Sie sind auf Seite 1von 2266

The AutoLisp/Visual Lisp/VBA

Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Basic and AutoCAD
In this section you will find a few applications that I've written using Visual Basic.
Most of them have been written to assist in a better understanding of VBA and AutoCAD.
I have supplied the source coding with all projects but you will need to have Visual
Basic 4, or above, installed on your system to view and/or modify the source coding
of the stand alone applications.
VB and VBA Tutorials
VBA Quick Tips G
AutoCAD API's G
An Introduction to VBA. G
VBA Primer. G
Userforms. G
Lisp To VBA. G
AutoCAD and Customizable Support Files G
VBA and Menu's G
VBA and Sequencial Text Files G
Hiding Dialogs and Other Things G
PolyLines and Arcs by Scott McGlynn G
Accessing AutoCAD by Scott McGlynn G
File Functions In Visual Basic G
Error Trapping G

VBA Applications
VBA Batch Purge. G
Change Text. G
VBA and Outlook. G
VBA and Powerpoint. G
Command Line Project. G
VBA Fax Project. G
Visual Basic Tutorials
http://www.afralisp.com/vba.htm (1 of 3) [23/03/2005 05:43:10 p.m.]
Timesheet Project. G
Loading VBA Projects. G
VBA and Excel. G
VBA and DataBases. G
VBA Steel Project. G
Drawing Setup Project. G
AutoLisp/VBA Drawing Setup G
The Utils Project. G
Drawing Layer Manager G
Save Manager G
Attributes and VBA G
VBA Steel by Cyril Horsey cyril_h@smartchat.net.au G
Multiple Inserts by Robert Endres Rendres@Landrum-Brown.com G
Block Attribute Modifier by Robert Endres Rendres@Landrum-Brown.com G
AutoCAD and HTML - VBA G
Publishing Code G
Batch Convert to AutoCAD R14 by Scott McGlynn G
VB Standalone Applications
Create a Toolbar DLL. G
Create a Toobar DLL Re-Visited G
DLL Resource Tool G
AfraLisp Screensaver. G
Batch Purge 2002. G
Batch Purge 2004. G
RC-Batcher. G
Randall Raaths Lisp Manager. G
VBA Partial Menu. G
The Acad Export Drawings Project. G
Batch Purge Project. G
AfraLisp Drawing Backup G
How to write unmaintainable code G
Shadow Controls G
AfraLisp Coffee Holder G
AutoCAD and HTML - VB G
Custom Application Setup G
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

Visual Basic Tutorials


http://www.afralisp.com/vba.htm (2 of 3) [23/03/2005 05:43:10 p.m.]
Submit
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Basic Tutorials
http://www.afralisp.com/vba.htm (3 of 3) [23/03/2005 05:43:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Welcome to AfraLisp
any moons ago whilst in a fit of madness or drunk - I
cannot remember which - I decided to write and publish a
simple web page containing a few AutoCAD Links and maybe a
couple of AutoLisp routines. Within a couple of days I began to
receive a few queries in regards to AutoLisp so decided to post
one or two Tutorials. That was the real beginning. Now, after
more than four years, AfraLisp has grown out of all proportion
in relation to my original intention.
AfraLisp now publishes over 100 AutoLisp Tutorials and nearly 50 VB/VBA Tutorials all open source and
complete with working examples. AfraLisp also publishes a download section containing many custom
AutoLisp applications written by AfraLisp as well as others.
AfraLisp also collaborates greatly with some other brilliant AutoLisp/VB/VBA sites, namely :
The Cad Vault is focused on helping you to improve your work environment
with tutorials and working code examples written in, and for, the most
popular customizing languages for the major CAD software programs and Microsoft Office products - Visual Basic
for Applications, Visual Basic, Visual C++, AutoLisp, Visual Lisp, and DCL.
And last but by no means least, CORBIMITE.COM is the host of AfraLisp and my thanks go to Frank
Zander for his generosity and support.
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AfraLisp-The AutoLisp/VBA Resource Website
http://www.afralisp.com/index.html (1 of 2) [23/03/2005 05:43:12 p.m.]
Submit
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp-The AutoLisp/VBA Resource Website
http://www.afralisp.com/index.html (2 of 2) [23/03/2005 05:43:12 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp and Visual Lisp Tutorials
Basic AutoLisp Tutorials
AutoLisp Quick Start G
The Basics in a Nutshell. G
Loading Autolisp Files G
Autolisp Quick Reference Table. G
System Variables - Download G
System Variables 2002 - Alphabetical & Topical - Download G
System Variables 2004 - Alphabetical & Topical - Download G
AutoCAD 2004 System Variables G
AutoCAD and Customizable Support Files G
Environment Variables Listing G
Migrating Express Tools G
Enhanced Express Tools 2002 Menu G
Enhanced Express Tools 2004 Menu G
DXF Group Codes - Download G
AutoCAD Command History - Download G
The AfraLisp AutoLisp Tutorials G
Default Drawing Folder G
AutoLisp Basics - Download G
AutoCAD API's G
AutoLisp and Menu's
Partial Menu's G
Partial Menu's - Visual Lisp G
Custom Hatch Patterns and Menu Access G
Creating Hatch Patterns G
Creating Linetypes G
Controlling Complex Linetypes G
Automating Menu Loading G
Preserving Custom Toolbars G
Menu Customisation G
Dealing with Tool Palettes G
AutoLisp and Visual Lisp Tutorials
http://www.afralisp.com/tutor.htm (1 of 5) [23/03/2005 05:43:13 p.m.]
Advanced AutoLisp Tutorials
Define Function (defun) G
Set and Setq G
Programme Looping G
Conditionals. G
Cond vs If G
Error Trapping G
Calculating Points (Polar) G
Locating Files. G
File Handling. G
External Data G
List Manipulation. G
Into the DataBase. G
DXF Group Codes. G
Selection Sets. G
Selection Set Filters G
Working With Layers & Styles. G
Polylines and Blocks. G
Extended Entity Data. G
(mapcar) and (lambda) G
The 'Eval' Function. G
Redefining Commands. G
Efficient Variables. G
The "DIR" Command. G
Colours and Linetypes ByLayer G
Debugging G
Dictionaries and XRecords. G
Basic Tool System Primer G
Dialogue Box Tutorials
Getting Started G
DCL Primer - Download G
Dialog Box Layout G
Dialogue Boxes Step by Step G
Dialogue Boxe in Action G
Nesting and Hiding Dialogues. G
Hiding Dialogues Revisited. G
AutoLisp Message Box. G
AutoLisp Input Box. G
Referencing DCL Files. G
AutoLISP Functions for Dialog Control Language (DCL) G
AutoLisp and Visual Lisp Tutorials
http://www.afralisp.com/tutor.htm (2 of 5) [23/03/2005 05:43:13 p.m.]
Functional Synopsis of DCL Files. G
DCL Attributes. G
Dialogue Box Default Data. G
DCL Model. G
DCL Progress Bar. G
Attributes and Dialogue Boxes G
DCL without the DCL File G
The AfraLisp DCL Tutorials G
Entering Edit Boxes G
AutoLisp Application Tutorials
Drawing Setup G
AutoLisp/VBA Drawing Setup G
Application Data. G
Time and Date Stamping. G
AutoLisp Macro Recorder. G
Auto-Breaking Blocks. G
List Variables/Functions. G
Lisp Help. G
DOSLib - Batch Slides. G
AfraLisp Slide Manager G
Working with Areas G
Lisp to HTML G
AutoCAD and HTML - AutoLisp G
AutoCAD and HTML - Revisited G
Environmental Issues G
Quick Plot G
AutoCAD Command Line Switches G
David Steins's DSXTools G
Dave Corrals DC-Tools G
AutoCAD Setup G
Express Tools Utilities G
Publishing Code G
Rtext and Drawing Setup G
AutoCAD & Binaries G
PolyLine Bulges G
A Look at Plan G
Custom Application Setup G
Standing Alone with Acad Install G
Visual Lisp Tutorials
The Visual Lisp Editor - The Beginning G
The Visual Lisp Editor G
AutoLisp and Visual Lisp Tutorials
http://www.afralisp.com/tutor.htm (3 of 5) [23/03/2005 05:43:13 p.m.]
The Beginning G
Viewing Objects G
Properties & Methods G
Methods Reference G
Arrays G
Selecting Objects G
Collections G
Reactors G
Menu's G
Error Trapping G
Layers G
Profiles G
Sample Profile Utilities G
Attributes G
Attributes Re-visited G
Loading VBA Files G
Directories and Files G
Compiling AutoLisp Files G
VLAX Enumeration Constants G
Polylines G
The Utilities Object G
Visual Lisp and VBA G
AutoCAD and HTML - Visual Lisp G
The AfraLisp Visual Lisp Tutorials G
David Steins's Visual LISP Developers Bible G
Visual Lisp Sample Files G
Scripting Objects G
"Talking" to External Applications G
How to make Tripe and Onion's G
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

AutoLisp and Visual Lisp Tutorials


http://www.afralisp.com/tutor.htm (4 of 5) [23/03/2005 05:43:13 p.m.]
Submit
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp and Visual Lisp Tutorials
http://www.afralisp.com/tutor.htm (5 of 5) [23/03/2005 05:43:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp Newsletter
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com
Archives 2004
Issue 2004-01 G
Issue 2004-02 G
Issue 2004-03 G
Issue 2004-04 G
Issue 2004-05 G
Issue 2004-06 G
Issue 2004-07 G
Issue 2004-08 G
Issue 2004-09 G
Issue 2004-10 G
Issue 2004-11 G
Issue 2004-12 G
Issue 2004-13 G
Issue 2004-14 G
Issue 2004-15 G
Issue 2004-16 G
Issue 2004-17 G
Issue 2004-18 G
Issue 2004-19 G
Issue 2004-20 G

Archives 2003
Issue 2003-01 G
Issue 2003-02 G
Issue 2003-03 G
Issue 2003-04 G
Issue 2003-05 G
Issue 2003-06 G
Issue 2003-07 G
Issue 2003-08 G
Issue 2003-09 G
Issue 2003-10 G
Issue 2003-11 G
Issue 2003-12 G
Issue 2003-13 G
Issue 2003-14 G
Issue 2003-15 G
Issue 2003-16 G
Issue 2003-17 G
Issue 2003-18 G
Issue 2003-19 G
Issue 2003-20 G
Issue 2003-21 G
Issue 2003-22 G
Issue 2003-23 G
Issue 2003-24 G

AfraLisp Newsletter
http://www.afralisp.com/newsletter/newsletter.htm (1 of 3) [23/03/2005 05:43:15 p.m.]
Submit
Archives 2002
Issue 2002-01 G
Issue 2002-02 G
Issue 2002-03 G
Issue 2002-04 G
Issue 2002-05 G
Issue 2002-06 G
Issue 2002-07 G
Issue 2002-08 G
Issue 2002-09 G
Issue 2002-10 G
Issue 2002-11 G
Issue 2002-12 G
Issue 2002-13 G
Issue 2002-14 G
Issue 2002-15 G
Issue 2002-16 G
Issue 2002-17 G

Archives 2001
Issue 2001-01 G
Issue 2001-02 G
Issue 2001-03 G
Issue 2001-04 G
Issue 2001-05 G
Issue 2001-06 G
Issue 2001-07 G
Issue 2001-08 G
Issue 2001-09 G
Issue 2001-10 G
Issue 2001-11 G
Issue 2001-12 G
Issue 2001-13 G
Issue 2001-14 G
Issue 2001-15 G

Archives 1999
Issue 03-05-99 G
Issue 12-05-99 G
Issue 27-05-99 G
Issue 01-06-99 G
Issue 11-06-99 G
Issue 18-06-99 G
Issue 23-06-99 G
Issue 06-07-99 G
Issue 10-07-99 G
Issue 22-07-99 G
Issue 30-07-99 G
Issue 02-08-99 G
Issue 15-08-99 G
Issue 25-08-99 G
Issue 08-09-99 G
Issue 17-09-99 G
Issue 06-10-99 G
Issue 12-10-99 G
Issue 18-10-99 G
Issue 28-10-99 G
Issue 01-11-99 G

The AfraLisp Newsletter PDF Archives


If you so wish, you can download, in PDF format, all of the AfraLisp Newsletters.
This service will be updated on approx. a three monthly basis and/or as time allows.
Latest Updated Download : Issue 03-05-99 to 2004-07 Dated March 9th 2004 ( 1033 Kb )
New!! You can now download the AfraLisp Newsletters PLUS all 3 AfraLisp Books in one installation file. To do
AfraLisp Newsletter
http://www.afralisp.com/newsletter/newsletter.htm (2 of 3) [23/03/2005 05:43:15 p.m.]
so, just click here. ( 5227 kb)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter
http://www.afralisp.com/newsletter/newsletter.htm (3 of 3) [23/03/2005 05:43:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
"Utter Rubbish"
Page II Page III Page IV Page V
Warning : Some of the articles in this section are slightly blue in nature, include bad language, are sexist
and are generally insulting to a whole cross section of people.
You have been warned!!
Disclaimer: If you take this section seriously you are an idiot, and any damages caused by taking these
articles seriously are deemed to be too bad.

Memo from Bin Laden


To: All Al Qaeda Fighters
From: Bin Laden, Osama
Subject: The Cave
Hi Guys
We have been putting in long hours recently but weve really come together as a
group and I love that. However, while we are fighting a jihad, we cant forget to
take care of the cave, and frankly I have a few concerns:
Fist of all, while it is good to be concerned about cruise missiles, we should be
even more concerned about the dust in our cave. We want to avoid excessive
dust inhalation, (a health and safety issue) so we need to sweep the cave daily.
I have done my bit on the cleaning rosterhave you??
I have posted a sign-up sheet near the cave reception area. Next to the halaal toaster.
Second: It is not often I make a video address but when I do, Im trying to scare the
living shit out of most of the worlds population, okay? That means that while were
taping; please do not ride your scooter in the background or keep doing the
Wassup thing. Thanks.
Third: Food. I bought a box of Dairylea recently. Clearly wrote Ossy on the front,
and put it on the top shelf. Today, two of my Daillea slices were gone.
Consideration. Thats all Im saying.
Fourth: Im not against team spirit and all that, but we must distance ourselves
from the Infidels bat and ball games. Please do not chant Ossy, Ossy Ossy, Oy Oy Oy
when I ride past on my donkey. Thanks.
Five: Graffiti. To whoever wrote OSAMA SHAGS DONKEYS on the group toilet wall,
its a lie. The donkey backed into me whilst I was relieving myself at the edge of the
mountain.
Six: The use of chickens is strictly for food. Assam, the old excuse that the chicken
backed into me, whilst I was relieving myself at the edge of a mountain will not
be accepted in the future. (With donkeys, there is a grey area)
Finally: Weve heard that there may be Western soldiers in disguise trying to infiltrate
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (1 of 18) [23/03/2005 05:43:19 p.m.]
our ranks. I want to set up patrols to look for them. First patrol will be Omar, Muhammad,
Abdul, Akbar and Dave.
Love you lots, Group hug.
Os
More Dinosaurs Are The Solution To The Oil Crisis
From somewhere off the web
IF YOU'VE been to a gas station lately, you have no doubt been shocked by the prices: $1.67, $1.78,
even $1.92. And that's just for Hostess Twinkies. Gas prices are even worse. Americans are ticked off
about this, and with good reason: Our rights are being violated! The First Amendment clearly states: "In
addition to freedom of speech, Americans shall always have low gasoline prices, so they can drive
around in 'sport utility' vehicles the size of minor planets."
And don't let any so-called "economists" try to tell you that foreigners pay more for gas than we do.
Foreigners use metric gasoline, which is sold in foreign units called "kilometers," plus they are paying
for it with foreign currencies such as the "franc," the "lira" and the "doubloon." So in fact there is no
mathematical way to tell WHAT they are paying.
But here in the United States we are definitely getting messed over, and the question is: What are we
going to do about it?
Step 1, of course, is to file a class-action lawsuit against the cigarette companies. They have nothing to
do with gasoline, but juries really hate them, so we'd probably win several hundred billion dollars. But
that is a short-term answer. To truly solve this problem, we must understand how the oil business
works. Like most Americans, you probably think that gasoline comes from the pump at the gas station.
Ha ha! What an idiot. In fact, the gasoline comes from tanks UNDER the gas station. These tanks are
connected to underground pipelines, which carry large oil tankers filled with oil from the Middle East.
But how did the oil get in the Middle East in the first place? To answer that question, we must go back
millions of years, to an era that geologists call the Voracious Period, when giant dinosaurs roamed the
Earth, eating everything that stood in their path,
except for broccoli, which they hated. And then, one fateful day (Oct. 8), a runaway asteroid, believed by
scientists to be nearly twice the diameter of the late Orson Welles, slammed into the Earth and killed the
dinosaurs, who by sheer bad luck all happened to be standing right where it landed. The massive
impact turned the dinosaurs, via a process called photosynthesis, into oil; this oil was then gradually
covered with a layer of sand, which in turn was gradually covered by a layer of people who hate each
other, and thus the Middle East was formed. For many years, the Middle East was content to supply the
United States with as much oil as we wanted at fair constitutional prices. But then the major
oil-producing nations-Saudi Arabia, Iran, Iraq, Kuwait and Texas-got all snotty and formed an
organization called OPEC, which stands for "North Atlantic Treaty Organization." In the 1970s, OPEC
decided to raise prices, and soon the United States was caught up in a serious crisis: The Disco Era. It
was horrible. You couldn't go to a bar or wedding reception without being ordered onto the dance floor
to learn "The Hustle."
AT THE SAME time, we also had an oil crisis, which was caused by the fact that every motorist in the
United States was determined to keep his or her automobile gas tank completely filled at all times. As
soon as your gas gauge dropped from "Full" to "Fifteen-sixteenths," you'd rush to a gas station and get
in a huge line with hundreds of other motorists who also had nearly full tanks. Also a lot of people,
including me, saved on heating oil by buying kerosene space heaters, which enabled us to transform a
cold, dank room into a cold, dank room filled with kerosene fumes. Buying gas and dancing "The
Hustle" with people who smelled like kerosene: That was the '70s.
So anyway, the oil crisis finally ended, and over time we got rid of our Volkswagen Rabbits and replaced
them with Chevrolet Suburbans boasting the same fuel economy as the World Trade Center. Now, once
again, we find ourselves facing rising gas prices, and the question is: This time, are we going to learn
from the past? Are we finally going to get serious about energy conservation? Of course not! We have
the brains of mealworms! So we need to get more oil somehow. As far as I can figure, there's only one
practical way to do this. That's right: We need to clone more dinosaurs.
We have the technology, as was shown in two blockbuster scientific movies, "Jurassic Park" and
"Jurassic Park Returns with Exactly the Same Plot." Once we have the dinosaurs, all we need is an
asteroid. Or, if he is available, Marlon Brando.
If this plan makes sense to you, double your medication dosage, then write to your congressperson.
Do it now! That way you'll be busy when I siphon your tank.
Aussie Humour
From down under.
The AfraLisp Fortune Teller
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (2 of 18) [23/03/2005 05:43:19 p.m.]
Pop in here to have your fortune told.
All You Needed To Know About Life
Author Unknown
If you take an Oriental person and spin him around several times, does he become disoriented?
- Only if he has to much to much saki before hand.
If people from Poland are called Poles, why aren't people from Holland called Holes?
- Dutchmen were called 'Holes' before the Pope in the Vatican kicked up a fuss when they were refered to as
'Holey-men'.
Do infants enjoy infancy as much as adults enjoy adultery?
- I know I did.
Why is the man who invests all your money called a broker?
- The word 'broker' has Spanish origins, alboroque, meaning 'ceremonial gift at conclusion of business deal'.
e.g., while they are making you money, they get a 'little gift' along the way.
Why is a person who plays the piano called a pianist, but a person who drives a race car not called a
racist?
What is the difference between a slim chance and a fat chance?
- From Old England when milk demand was high, so getting your milk was a problem. The chance of getting
slim milk and the chance of getting normal [fat] milk was known as slim chance and fat chance.
Why are a wise man and a wise guy opposites?
- Wise men were from biblical times and prefered to freely give away gifts to any new-born they saw at
Christmas time, whereas Wise guys were from America and prefered to sit on their ass all day and watch
repeats of 'The 3 Stooges' and so called named by the famous line 'Wise guys ,eh ?'. The Differences are quite
obvious.
Why do overlook and oversee mean opposite things?
- The two words overlook and oversee did have the same meaning [supervise] until the 1870's when many
construction site supervisors were turning blind eyes to malpractice on the site which risked their job. These
fore-men were then known as 'over-lookers' while the remaining men were known as the 'over-seers' where
from today's meanings evolved.
If horrific means horrible, does terrific mean terrible?
- Erm, yes it does. Both words terrific and terrible come from the same latin word, terrere, which means frighten.
Why isn't 11 pronounced onety-one?
- Onety-one became redundant when the wristwatch became widely popular. The word 'eleven' was introduced
to help the confusion when asked the time by another person, 11 o'clock or 'onety-one' was always
misunderstood as 'one to one'.
Do Roman paramedics refer to IVs as 4s?
- Quite by coincidence, the IVs [intravenous drip] used then were very similar this modern day and the length of
delivery tube to the vein was four feet.
If lawyers are disbarred and clergymen defrocked, doesn't it follow that electricians can be delighted,
musicians denoted, cowboys deranged, models deposed, tree surgeons debarked and dry cleaners
depressed?
- And I dare say porn stars are denuded, wine makers are deported, portrait artists are defaced and hens are
delayed.
Why do croutons come in airtight packages? It's just stale bread to begin with.
- And why does sour cream have a use-by date ?
When cheese gets its picture taken, what does it say?
- "Humans!"
If you mixed vodka & orange juice with milk of magnesia, would you get a Philip's Screw Driver?
- I dunno, but if you had too many, you'd vomit half back up and the other half out the rear end!!!
If a pig loses his voice, is it disgruntled?
- If a pig has lost its voice, it would have therefore been slaughtered. I think being disgruntled would be the last
thing on its mind.
'I am' is reportedly the shortest sentence in the English language. Could it be that 'I do' is the longest
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (3 of 18) [23/03/2005 05:43:19 p.m.]
sentence?
- Although the average marriage length has fallen over the last century, it is still a lot longer than just saying 'I
am".
If love is blind, why is lingerie so popular?
- Because men may be blind when it comes to love, but they know what's underneath it.
Why do women wear evening gowns to nightclubs? Shouldn't they be wearing nightgowns?
- A nightgown is a loose undergarment which women wear to bed. I should hope no female wishes to go out in
her nightgown [or maybe I should be hoping]
Why do they say something is out of whack? What is a whack?
- Term usually only used by junkies, where, they are in a coma are said to be 'out of whack'. A second term
coined by the junkies has a more literal meaning where 'whack', which of course means - hit. 'Out of whack' was
also out of drugs.
When someone asks you, A penny for your thoughts, and you put your two cents in, what happens to
the other penny?
- This was all part of the government's harsh "50% Two Cent Thought Tax" where after you have given your two
cents, the recipient must then remit 50% [one cent] to the tax department before the end of the month.
If you throw a cat out of the car window, does it become kitty litter?
- Only say, if another cat came up to it in the street, did it's business on its head, covered it with some gravel,
and then some-one chased you down to tell you to change it more often because it still stinks.
If you choke a Smurf, what color does it turn?
- Erm... blue.
Is it OK to use the AM radio after noon?
- Although the radio station owners find it cheaper not to, seeing people know its after midday, some stations
still can be found and listened to safely.
What do people in China call their good plates?
- Roughly, it translates to "a luxury"
What do you call a male ladybird?
- Mr. Ladybird.
What hair color do they put on the driver's license of a bald man?
- Most say 'none', but the modest ones say 'transparent'.
When dog food is new and improved tasting, who tests it?
- Erm... dogs.
Why do they sterilise the needle for lethal injections?
- So the dead person's lawyer cannot sue for negligence.
Why doesn't glue stick to the inside of the bottle?
- Erm... it does.
Why is it called tourist season if we can't shoot at them?
- The liberationists and greenies would be up in arms over the culling of poor, defenceless tourists.
Have you ever imagined a world without hypothetical situations?
- I would imagine that I wouldn't have to see a psychiatrist.
How does the guy who drives the snowplough get to work?
- Special underground cave networks that only classified people are allowed to know about.
If the 7 11 is open 24 hours a day, 365 days a year, why does it have locks on the door?
- For when it closes every 4 years on Feb. 29, the 366 day in a leap year.
If a fire-fighter fights fire and a crime fighter fights crime, what does a freedom fighter fight?
- Erm... freedom.
If they squeeze olives to get olive oil, how do they get baby oil?
- Of course, they only very gently squeeze them.
Why don't sheep shrink when it rains?
- The sheep themselves do not shrink, but the wool fibres on them shrink up to 10%.
What do chickens think we taste like?
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (4 of 18) [23/03/2005 05:43:19 p.m.]
- Firstly, they wonder how to get us in the oven.
Why didn't Noah swat those two mosquitoes?
- Swatters were not invented until post-biblical times.
Why do you need a driver's license to buy liquor when you can't drink and drive?
- Back in the days of alcohol prohibition, some retailers found a loop-hole in the law. The found it was not illegal
to sell liquor if it was to only be drunk in the vehicle whilst stationery, where they needed proof that the buyer did
own a car by having them show their licence. The tradition remains today.
Why are there flotation devices in the seats of planes instead of parachutes?
- We all know dead bodies in orange floaties are easier to see than dead bodies under parachutes.
Why are cigarettes sold at gas stations where smoking is prohibited?
- They used to sell guns, but they were considered dangerous. Go figure.
Why is a bra singular and panties plural?
- Both words have evolved over their years of use. Bra, of course, short for 'brassiere' is actually plural [from
Latin 'clothing hard to get off in dark by male']. Whereas, panties is a more feminine word for 'pant' which is
singular [from Latin 'male breathing heavy, as she hasn't got them off yet']
You know that indestructible black box that is used on airplanes? Why don't they make the whole plane
out of that stuff?
- Would you want to fly in a big, black, rectangular box which taped each conversation you had during your flight
and could only be opened by special secret-service agents ?
If you are driving at the speed of light and you turn your headlights on, what happens?
- The particles of light, or 'photons' they are called, are so abrasive at that as they slow down and you continue
your speed, it wears away at your car until of course, you crash and die.
Why do they put Braille dots on the keypad of a drive-up ATM?
- Erm... in case the blind person is behind in the back seat.
Why is it that when you transport something by car it is called shipment, but when you transport
something by ship it's called cargo?
- 'Shipment' by car was coined when people carting goods by car on a ferry was still called by ship, even when it
reached land, to tell where it came from. Ship's 'cargo' is from the French when the primary use of boats in
France was to ship snails for consumption [or as its called 'escargot'].
What would Geronimo say if he jumped out of an airplane?
- "What the fuck am I doing out of the plane ???"
Why are they called apartments when they are all stuck together?
- 'Apartments' were first built in the 1700's by the Scots, where they were apart from each other in the rural
country areas, some up to 3 miles apart. But fashionable Scots found moving them into cities required them to
be built next to each other.
If con is the opposite of pro, is Congress the opposite of progress?
- If you are the minority in the Congress, it certainly would.
If flying is so safe, why do they call the airport the terminal?
- Terminal is Latin for 'boundary', which is only a reference to the perimeter fence around to airport to stop
way-ward car-drivers getting on the runway.
If nothing sticks to teflon, how does it stick to the pan?
- Only the top surface of the 'Teflon' is non-stick, which is why the workers in the factory have to be very careful
putting the Teflon on the pan.
If you tickled a cow, would milk come out of its' nose?
- No. Only snot out its nose and a kick in your groin is all you will get.
Woman: Is there a problem, Officer?
Officer: Ma'am, you were speeding.
Woman: Oh, I see.
Officer: Can I see your license please?
Woman: I'd give it to you but I don't have one.
Officer: Don't have one?
Woman: Lost it 4 times for drunk driving.
Officer: I see...Can I see your vehicle registration papers please.
Woman: I can't do that.
Officer: Why not?
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (5 of 18) [23/03/2005 05:43:19 p.m.]
Woman: I stole this car.
Officer: Stole it?
Woman: Yes, and I killed and hacked up the owner.
Officer: You what?
Woman: His body parts are in plastic bags in the trunk if you want to see.
The Officer looks at the woman and slowly backs away to his car and calls for back up. Within minutes 5
police cars circle the woman and a senior officer slowly approaches the car, clasping his half drawn
gun.
Officer 2: Ma'am, could you step out of your vehicle please!
Woman: Is there a problem sir?
Officer 2: The officer told me that you stole this car and murdered the owner.
Woman: Murdered the owner?
Officer 2: Yes, could you open the trunk of your car, please.
The woman opens the trunk, revealing nothing but an empty trunk.
Officer 2: Is this your car, ma'am?
Woman: Yes, here are the registration papers.
The officer is quite stunned.
Officer 2: The officer claims that you do not have a driver's license.
The woman digs into her handbag and pulls out a clutch purse and hands it to the officer. The officer
snaps open the clutch purse and examines the license. He looks quite puzzled.
Officer 2: I must admit, ma'am, that I'm confused; the officer told me you didn't have a license, that you
stole this car, and that you murdered the owner.
Woman: I suppose the lying bastard told you I was speeding, too.
I heard today that Iraq had developed a special weapon for use against the Canadian Navy. It was called
a rust-seeking missile.
===========
In Iraq, I believe that they're replacing 100,000 Desert Marines with 1,000 women with PMS.
They're meaner, and they can retain water for 7 days
===========
What was Saddam Hussein's wife telling neighbors who asked why she's leaving the country?
a) "We're having some remodeling done."
b) "The exterminators are coming."
c) "We're getting the carpets bombed."
d) All of the above.
===========
Adviser: "Well, Mr. President, the deadline's expired. What shall we do?"
Bush: "Send in Colin Powell!"
Adviser: "Isn't that rather a limited strike, sir?"
Bush: "No, I mean send him in to my office!"
Powell: "Sir!"
Bush: "What would be the result of an air strike on Wednesday night?"
Powell: "Millions of innocent civilians killed and the city razed to the ground, Sir!"
Bush: "You know I don't understand that military jargon! Give it to me in words I can understand."
Powell: "Personnel density adjustment and strategic collateral upheaval, Sir!"
Bush: "That bad?!"
===========
Q. What is common between Saddam and Dukakis?
A. They both couldn't believe they lost to Bush.
===========
I can't quite call anything that drops off a plane traveling several hundred miles an hour and few
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (6 of 18) [23/03/2005 05:43:19 p.m.]
thousand feet in the air to dive nose first into a concrete wall just to explode "smart."
===========
How do you play Iraqi bingo?
B-52...F-16...B-52
===========
What is the Iraqi air force motto?
I came, I saw, Iran.
---------------------------------------------------------------------------------
Have you heard about the new Iraqi Air Force exercise program?
Each morning you raise your hands above your head and leave them there.
---------------------------------------------------------------------------------
What's the five-day forecast for Baghdad?
Two days.
---------------------------------------------------------------------------------
What do Miss Muffet and Saddam Hussein have in common?
They both have Kurds in their way.
---------------------------------------------------------------------------------
What is the best Iraqi job?
Foreign ambassador.
---------------------------------------------------------------------------------
Did you hear that it is twice as easy to train Iraqi fighter pilots?
You only have to teach them to take off.
---------------------------------------------------------------------------------
What is Iraq's national bird?
Duck.
---------------------------------------------------------------------------------
What do Saddam Hussein and General Custer have in common?
They both want to know where the hell those Tomahawks are coming from!
---------------------------------------------------------------------------------
Why does the Iraqi Navy have glass bottom boats?
So they can see their air force.
Stanley stops by to visit his friend who is paralyzed from the waist down.
They talk for a while and then the friend asks, "My feet are cold.
Would you be so kind as to go get me my house slippers please?"
Stanley obliges and goes upstairs.
There he sees his friend's daughters, both very good looking.
Being the adventurous and quick thinking kind, he says.....
"Hi, ladies! Your daddy sent me here to have sex with you!"
They stare at him and say, "That can't be!"
He replies, "OK, let's check!"
He shouts at his friend down the stairs, "Both of them?"
......"Yes, both of them!"
New Technology
An American, a Japanese and an Irishman were sitting naked in a sauna. Suddenly, there was a beeping
sound. The American pressed his forearm and the beep stopped. The others looked at him
questioningly. "That was my pager," he said, "I have a microchip under the skin of my arm." A few
minutes later a phone rang. The Japanese fellow lifted his palm to his ear. When he finished he
explained "That was my mobile phone, I have a microchip in my hand." The Irishman felt decidedly low
tech, but not to be outdone he decided he had to do something just as impressive. He stepped out of
the sauna and went to the toilet. He returned with a piece of toilet paper hanging from hisbehind. The
others raised their eyebrows and stared at him.
The Irishman finally said Well, will you look at that, I'm getting a fax.
Top 10 Historical uses of the 'F' word...
1 - "Scattered f___ing showers, my ass!" - Noah, 4314 BC
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (7 of 18) [23/03/2005 05:43:19 p.m.]
2 - "How the f___ did you work that out?" - Pythagoras, 126 BC
3 - "You want THAT on the f___ing ceiling?" - Michelangelo, 1566
4 - "Where did all those f___ing Indians come from?" - Custer,1877
5 - "It does so f___ing look like her!" - Picasso, 1926
6 - "Where the f___ are we?" - Amelia Earhart, 1937
7 - "Any f___ing idiot could understand that." - Einstein, 1938
8 - "What the f___ was that?" - Mayor Of Hiroshima, 1945
9 - "I need this parade like I need a f___ing hole in the head!" -
JFK,1963
10 - "Aw c'mon. Who the f___ is going to find out?" - Bill Clinton,1997
SOMETHING TO OFFEND EVERYONE PART I
What do you call two Mexicans playing basketball?
Juan on Juan.
What is a Yankee?
The same as a quickie, but a guy can do it alone.
What is the difference between a Harley and a Hoover?
The position of the dirt bag.
Why is divorce so expensive?
Because it's worth it.
What do you see when the Pillsbury Dough Boy bends over?
Doughnuts.
Why is air a lot like sex?
Because it's no big deal unless you're not getting any.
SOMETHING TO OFFEND EVERYONE PART II (JUST WARMING UP!)
What do you call a smart blonde?
A golden retriever.
What do attorneys use for birth control?
Their personalities.
What's the difference between a girlfriend and wife?
45 lbs.
What's the difference between a boyfriend and husband?
45 minutes.
What's the fastest way to a man's heart?
Through his chest with a sharp knife.
Why do men want to marry virgins?
They can't stand criticism.
Why is it so hard for women to find men that are sensitive, caring, and good-looking?
Because those men already have boyfriends.
What's the difference between a new husband and a new dog?
After a year, the dog is still excited to see you.
What makes men chase women they have no intention of marrying?
The same urge that makes dogs chase cars they have no intention of driving.
Why don't bunnies make noise when they have sex?
Because they have cotton balls.
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (8 of 18) [23/03/2005 05:43:19 p.m.]
What's the difference between a porcupine and BMW?
A porcupine has the pricks on the outside.
What did the blonde say when she found out she was pregnant?
"Are you sure it's mine?"
Why does Mike Tyson cry during sex?
Mace will do that to you.
Why did OJ Simpson want to move to West Virginia?
Everyone has the same DNA.
Why do men find it difficult to make eye contact?
Breasts don't have eyes.
Did you hear about the dyslexic Rabbi?
He walks around saying "Yo."
Why do drivers' education classes in Redneck schools use the car only on Mondays, Wednesdays and
Fridays?
Because on Tuesday and Thursday, the Sex Ed class uses it.
SOMETHING TO OFFEND EVERYONE, PART III (Just Great Stuff)
Where does an Irish family go on vacation?
A different bar.
Did you hear about the Chinese couple that had a retarded baby?
They named him "Sum Ting Wong"
What would you call it when an Italian has one arm shorter than the other?
A speech impediment.
What does it mean when the flag at the Post Office is flying at half-mast?
They're hiring.
What's the difference between a southern zoo and a northern zoo?
A southern zoo has a description of the animal on the front of the cage along with... "a recipe".
How do you get a sweet little 80-year-old lady to say the F word?
Get another sweet little 80-year-old lady to yell *BINGO*!
What's the difference between a northern fairytale and a southern fairytale?
A northern fairytale begins "Once upon a time..."
A southern fairytale begins "Y'all ain't gonna believe this shit..."
Why is there no Disneyland in China?
No one's tall enough to go on the good rides.
What did the guitarist do when his teacher told him to turn his amplifier on?
He caressed it softly and told it that he loved it.
Why do bagpipe players walk while they play?
To get away from the noise.
How many country & western singers does it take to change a light bulb?
Three. One to change the bulb and two to sing about the old one.
What does it say on a blues singer's tombstone?
"I didn't wake up this morning..."
What's the difference between a bull and an orchestra?
The bull has the horns in the front and the asshole in the back.
What would a musician do if he won a million dollars?
Continue to play gigs until the money ran out.
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (9 of 18) [23/03/2005 05:43:19 p.m.]
A man was walking down the street when he was accosted by a particularly dirty and shabby-looking
homeless man who asked him for a couple of dollars for dinner. The man took out his wallet, extracted
two dollars and asked, "If I gave you this money, will you buy some beers with it instead?"
"No, I stopped drinking years ago," the homeless man said.
"Will you use it to gamble instead of buying food?" the man asked.
"No, I don't gamble," the homeless man said. "I need everything I can get just to stay alive."
"Will you spend the money on greens fees at a golf course instead of food?" the man asked.
"Are you NUTS!" replied the homeless man. "I haven't played golf in 20+ years!"
"Well," said the man, "I'm not going to give you two dollars. Instead, I'm going to take you home for a
terrific dinner cooked by my wife."
The homeless man was astounded. "Won't your wife be furious with you for doing that? I know I'm dirty,
and I probably smell pretty bad."
The man replied, "Hey, man, that's okay! I just want her to see what a man looks like who's given up
beer, gambling, and golf!
Five men were bragging about how smart their dogs were. One was an
engineer, the second man was an accountant, the third man was a chemist,
the fourth was a computer tech, and the fifth was a government worker.
To show off, the engineer called his dog."T-square, do your stuff."
T-square trotted over to a desk, took out some paper and a pen and
promptly drew a circle, a square and a triangle. Everyone agreed that was
pretty incredible.
But the accountant said his dog could do better. He called to his dog
and commanded "Spreadsheet, do your stuff."
Spreadsheet went out into the kitchen and returned with a dozen
cookies. He divided them into 4 equal piles of 3 cookies each. Everyone
agreed that was good.
But the chemist said his dog could do better. He called to his dog
and said,"Measure, do your stuff. " Measure got up, walked over to
the fridge, took out a quart of milk, got a 10 ounce glass from the
cupboard and poured exactly 8 ounces without spilling a drop. Everyone
agreed that was
more than a little impressive.
The computer tech knew he could top them all."Hard Drive' have at
it." Hard Drive crossed the room and booted the computer, checked for
viruses, upgraded the operating system, sent an email, and installed a cool
new game.
Everyone knew that was a tough act to follow.
Then the four men turned to the government worker and said, "What can
your dog do?"
The government worker called to his dog and said, "Coffee Break, do
your stuff, Boy."
Coffee Break jumped to his feet, ate the cookies, drank the milk,
erased all the files on the computer, screwed the other four dogs, claimed
he injured his back while doing so, filed a grievance report for
unsafe working conditions, put in for workers compensation and went
home for six-month sick leave.
A man walks into a pharmacy and wanders up and down the aisles.
The salesgirl notices him and asks him if she can help him.
He answers that he is looking for a box of tampons for his wife.
She directs him down the correct aisle.
A few minutes later, he deposits a huge bag of cotton balls and a ball of string on the counter.
She says, confused, "Sir, I thought you were looking for some tampons for your wife?"
He answers, "You see, it's like this. Yesterday, I sent my wife to the store to get me a carton of
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (10 of 18) [23/03/2005 05:43:19 p.m.]
cigarettes, and she came back with a tin of tobacco and some rolling papers.... 'cause it's
sooooooooooo much cheaper. So....I figure if I have to roll my own... so does she...."
Things I Hate, by Billy Connolly..
1. People who point at their wrist while asking for the time....I know where my watch is pal, where the
f*ck is yours? Do I point at my crotch when I ask where the toilet is?
2. People who are willing to get off their arse to search the entire room for the TV remote because they
refuse to walk _to the TV and change the channel manually.
3. When people say "Oh you just want to have your cake and eat it too"
F*cking right! What good is a cake if you can't eat it?
4. When people say "it's always the last place you look". Of course itis. Why the f*ck would you keep
looking _after you've found it? Do people do this? Who and where are they?
5. When people say while watching a film "did you see that?". No tosser,
I paid 10 quid to come to the cinema _and stare at the f*cking floor.
6. People who ask "Can I ask you a question?". Didn't really give me a choice there, did you sunshine?
7. When something is 'new and improved!'. Which is it? If it's new, then there has never been anything
_before it. If it's an improvement, then there must have been something before it.
8. When people say "life is short". What the f*ck?? Life is the longest damn thing anyone ever f*cking
does!! What can you do that's longer?
9. When you are waiting for the bus and someone asks, "Has the bus come yet?".
If the bus came would I be standing here, Knobhead?
10. People who say things like 'My eyes aren't what they used to be'.
So what did they used to be? ears, _Wellington boots?
11. When you're eating something and someone asks 'Is that nice? 'No it's really revolting - I always eat
stuff I hate.
12. People who announce they are going to the toilet. Thanks that's an image I really didn't need.
13. McDonalds staff who pretend they don't understand you unless you insert the 'Mc' before the item
you are ordering.....It's has to be a McChicken Burger, just a Chicken Burger get blank looks. _Well I'll
have a McStraw and jam it in your McEyes you _f*cking McTosser.
14. When you involved in a accident and someone asks 'are you alright?'Yes fine thanks, I'll just pick up
my _limbs and be off - See Ya.
The Drinkers Prayer
(Author Unknown)
Starkle, starkle, little twink,
Who the hell are you I think.
I'm not under what you call
The alcofluence of incohol.
I'm just a little slort of sheep,
I'm not drunk like thinkle peep.
I don't know who is me yet,
But the drunker I stand here the longer I get.
So just give me one more fink to drill my cup,
'Cause I got all day sober to Sunday up.
Age
(Authors Unknown)
Three old men are walking on the sidewalk.
First one says, "Windy, isn't it?"
Second one says, "No, its Thursday!"
Third one says, "So am I. Let's go get a beer."
------------------------------------
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (11 of 18) [23/03/2005 05:43:19 p.m.]
A man was telling his neighbor, "I just bought a new hearing aid. It cost me four thousand dollars, but
it's state of the art. It's perfect."
"Really," answered the neighbor. "What kind is it?"
"Twelve thirty."
------------------------------------
Morris, an 82 year-old man, went to the doctor to get a physical.
A few days later the doctor saw Morris walking down the street with a gorgeous young lady on his arm.
A couple of days later the doctor spoke to Morris and said, "You're really doing great, aren't you?"
Morris replied, "Just doing what you said, Doc: 'Get a hot mamma and be cheerful.' "
The doctor said, "I didn't say that. I said, 'You got a heart murmur. Be careful.'"
------------------------------------
As a senior citizen was driving down the freeway, his car phone rang.
Answering, he heard his wife's voice urgently warning him, "Herman, I just heard on the news that
there's a car going the wrong way on Interstate 280. Please be careful!"
"It's not just one car," said Herman. "It's hundreds of them!"
----------------------------------------
An elderly gent was invited to his old friends' home for dinner one evening.
He was impressed by the way his buddy preceded every request to his wife with endearing terms -
Honey, My Love, Darling, Sweetheart, Pumpkin, etc...
The couple had been married almost 70 years, and clearly they were still very much in love.
While the wife was in the kitchen, the man leaned over and said to his host,
"I think it's wonderful that, after all these years, you still call your wife those loving pet names."
The old man hung his head. "I have to tell you the truth," he said, "I forgot her name
about 10 years ago."
So, you think you are clever do you?
(Kenny Ramage - March 2003)
So, you think you are clever do you?
Well, let me burst your bubble!!!!
There are some of you that know that I am a "Rock Super Star".
There are maybe still a few that still need to learn that!!
If so, you are one of the uninformed. Pay a visit here:
BedRock -The Band In The Sand
Okay, feel better now?
===================
Aside from my "musical" pastime, I've been heavily involved with coding and websites for many a year.
My main claim to fame though, is that I am a professional drawing office manager. I spent over 15 post
apprenticeship years on "the board" before moving into the realms of management. I know all the buzz
words. In fact, I wrote most of them, purely to piss the upper management off - I failed - they liked them.
Next time they ask you for a "balanced score card", blame me. I started it all by claiming that our pilots
should be the perfect example of one. Same number of landings as take-offs!
Anyway, what I was getting around to was this.
Do you want to be a professional coder?
Do you want to be a professional draughtsman/designer/whateveryoucallitinyourcountry?
Then you more than likely need to put in a bit of work and money.
Example from me in regards to my musical pastime:
Personal cost to me to produce the new CD, $3000 US (remember, there's 4 in the band). We've now
moved into the realms of Video/DVD - my share so far, $500 US - and we've just started on this project.
This does not include personal time, leave from work, personal equipment costs such as guitar strings,
amp blowing up, etc. Oh, and my beer bill is horrendous and my wife often doesn't speak to me.
We will recover most of it within a month - maybe two, but the point I'm trying to make is this! To
succeed - or should I get to basics here - to make a living out of something you do, takes a great deal of
investment in yourself.
I read nearly every post on VB Expresso, and I must say one thing - there are some really talented
people within this forum. BUT................ a lot of you have not got a clue of how to market yourself or
your talents. How can you say that Kenny? We are the elite of the CAD coding world. We can answer
any question that is thrown at us. We are the best!
Humbug. I say!!
First lesson:
You must learn how to sell yourself.
Don't do or give anything for free unless you receive some sort of payment, no matter how indirectly, in
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (12 of 18) [23/03/2005 05:43:19 p.m.]
return.
Example: I run AfraLisp and have spent many hours and "given" away lot's of ideas. True, but in my part
of the world, my marketability is way above my peers. And so is my salary and other perks.
Second Lesson:
You must learn how to communicate.
Example: Why do you have a strange handle such as "butlicker" or "womanizer"? Use your name. If
you're afraid of being recognized and your words don't carry the courage of your convictions, then don't
bother posting. You cannot use your participation on the web in your CV if you use a strange name.
Remember, this is business. It is not a teenage chat room. Check your spelling and your grammar. Hey,
your next boss could be reading your last post.
Third lesson: Make friends.
It's easy to criticise someone else's coding. It's even easier to do it in a nasty way. Don't!! Be a
gentleman or a lady at all times.
Example: I get all sorts of correspondence in regards to AfraLisp and Cad Encoding. The majority is
good, some downright rude. Each and every one receives a reply varying from friendly to polite, polite
being the key word here. Yes, you do have to put up with shit. Hey, it's a tough world. Don't dish it back,
learn how to deal with it. The web makes it very easy to hide behind an electronic screen. Don't do it!
Handle it like the professional that you profess to be. I work day to day with people that I don't
particularly like. So what? Must I slag them off because they do things I don't like. No I don't, I work with
them. The same goes when communicating on the web.
Fourth lesson: Spend money. Yes, YOUR money.
Not on a new car or house - at least not yet. Spend it on such things as professionally designed and
printed business cards. Or a professionally produced CV. Did you notice how the word "professional"
kept on rearing it's ugly head? Okay fine, you can produce the "same" thing at home on your computer.
YOU CANNOT!! And for one simple reason. You are not a professional graphics designer or printer
that's why. Spend some money and pay the experts. The same goes for software. Buy the software.
Stop copying the bloody stuff from your friends and then searching the web for a crack. You cannot run
a business using unlicensed, illegal software. And remember, the business is you. So if your software is
dodgy then maybe you are. Another thing. Keep books. Yes, every cent should be accounted for. How
else can you get yourself a line of credit if you don't keep account of the money? If your business does
take off you will need to first employ other people and then, more than likely, borrow money. Strangely
enough, when you employ someone they expect to be paid - on time. If you do not know exactly where
your money is going, how will you know if you have enough to pay them come pay day. In regards to
borrowing money, all bank managers will require a business plan before letting go of one cent. Your
books are your business plan.
Example: My wife is an ex-trainee accountant. She is now a librarian. Heather looks after all the money.
We don't have much, but every cent is accounted for. ALL my software is licensed. Some of it I paid for -
some I was given 'cos I'm nice.
Fifth lesson: Honesty and integrity.
You can makes lots of money, but in my eyes, if you lose these two then you lose life.
What Were You Doing 10 Years Ago?
(Kenny Ramage February 2003)
Me, well I was in exactly the same place as I am now - Oranjemund, Namibia. In those long lost days
though, I was a lowly design draughtsman with a year to go before I hit the big time and got the
promotion I so richly deserved. My oldest son was 12, my second 10, and my daughter still a wee mite
of 8 years. At this time of the year, we were getting all prepared to send off my oldest to boarding school
in Cape Town. He wanted to take a puppy. I said no!!
Programming - If memory serves me correctly, this was just about the time that we received our
upgrades from R12 to R13. We were still working in DOS, and I had no idea about such things as dialog
boxes, especially designing your own. Until that point, I'd been modifying the AutoCAD pull down
menus to run macros and AutoLisp routines. When R13 hit me, partial menus had come into play and
the buggers at AutoDesk had changed the whole format of the menu system. Just like that, everything
I'd written became null and void. Not that my programs were wrong and didn't work anymore. No, they
were more devious than that! I now couldn't trigger the bloody things.
This was my slow painful entry into the world of DCL. You may laugh now, but remember, in those days
we had no choice. VBA didn't exist. AutoLisp or nothing!!
To make matters worse, email and the Internet didn't exist, and being stuck in the middle of the desert I
had no access to any of the few AutoCAD magazines that were published in those days. I was stuck
with the AutoCAD reference manuals. Never, ever, ever do I want to repeat that exercise again and I
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (13 of 18) [23/03/2005 05:43:19 p.m.]
wouldn't wish it upon my worst enemy. How did I work it all out? Pure bloody trial and error that's how.
(Randall claims I still work the same way).
Bur, persist I did and maybe it did me a lot of good. It helped a lot in that I was in a working drawing
office and sort of "HAD" to make things work. (I made it work and a year later was promoted.)
Political - In Namibia, we'd gone through our independence a couple of years previously so things had
pretty well settled down. Our neighbour South Africa though - whom we rely on to a large degree - was
busy going through the birth pains of a change of government and the end of apartheid. Mandela was
about to be released, and there was a lot of concern over civil war breaking out. Thank the Lord it didn't.
People were hoarding food and fuel, rumours were flying around and everyone - white, black, pink and
green - were worried. Turmoilous times.
Music - I was "retired" from music at that time and to keep myself busy had got heavily involved with
the local amateur theatre on the directing and production side. Good fun. Pantomimes, Variety Shows,
even one or two "serious" productions. Some times I miss it. Mostly I don't. Why? Well in a band you've
got maybe 4 or 5 egos to contend with. In the theatre there's bloody hundreds - including the person
who takes the tickets. Never again - well, maybe once.
Other Hobbies - well I build two wooden ships from scratch with just the plans, and a few bits of
wood. (Honest). In fact my son Daniel said to his Mum today that when Dad dies he would like my ships.
Mmm - is that good or bad.
I also started playing Lawn Bowls - go on laugh. Great game and better than bloody golf 'cos at least
you don't lose your balls - or your temper.
(By the way - I ended up being Namibian Open Singles Champion and I've got the medals and photo's to
prove it. So there).
So, what were you doing 10 years ago? Care to share??
Insulting Humour
(Just replace the names with those of your enemies.)
(Authors Unknown)
If I offend anybody here, hey life's tough -----------------------
Kenny died in a fire and was burnt pretty badly and the morgue needed someone to identify the body. Of
course, his two best friends, Cornbread and Kinat, were sent for.
Cornbread went in and the mortician pulled back the sheet.
He said "Yup, he's burnt pretty bad. Roll him over". So the mortician rolled him over and Cornbread
looked and said "No, that ain't Kenny."
The mortician thought that was rather strange and then he brought Kinat in to identify the body. He took
a look at him and said, "Yup, he's burnt real bad, roll him over" The mortician rolled him over and Kinat
looked down and said, "No, that ain't Kenny"
The mortician asked, "How can you tell?"
Cornbread said, "Well, Kenny had two arseholes."
"What? He had two arseholes?" said the mortician.
"Yup, everyone knew he had two arseholes. Every time we went into town, folks would say........
"Here comes Kenny with them two arseholes...."
-------------
Randall walks into a bar, orders three pints of Guinness and sits in the back of the room, drinking a sip
out of each one in turn. When he finishes them, he comes back to the bar and orders three more.
The bartender asks him, "You know, a pint goes flat after I draw it; it would taste better if you bought
one at a time."
Randall replies, "Well, you see, I have two brothers. One is in Africa, and the other in Australia, and I'm
here in the US of A. When we all left home, we promised that we'd drink this way to remember the days
when we drank together."
The bartender admits that this is a nice custom, and leaves it there.
Randall becomes a regular in the bar, and always drinks the same way: He orders three pints and drinks
them in turn.
One day, he comes in and orders two pints. All the other regulars notice and fall silent.
When he comes back to the bar for the second round, the bartender says, "I don't want to intrude on
your grief, but I wanted to offer my condolences on your great loss."
Randall looks confused for a moment, then a light dawns in his eye and he laughs, "Oh, no" he says,
"everyone's fine. I've just quit drinking."
---------------
Dear Marie:
I have been engaged for almost a year. I am to be married next month.
My fiancee's mother is not only very attractive but really great and understanding. She is putting the
entire wedding together and invited me to her place to go over the invitation list because it had grown a
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (14 of 18) [23/03/2005 05:43:19 p.m.]
bit beyond what we had expected it to be.
When I got to her place we reviewed the list and trimmed it down to just under a hundred...then she
floored me. She said that in a month I would be a married man and that before that happened, she
wanted to have sex with me.
Then she just stood up and walked to her bedroom and on her way said that I knew where the front door
was if I wanted to leave. I stood there for about five minutes and finally decided that I knew exactly how
to deal with this situation. I headed straight out the front door...
There, leaning against my car was her husband, my father-in-law to be.
He was smiling. He explained that they just wanted to be sure I was a good kid and would be true to
their little girl. I shook his hand and he congratulated me on passing their little test. Marie, should I tell
my fiance what her parents did, and that I thought their "little test" was asinine and insulting to my
character?
Or should I keep the whole thing to myself including the fact that the reason I was walking out to my car
was to get a condom?
Dirty Howi
------------
Stig Madesen feeling very depressed walked into a bar and ordered a triple scotch. As the bartender
poured him the drink he remarked, "That's quite a heavy drink. Is something wrong?" After quickly
downing his drink Stig replied, "I got home and found my wife in bed with my best friend."
"Wow", exclaimed the bartender as he poured the man a second triple scotch, "No wonder you needed a
stiff drink. This one's on the house."
As Stig finished the second scotch, the bartender asked him, "So what did you do?"
"I walked over to my wife", Stig replied, "looked her straight in the eye and told her that we were
through. I told her to pack her bags and get the hell out."
"That makes sense", said the bartender, "but what about your best friend?"
"I walked over to him, looked him right in the eye and said 'Bad dog!'"
----------
Sherko walks into a bar and says "Gimme twenty shots of your best bourbon." The bartender pours the
shots, and Sherko immediately pounds them all down like a madman.
The bartender says "Man, I've never seen anybody drink like that before."
Sherko says "You'd drink like that too if you had what I have."
"What do you have?" asks the bartender.
Sherko says "Fifty cents."
Engineers Rules For When Dealing With The Drawing Office
Kindly donated by Andy Canfield (Cornbread)
Never give me work in the morning. Always wait until 4:00 and then bring it to me. The challenge
of a deadline is refreshing.
G
If it's really a rush job, run in and interrupt me every 10 minutes to inquire how it's going. That
helps. Or even better, hover behind me, advising me at every keystroke.
G
Always leave without telling anyone where you're going. It gives me a chance to be creative when
someone asks where you are.
G
If my arms are full of papers, boxes, books, or supplies, don't open the door for me. I need to
learn how to function as a paraplegic and opening doors with no arms is good training in case I
should ever be injured and lose all use of my limbs.
G
If you give me more than one job to do, don't tell me which is priority. I am psychic. G
Do your best to keep me late. I adore this office and really have nowhere to go or anything to do. I
have no life beyond work.
G
If a job I do pleases you, keep it a secret. If that gets out, it could mean a promotion. G
If you don't like my work, tell everyone. I like my name to be popular in conversations. I was born
to be whipped.
G
If you have special instructions for a job, don't write them down. In fact, save them until the job is
almost done. No use confusing me with useful information.
G
Never introduce me to the people you're with. I have no right to know anything. In the corporate
food chain, I am plankton. When you refer to them later, my shrewd deductions will identify them.
G
Be nice to me only when the job I'm doing for you could really change your life and send you
straight to Engineers' hell.
G
Tell me all your little problems. No one else has any and it's nice to know someone is less
fortunate. I especially like the story about having to pay so much taxes on the bonus check you
received for being such a good Engineer.
G
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (15 of 18) [23/03/2005 05:43:19 p.m.]
Wait until my yearly review and THEN tell me what my goals SHOULD have been. Give me a
mediocre performance rating with a cost of living increase. I'm not here for the money anyway.
G
Tell me to hurry up and finish so you can tell me about the changes you decided on at a meeting
yesterday.
G
Benchmark Test
(Kenny Ramage - November 2002)
AutoCAD VV-Lite
Recently, I received an unusual request from AutoDesk :
"Hi Kenny," it said, "Knowing that you are a man of high intellect, have a good understanding of the
AutoDesk range of products, and have never been found guilty of anything as charges were always
dropped, we would like you to benchmark and test our latest product namely - "AutoCAD VV-Lite" or, to
reveal it's true name, "AutoCAD Very, Very Lite."
Being a strong upstanding citizen (whilst standing,) I decide to give it a go.
AutoCAD VV-Lite is a brand new product aimed primarily at the person who has difficulty in
producing/reading a drawing. The major selling point of this package is that it is a state of the art,
seventh generation, ONE DIMENSIONAL Cad package. AutoDesk, after major research, identified the
need that a lot of draughtspersons/engineerpersons have in producing and or reading 2D drawings -
never mind 3D solid models or wire frames.
This was the niche that AutoDesk had been looking for!
Following are a couple of major features I picked up on whilst testing this truly unique software package
:
The first step is to select your mode of drawing. AutoCAD VV-Lite provides 3 modes - Horizontal
Mode, Vertical Mode and Angular Mode. Only one Mode at a time can be active. This exciting and
revolutionary feature removes all confusion and difficulty from having to remember what type and
orientation of entity you are drawing. A simple 3-way toggle switch, as used on the Space Shuttle,
allows you to cycle between modes.
An added bonus is that only one of the "Mode" types is displayed. This drastically reduces regen
time. e.g. If you are in "Horizontal Mode," only Horizontal entities are displayed.
G
Pull Down, Screen and Toolbar Menu's have been totally eliminated. In their place, a "stick on"
screen menu has been provided. This new menu type comes in all screen sizes and resolutions to
suit your VDU. (TV screens, drive-in screens and ice creams are not yet supported.)
G
All text is entered as normal, but appear on your screen in Lower Case Pittman's Shorthand. In
addition, all numeric characters are converted to binary code (1 and 0.)
Both these enhancements greatly help in reducing the pressure on system resources.
G
Blocks and Xref's are not inserted. Hieroglyphics are used instead. They are fully customisable. G
Every entity automatically snaps to all other entities within the drawing to avoid confusion of
which snap to use.
G
No scaling is necessary as "Not To Scale" is automatically applied to the drawing in the way of a
water mark.
G
When you draw an entity or insert a block, and if the system doesn't like what you are doing, or if
you take to long, the entity is deleted and your immediate supervisor is informed via e-mail.
G
AutoLisp is present in the form of a stripped version known as "AutoLisp VV-Lite."
The need for brackets has been eliminated.
G
These are just a few of the more powerful features present in this new, vastly improved package of
goodies from the AutoDesk stable. Keep your eye out for AutoCAD VV-Lite. It should hit the shelves
around about the last quarter of this year.
Tested on : Commodore 64 with 12 inch portable TV screen. G
Program Size (installed) : 53Kb G
Suggested retail price : $57- 36c US G
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (16 of 18) [23/03/2005 05:43:19 p.m.]
Platforms Supported : Windows, Doors and Ceiling. G
Rating : 4 peanuts and a keg. G
AutoCAD Training
(Kenny Ramage - November 2002)
I don't hate training, I detest it. How I ever ended up with the responsibility of training people on
AutoCAD I don't know. Well I do really. It's 'cos of my big mouth and having a tendency to "volunteer"
for what I think will be an interesting experience. Silly me! I'll never learn. I don't mind workshops, in fact
I quite enjoy that aspect of training. A workshop is different. At most workshops you're dealing with
people that want to be there and want to learn. Straight forward training is a totally different matter.
There you're dealing with people who have all sorts of reasons and agendas for having to attend the
course. Here's a couple of my pet hates :
The Absolute Total Executive Beginner.
They often arrive in a suit and tie and have normally been newly promoted. Many of them are on a "fast
track" career path and have decided (and there boss) that a half day "Introduction to the PC" followed
by a one day AutoCAD course is all that will be necessary to run a 20 seat CAD office. Of course, these
are the people who hold the purse strings and decide on new software. They normally leave just after
lunch to attend an important meeting.
The Quiet as a Mouse Invisible Man.
This person never says a word. He hides behind his computer screen ducking his head every time you
look at him. He never asks a questions and when asked if he understands gives a meek smile and
cleans his glasses. Half way through the session you normally discover that he got lost within the first
quarter of an hour and has just been pretending to go along with the lessons. You normally spend the
first tea break sitting with him to allow him to catch up with the rest of the class. At the end of the day
he's never finished and you end up pulling out the PC plug and pretending that there's been a major
power failure to get rid of him. He phones your every day for the next 6 months with questions
regarding the first lesson.
The Know it all Expert
This guy has normally finished the whole days syllabus before morning tea time. He doesn't listen to
word you say and does his own thing. When you do ask him a question he can't answer but shrugs it off
by telling his neighbour that he doesn't do it that way anyway. His way is quicker. He spends most of
the day rearranging his toolbars and doesn't need to learn AutoLisp or VBA because he doesn't have
time for coding. He has an extensive library of macros which he claims does the same as any program.
He normally wears a Bon Jovi World Tour 96 t-shirt and drives a VW Beetle. He claims he built his own
PC.
So, have you done any training? Have you got student types that you hate? Let me know and we'll add
them to the list.
The Atoms Family
(Kenny Ramage - October 2002)
A Never Ending Story
The rest of the Atoms Family were already having breakfast by the time Mr Atom, the Global Variable,
made his way down to the kitchen. As he was a long, he had to duck his head to get through the kitchen
door.
"Morning everyone," he setq'd.
"Morning Dad," the rest of the family chorused.
He defined himself on his chair and proceeded to tablesearch.
"I can't findfile my newspaper. Who set_tiled the table?" he setq'd.
"I did Dad," setq'd his son, "I must have errored and left it on the tblnext in the xroom. I'll getfiled it for
you now."
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (17 of 18) [23/03/2005 05:43:19 p.m.]
Mrs Atom, another Global Long, was busy entmaking breakfast.
"How should I defun your tiles dear?" she setq'd.
I'd like them well set," he menucmded, "Without a trace of lsh."
His son returned with his newspaper and xunloaded to his father who put on his vports, opened the
newspaper and proceeded to readline.
"Dad," his daughter prompted, trying to entmake conversation. "Could I go to the function tonight?"
Father was immediately alert. Slowly he turned the textpage of his newspaper.
Where is it being held?" he setq'd.
"In Paper Space," she replied.
"Well you are a double," he evaled. "How will you get there as it's quite a distance and the weather is so
bad that it's almost polar."
"We'll be transported by car," she setq'd.
"In that old Ascii your boyfriend constructed?" Dad said. "It's a wonder that it hasn't been picked up
during garbage collection. Okay, you can go, but on one condition. Do not mix with any of the local
variables. If they cause any arguments, do not stay, exit immediately."
"Can I go as well Dad?" setq'd his son.
"Getreal," his Dad replied, "You're still an integer. Anyway, I've got a list of commands and sub routines
for you."
"Oh Dad," his son wailed.
Now, now, foreach task you complete I will pay you one dollar.
First I want you to feed the strcat.
Then you can help me reverse the car out the garage, and while I'm out you can chop a log and then
progn the VCR."
To be continued, hopefully by a VBA version.
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Utter Rubbish
http://www.afralisp.com/utterrubbish.htm (18 of 18) [23/03/2005 05:43:19 p.m.]
Submit
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp's Tips 'n Tricks
Page II Page III

Entity Length
This will display the length of most entities :
;Coding starts here
(defun c:lg ( / x_object x_length)
(vl-load-com)
(setq x_object (entsel))
(setq x_object (vlax-Ename->Vla-Object (car x_object)))
(setq x_length (vlax-curve-getdistatparam x_object
(vlax-curve-getendparam x_object )))
(alert (strcat "Length = " (rtos x_length)))
(princ)
);defun
(princ)
;Coding ends here
Rtext
Have you had a good look at the Express Tools yet? Under the Text sub-menu there is a little gem of a routine called
"Rtext." Using this application you can insert Diesel expressions anywhere in your drawing. This is great for Plot
Stamps and much easier to setup and maintain than other Plot Stamp applications. Just insert it into your template
drawings and away you go.
Here's the one that I use :
Date Plotted : $(edtime, 0, Mon DD"," YYYY - H:MMam/pm)
Plotted By : $(upper, $(getvar, "loginname"))
This "stamps" the Plotted Date and Time as well as the users Login name.
Check out the "Rtext" help for more details and more uses.
AutoLisp Comments
Do you know that you can write block comments in your AutoLisp files like this :
;| This is the start of the comments.
You can carry your comments to multiple lines.
This will end your comments |;
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (1 of 6) [23/03/2005 05:43:21 p.m.]

Lwpolyline
This AutoLISP function returns the vertex of a lwpolyline (print in this case). You can use this function
in AutoLISP routines to treat lwpolylines as AutoCAD Release 13 2D polylines.
;Coding starts here
(defun c:POINTS ()
(setq a (entget (car (entsel))) b a)
(while (/= (assoc 10 b) nil)
(print)
(princ (assoc 10 b))
(princ "\n")
(setq b (subst (cons 0 "SUBSTITUTE" (assoc 10 b) b))
)
(setq b nil)
(princ)
)
;Coding ends here
Model Tab
Have you ever wanted to want to view information about the Model tab or a Layout tab; for example,
such as the current output device and paper size.
The information for layout settings is now stored in the drawing dictionary.
Following is an example of how you would access the entity information for the Model tab in AutoLISP.
;;Begining of Sample code
(setq layList (dictsearch (namedobjdict) "ACAD_LAYOUT"))
(setq Index 0)
(while (and (/= (cdr (nth Index layList)) "Model")
(/= (nth Index layList) nil))
(setq Index (+ Index 1))
(if (nth (+ Index 1) layList)
(setq modelList (entget (cdr (nth (+ Index 1) layList))))
;;End of Sample Code
This code sets the "modelList" value equal to the entity information for the Model tab as they are stored
in the drawing dictionary. After running this routine, type !modelList on the command line and press
ENTER. The contents of modelList will be displayed on the command line.
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (2 of 6) [23/03/2005 05:43:21 p.m.]
ARX Applications
When using certain AutoCAD commands in AutoLISP that are called from ARX applications (for
example, ROTATE3D and MIRROR3D), the following error message is displayed:
UNKNOWN Command
This error occurs because the ARX application was not already loaded into memory. To work around
this you must first determine what ARX application the command is from.
The following example AutoLISP routine uses the ROTATE3D command and determines if the
associated ARX application is loaded, and loads the application if it is not already loaded.
;;Start AutoLISP code
(defun c:drawsyl ( / acadObject Arxlist strArx)
(vl-load-com)
(setq acadObject (vlax-get-acad-object))
(setq Arxlist (vla-listarx acadObject))
(setq strArx (vlax-safearray->list (vlax-variant-value arxlist)))
(if (= (member '"geom3d.arx" strArx) nil)
(arxload "geom3d.arx")
);if
(command "cylinder" "0,0,0" "5" "20")
(command "rotate3d" "last" "" "x" "0,0,0" "19")
(princ)
);defun
(princ)
;;End AutoLISP code
Vertex Coordinates
You try to obtain the vertex coordinates of a 3D polyline using the following AutoLISP expression.
(entget (car (entsel)))
However, this expression only returns basic information about the 3D polyline; it does not return the
vertex coordinates, which are stored as a sub-entity of the 3D polyline.
Copy and paste the following coding into Notepad and save it as "ListVertex.lsp."
To run the routine, type ListVertex on the command line and press ENTER.
;Start of AutoLisp Coding
(defun c:ListVertex ( / ename n elist )
(setq ename (entsel))
(setq n 0)
(setq elist (entget (car ename)))
(setq ename (cdr (assoc -1 elist)))
(while (/= (cdr (assoc 0 elist)) "SEQEND")
(progn
(setq elist (entget (setq ename
(entnext ename))))
(if (assoc 10 elist)
(progn
(princ "\n ****** Vertex number ")
(princ n)
(princ "\n X = ")
(princ (cadr (assoc 10 elist)))
(princ " Y = ")
(princ (caddr (assoc 10 elist)))
(princ " Z = ")
(princ (cadddr (assoc 10 elist)))
(setq n (+ 1 n))
);progn
);if
);progn
);while
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (3 of 6) [23/03/2005 05:43:21 p.m.]
(princ)
);defun
(princ)
;End AutoLisp Coding
A list of all loaded ARX applications will be created. If the geom3d.arx file is not listed, it will be loaded,
and a 3D cylinder will be created and rotated.
Drawing Path
To get the full path, you append the DWGPREFIX system variable (which stores the path) to the
DWGNAME system variable (which stores the file name).
Use code such as the following example to retrieve and assign the values of DWGNAME and
DWGPREFIX to variables in AutoLISP :
(setq DN (getvar "DWGNAME"))
(setq DP (getvar "DWGPREFIX"))
Use the AutoLISP function (strcat), to concatenate the results and assign them to a variable, for
example :
(setq TM (strcat DP DN))
In this example, the variable TM contains the full path including the file name.
Acad.lsp
Can anybody remember the Acad.lsp file? Now that there are MNL files and Acaddoc.Lsp, Acad.Lsp
would seem to be redundant. Well not really. The Acad.Lsp file is great for ensuring that partial menu's
are loaded.
So, want to ensure your custom menu/menu's, including pulldowns, are loaded
everytime AutoCAD is opened? Copy and paste this into your Acad.Lsp file
substituting your menu name where applicable :
;;;Start Coding Here
(defun MYSTARTUP ( );;;replace this line with the following if you are using R2000
;;;(defun-q MYSTARTUP ( )
;first set the flag
(setq flag1 T)
;check for the existence of the menu
(setq loaded (menugroup "MYMENU"))
;if it's not loaded
(if (= loaded nil)
;do the following
(progn
;find the menu
(setq temp (findfile "MYMENU.MNU"))
;if you find it
(if temp
;do the following
(progn
;suppress dialogues
(setvar "FILEDIA" 0)
;load the menu
(command "menuload" "MYMENU")
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (4 of 6) [23/03/2005 05:43:21 p.m.]
;un-suppress dialogues
(setvar "FILEDIA" 1)
;load the first pulldown
(menucmd "P11=+MYMENU.POP1")
;load the second
(menucmd "P12=+MYMENU.POP2")
;tell them what you are doing
(prompt "\nLoading MyMenu Custom Utilities....\n")
);progn
;if you cannot find the menu, do this
(progn
;tell the it's missing
(alert "Cannot Locate MyMenu Menu. \n
Blame Randall Raath.")
;clear the flag
(setq flag1 nil)
);progn
);if
);progn
);if
;if the flag is set
(if flag1
;inform the user
(prompt "\nMyMenu Custom Utilities Loaded....\n")
);if
;finish clean
(princ)
);defun
;append your startup function to any other startup function
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
;;;End Coding Here
Please ensure that all "MYMENU" menu files are in your AutoCAD search path.
Listing Symbols
The following will give you a list of all entries in a symbol table. This is
great for creating a list to populate a list box in DCL.
;;;Start Coding Here
(defun tablelist (s / d r)
(while
(setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
);while
);defun
;;;End Coding Here
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (5 of 6) [23/03/2005 05:43:21 p.m.]
For example, if you would like a list of all layers in a specific drawing,
use this :
(setq all_layers (tablelist "LAYER"))
AutoLisp should return something like this :
("7" "6" "5" "4" "3" "2" "0")
To populate a list box with the key of "selections," use this :
(start_list "selections")
(mapcar 'add_list all_layers)
Command Line VBA
Did you know that you can run VBA statements from the command line?
Try this :
From AutoCAD's Command line
VBASTMT <enter> G
ThisDrawing.PurgeAll <enter> G
Page II Page III

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Tips 'n Tricks Page I
http://www.afralisp.com/tips.htm (6 of 6) [23/03/2005 05:43:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp Links
If you would like to have an AutoCAD or AutoLisp Link added
to this site, then please send details using the Contribution Form.
AutoCAD & AutoLISP
Autodesk H
Cadalog. H
Cadalyst. H
Cadence. H
The CAD Depot. H
Autolisper H
Gari's CAD Pages H
Reini Urban H
AutoLISP in Japan. H
Lintang Lives Here. H
AutoLisp Page H
@Acad+ H
BedRock H
Hurricane PowerTool H
DSXCad H
Asuni CAD H
Firehouse Designs H
Contract CADD Group H
3D Drafting H
kitoX.com H
G AutoCAD & AutoLISP
CadUser. H
The Cadshack. H
Custom Hatch Patterns H
CADesigner H
Acad Piping and Steel H
CadINFO.Net H
Cad Nauseam. H
upFront.eZine. H
EaglePoint Software. H
Australian CAD Links. H
Cadopolis H
Cad Code H
The Mech of Cad H
CADLandia (Italian) H
Gr-Acad (Portugese) H
Viking CAD H
MecaniCAD H
QnA~Tnt H
CADmechanic H
G

Tutorials/Forums
AfraLisp Tutorials. H
VBA Expresso H
CAD Encoding H
AutoCAD/AutoLisp Tutorials. H
Cadd Standards. H
AutoLisp Programming. H
Intervision H
AUGI H
AugAfrica H
AutoCAD User Groups H
G VBA/VB
Vbcad. H
VB Design. H
ActiveCAD. H
Contract CADD Group. H
AcadX.Com H
VB Free Code H
VB Code H
CopyPaste Code H
G
Links
http://www.afralisp.com/links.htm (1 of 2) [23/03/2005 05:43:23 p.m.]
Would you like to link to AfraLisp?
Here's an AfraLisp button designed by Michael deMott that you can use.
http://www.afralisp.com
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Links
http://www.afralisp.com/links.htm (2 of 2) [23/03/2005 05:43:23 p.m.]
Submit
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The AfraLisp Privacy Statement
I promise that nobody will get your email address from me.

AutoCAD Tutorial Books


http://www.afralisp.com/privacy.htm (1 of 2) [23/03/2005 05:43:24 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD Tutorial Books
http://www.afralisp.com/privacy.htm (2 of 2) [23/03/2005 05:43:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Daily Cartoon
by Ted Goff
www.newslettercartoons.com
This license grants non-exclusive electronic rights to the use of Ted Goff's daily cartoon at no charge to
Kenny Ramage for use on http://www.afralisp.com or any web page on that domain.
Ted Goff
PO Box 22679
Kansas City, MO 64113
18/08/2003
See cartoons about:
Cartoons for your Presentations and Newsletters.

Daily Cartoon
http://www.afralisp.com/cartoon-a-day.htm (1 of 2) [23/03/2005 05:43:26 p.m.]
Yesterday's cartoon go
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Daily Cartoon
http://www.afralisp.com/cartoon-a-day.htm (2 of 2) [23/03/2005 05:43:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The AfraLisp Tutorial Books
The three books below contain most of the AutoLisp/Visual Lisp/DCL Tutorials published on this
site. They are in a special PDF format in the sense that they will self destruct within one week and
reformat your hard drive unless you make a large donation to AfraLisp.
New!! You can now download all 3 books PLUS the AfraLisp Newsletters in one installation file. To
do so, just click here. ( 5227 kb)
AutoLisp Tutorials
785 kb
DCL Tutorials
1056 kb
Visual Lisp Tutorials
1566 kb
And here's something a little EXTRA (619 kb)
Now am I not nice to y'all?

AutoCAD Tutorial Books


http://www.afralisp.com/books.htm (1 of 2) [23/03/2005 05:43:28 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD Tutorial Books
http://www.afralisp.com/books.htm (2 of 2) [23/03/2005 05:43:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp Routines
Click Here for some Other AutoLisp Routines
These routines are provided as Un-Encoded Freeware
You are welcome to use them but please give me credit.
All Tutorials and Code are provided "as-is" for purposes of instruction and
utility and may be used by anyone for any purpose entirely at their own risk.
Please respect the intellectual rights of others.
All material provided here is unsupported and without warranty of any kind.
No responsibility will be taken for any direct or indirect consequences
resulting from or associated with the use of these Tutorials or Code.

Metric Steel Section Tool Palettes.


For use with AutoCAD 2004 and AutoCAD LT 2004
Note : All files must be unzipped to C:/AFRALISP/STEEL/ and all directory structures must be
maintained.
Contents :
C_PFC
Parallel Flange Channels PFC G
C_RSC
Tapered Flange Channels RSC G
E_Angle
Equal Angle Legs EA G
U_Angle
Unequal Angle Legs UA G
U_Beam
Universal Beams UB G
U_Col
Universal Columns UC G
Joist
Tapered Flange Joists RSJ G
H_Sect_C
Circular Hollow Sections CHS G
H_Sect_R
Rectangular Hollow Sections RHS G
AutoLisp Files
http://www.afralisp.com/mylisp.htm (1 of 5) [23/03/2005 05:43:29 p.m.]
Form_C
Formed Channels FC G
Form_CL
Formed Lipped Channels FLC G
Form_A
Formed Angles FA G
Form_AL
Formed Lipped Angles FLA G
DDSTEEL (265 Kb) UPDATED FOR AutoCAD 2002+
This set of routines, draws 2D Metric Structural Steel Sections.
Sections available are :-
Universal Beams
Universal Columns
Tapered Flange Channels
Parallel Flange Channels
Joists
Equal Leg Channels
Unequal Leg Channels
Circular Hollow Sections (User Input Only)
Rectangular/Square Hollow Sections (User Input Only)
All Section Properties are based on the South African Steel Construction Handbook.
DDPIPE (274 Kb) UPDATED FOR AutoCAD 2002+
This set of routines, draws 2D Metric Piping Sections.
Sections available are :-
Pipes
Flanges
Flanges in Elevation
90 Degree Elbows
45 Degree Elbows
Concentric Reducers
Eccentric Reducers
Lobster Back Bends
All Section Properties are based on British Standards.
Panzoom (4Kb)
One technique used for fast viewing of drawings is to divide the drawing into regions.
You can then quickly zoom into those regions. This application uses an AutoLisp routine
and a toolbar to automate the viewing of your drawing in four regions. The four regions
are always based on the current limits of the drawing.
1. Copy the files Panzoom.lsp, Panzoom.mnu and Panzoom.dll to any directory within the
AutoCad support path.
2. Open AutoCad.
3. Load the partial menu file Panzoom.mnu.
The toolbar is displayed after you complete the procedure.
AutoLisp Files
http://www.afralisp.com/mylisp.htm (2 of 5) [23/03/2005 05:43:29 p.m.]
The four directional arrows represent each quarter of the drawing. The AutoLisp routine
will automatically be loaded and run when you select one of the directional arrows.
Lisp Manager(16 Kb)
This application will allow you to view the first 10 lines
of any AutoLisp file. It will then give you the choice between
loading or editing the relevant AutoLisp file.
You can also download the VBA version here.
SuperCP - Batch Convert and Purge (3 Kb)
This routine will Batch Convert/Purge a directory of drawings AND all it's
sub-directories.
It will Batch Convert to:
R12, R13, R14, Template, DWF, DXF, BMP, and WMF.
It will Batch Purge :
All, Blocks, Dimstyles, Layers, Linetypes, Shapes,
Styles and Multilines.
Change to Reference Layer.(4 Kb)
Quite often you need to change a group of objects to a Reference Layer.
This allows you to distinguish between reference objects and new objects
and also allows you to plot the reference objects using a lighter pen.
Unfortunately, when you change these objects to the reference layer,
their linetype changes to the Reference Layers default linetype as well
as to the Reference Layers default colour.
This routine changes all objects to the Reference Layer but retains
their original linetype. You can also select a different colour from that
of the layers default colour if you so wish.
The routine also allows you to filter out selected layers that will not
be changed to the Reference layer.
Break Circle.(1 Kb)
This routine will break a circle and change either of the broken
sections to a different layer. I have it preset to layer 2 (Hidden Line),
but this can easily be changed to suit your needs. You will need to have
a line bisecting the circle at the two points where you want the circle to
be broken. The routine will snap to these two points and then ask you which
portion you wish to change.
Architectural Doors and Windows.(6 Kb)
This is a series of routines for parametrically drawing Doors and Windows.
It comes with a partial menu (Arch.mnu) containing an Architectural
Toolbar. Please note that both doors and windows will require a
AutoLisp Files
http://www.afralisp.com/mylisp.htm (3 of 5) [23/03/2005 05:43:29 p.m.]
reference line crossing the wall at the insertion point.
The Doors will be inserted at the hinge point and the Windows
at the centre of the window. The routines will automatically
break and trim the openings.
Item Symbol (10 Kb)
This draws an Item symbol with annotation.
USERR1 must be set to drawing scale.
Section Symbols (26 Kb)
This draws section symbols with annotation.
USERR1 must be set to drawing scale.
Level Symbols (15 Kb)
This draws vertical or horizontal level symbols with annotation.
USERR1 must be set to drawing scale.
Metric Conveyor Idlers (11 Kb)
This routine draws metric Conveyor Idlers using a
dialogue box interface.
Metric Nuts and Bolt (10 Kb)
This routine draws metric nuts and bolts using a
dialogue box interface.
Metric Bolt Holes (17 Kb)
This routine draws metric bolt holes using a dialogue
box interface.
Change Layer or Colour (2 Kb)
This routine allows you to change any objects layer
or colour by choosing from a dialogue box.
Conveyor Trajectory (3 Kb)
This routine plots the trajectory of material leaving
a conveyor Head Pulley.
Click Here for some Other AutoLisp Routines
AutoLisp Files
http://www.afralisp.com/mylisp.htm (4 of 5) [23/03/2005 05:43:29 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp Files
http://www.afralisp.com/mylisp.htm (5 of 5) [23/03/2005 05:43:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA Quick Tips.
VBA Hyperlink
Would you like to create a hyperlink to your favourite website on a form using VBA? Thought so!
Open a new project in VBA and insert a new Userform.
Add a label to the form and change the Caption to the URL of your website.
e.g. http://www.afralisp.com
Change the colour of the label to Blue - Underlined.
e.g. http://www.afralisp.com

Now add the following coding to the click event of the label :
'<- Coding Starts Here
Private Sub Label1_Click()
Dim nFile As Integer
'Write a temp file URL
nFile = FreeFile
Open "\TEMP.URL" For Output As #nFile
Print #nFile, "[InternetShortcut]"
Print #nFile, "URL=http://www.afralisp.com"
Close #nFile
'Launch the browser
Shell "rundll32.exe shdocvw.dll,OpenURL " & "\temp.url", vbNormalFocus
'Delete the temp file
Kill "\TEMP.URL"
End Sub
' Coding Ends Here
Voila, you have a hyperlink on your form.
Control Template
Ever get tired of making an exit button over and over? Do you use the same set up for multi
page (or any control) over and over? Save time, save effort. Make a control template!
1) Start with a New VBA Project in AutoCAD (or any VBA enabled application)
2) Add a UserForm to the project
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (1 of 6) [23/03/2005 05:43:31 p.m.]
3) Draw a command button on the form
4) If the properties window is not visible, click properties on the View Menu
5) Make sure that the properties for the command button are being listed in the properties
window, then change the following items:
6) Caption = Exit
7) Font = Arial (example, use your favorite font)
8) From the file menu choose close and return to AutoCAD (or whatever application you are
setting up).
9) Close AutoCad, when prompted to save the changes to Global1 say "yes" (save it under
any name, you will open it right back up).
10) Restart AutoCAD and load the dvb file saved in step 7.
11) Drag the command button you customized in step 5 onto the controls tab of the Toolbox.
Command Line VBA
Did you know that you can run VBA statements from the command line?
Try this:
From AutoCAD's Command line
1. VBASTMT <enter>
2. ThisDrawing.PurgeAll <enter>
CD Rom Drive
Let VB determine if the CD Rom drive contains media.
To quickly determine if the CD Rom drive contains media, use the Scripting Runtime library's IsReady
property for the Drive object.
For CD Rom drives, this property returns True only if the drive contains the appropriate media. To
take advantage of this handy property, add a Reference to Microsoft Scripting Runtime library
(scrrun.dll). Next, create a Drive variable based on the CD Rom drive, and test the IsReady property, as
shown below :
Dim FSO As FileSystemObject
Dim CDDrive As Drive
Set FSO = New FileSystemObject
Set CDDrive = FSO.GetDrive("E:")
If CDDrive.IsReady Then
MsgBox CDDrive.VolumeName
Else
MsgBox "Please enter a CD."
End If
Set CDDrive = Nothing
Set FSO = Nothing
Type-Declaration Characters
In addition to declaring a variable as its explicit data type,VB also lets you declare certain
data types using a single type-declaration character.
For example, instead of using :
Dim MyString As String
you can use:
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (2 of 6) [23/03/2005 05:43:31 p.m.]
Dim MyString$
Here's a complete list of the data-types and their corresponding characters :
String ($)
Integer (%)
Long (&)
Single (!)
Double (#)
Currency (@)
Of course, you should use these characters with caution, as they do reduce your code's readability.
Add Controls to a VB Control Array at Run-time.
As you probably know, a control array lets you create controls that share the same name and
events. They also use fewer resources than do the same number of controls not part of a
control array. Often, you may want to add a control, such as a button, to a control array at
runtime. To do so, you use the Load statement, which takes the following syntax :
Load object(index)
where object is the name of the control array, and index is the index number of the new control you
want to add. In order to add controls to a control array at runtime, however, you must have at least one
control already in the array, (with it's index property set-most likely to 0). VB only allows 32,767
controls in an array.
For example, suppose you have a form with a button control array named cmdBtn. On the button's
Click event, you want to add another button to the form. To illustrate, open a new project and add a
command button to the default form. In the Properties Window, enter 0 for the control's Index. When
you do, VB transforms the button into a control array. Now, add the following code to the form:
Private Sub cmdBtn_Click(Index As Integer)
Dim btn As CommandButton
Dim iIndex As Integer
iIndex = cmdBtn.Count
If iIndex <= 32767 Then
Load cmdBtn(iIndex)
Set btn = cmdBtn(iIndex)
With btn
.Top = cmdBtn(iIndex - 1).Top + 620
.Caption = "Command" & iIndex + 1
.Visible = True
End With
Set btn = Nothing
End If
End Sub
When you run the form, and click the button, the procedure adds a new button to the form.

Listbox - Deleting Items.


To delete selected items from a multiselect listbox, loop backwards through the items, then
remove those where the Selected property tests True. For example, suppose you have a list
box with item1, item2, item3, item4, item5. You've set the control's MultiSelect property to
Extended or Simple and have selected item1, item3, and item5. To remove them from the
listbox use code similar to the
following:
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (3 of 6) [23/03/2005 05:43:31 p.m.]
Private Sub cmdDeleteListItems_Click()
Dim i As Integer
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then List1.RemoveItem i
Next i
End Sub
Extending the Timer Control.
As you know, the Timer control provides a great way to schedule events in a VB project.
When you enable the control, it fires off its Timer event every n milliseconds, as determined
by the TimeInterval property. However, the TimeInterval property only accepts numbers up to
65,535, or just over one minute. As a result, you may have wondered how to use this control
for periods longer than that.
To do so, use a form, or project level, variable to keep track of how many times the Timer event fires.
Then, in the Timer event, re-enable the control if enough time hasn't passed. For example, consider the
code below that we attached to a standard form.
Option Explicit
Dim iElapsedMin As Integer
Const cMax_Min As Integer = 2
Private Sub Form_Load()
Timer1.Enabled = True
iElapsedMin = 1
End Sub
Private Sub Timer1_Timer()
lblText.Visible = (iElapsedMin = cMax_Min)
Timer1.Enabled = (iElapsedMin < cMax_Min)
iElapsedMin = iElapsedMin + 1
End Sub
Here, the iElapsedMin variable maintains the elapsed minutes. We also created a constant to hold the
maximum time we want to wait before turning the lblText control visible, (in this case 2 minutes). After
one minute, the Timer event fires and disables the Timer control. However, if the elapsed time is less
than the maximum time, then the procedure enables the control once more, starting
the process all over again.
Create an Excel object in VB.
First, assign a new reference to your VB app, "Microsoft Excel 8.0 Object Library" -
Excel8.olb
Dim objExcel As New Excel.Application
'-- Display Excel Application
objExcel.Visible = True
'-- Add new Workbook
objExcel.Workbooks.Add
'-- Set Text
objExcel.ActiveCell(1, 1) = "Row 1 Col 1"
objExcel.ActiveCell(1, 3) = "Row 1 Col 3"
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (4 of 6) [23/03/2005 05:43:31 p.m.]
'-- Release the object variable
Set objExcel = Nothing
Be sure to check out the Object Browser in VB for more properties/methods
of the Excel object.

Performing the Windows shutdown operation


Ever wondered how programs that you install automatically perform the Windows shutdown
operation? Well, it's actually a simple API call to do this. Add the following API Declares and
Constants to a BAS Module:
Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags&, ByVal
wReserved&)
Global Const EWX_FORCE = 4 'constants needed for exiting Windows
Global Const EWX_LOGOFF = 0
Global Const EWX_REBOOT = 2
Global Const EWX_SHUTDOWN = 1
Then you Shutdown/reboot/logoff windows with the following call:
lresult = ExitWindowsEx(EWX_SHUTDOWN, 0&) 'shut down the computer
Note: Replace the first parameter of the ExitWindowsEx function call with the appropriate
CONSTANT.
A new Format function.
VB 5 has the Format command that almost works the same as Print.
The difference is that Format shortens the output string length if all the format characters are
not used. To work around this I wrote a Public Function called FormatNum.
Public Function FormatNum(MyNumber As Double, FormatStr As String)
'This Function returns number formated as a string with the desired
'minimum number of characters
'MyNumber - Use CDbl(MyNumber) in the function call to prevent type
'mismatch error.
FormatNum = Format(MyNumber, FormatStr)
If Len(FormatNum) < Len(FormatStr) Then FormatNum = Space(Len(FormatStr) _
- Len(FormatNum)) & FormatNum
End Function
Use this function like this:
Print #FileNumber, FormatNum(CDbl(MyVariable), " #### ")
Highlight Text.
When you display a form, it's nice to highlight the text in a particular text box
so that the user does not have to delete the existing text before typing in his
new text string. Here's the coding :
**************************************************************************
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (5 of 6) [23/03/2005 05:43:31 p.m.]
Private Sub UserForm_Initialize()
UserForm1.TextBox1.SetFocus
'set focus to the textbox
UserForm1.TextBox1.SelStart = 0
'start at the first character
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)
'highlight the text string
End Sub
*********************************************************************
Double Click a List Box.
How do you create a double-click event for a list box?
Easy. From the Double-click event procedure of the list box, simply call the click event
procedure of the OK button :
*******************************************************************
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
CommandButton1_Click
End Sub
*******************************************************************
Private Sub CommandButton1_Click()
'Your coding goes here..............
End Sub
********************************************************************
Format Numbers.
Here's a quick tip that allows you to set the number of leading zeros, or to round to a certain
decimal point. Let's say you want to print '1.234000' in '001.234' format. To do this, use :
format(1.234000,"000.######")

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Quick Tip's
http://www.afralisp.com/vbaa/vbatips.htm (6 of 6) [23/03/2005 05:43:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Some Other Lisp Files.
The products referenced in this site are provided by parties other than AfraLisp.
AfraLisp makes no representations regarding either the products or any information about the products.
Any questions, complaints, or claims regarding the products must be directed to the appropriate Author.
File Listing.
Watson. (116 kb).
Written By : Aaron J. Strom.
Watson is an Experimental Artificial Intelligence Program.
Try This if You Dare!!

Re-number Text (2 kb)


Written by Jarvis Fosdick
Have you ever wanted to sort text items by there point values in AutoCad?
This lisp re-numbers text objects. it works well if you have some general notes, say 1 through 15, on
your drawing and you want to add a new note between 5 and 6. With this lisp you select all of the
numbers and it will reorder them starting with 1.
Format Solview Layers (4 kb)
Written by Andrew Levan
The downloadable LISP is called Format Solview Layers or FSL. For those of you using AutoCAD
R14 - 2002 to do 3D, the solview command is critical to this process. However, it creates layers "on
the fly". This creates a problem from a standardization point of view for a company, because you
cannot use pre-defined templates for standard layer colors, linetypes, etc. This program will search
for the created layers and format them to predefined or custom standards.
I welcome any comments about the program. I know it's a little rough around the edges (especially
in the interface and error handling areas) but I took it as far as I could in the time I had.
-----------------------------
Andrew Levan
Project Engineer
Marsden, Inc.
Email: alevan@marsdeninc.com
External AutoLisp Files
http://www.afralisp.com/olisp.htm (1 of 7) [23/03/2005 05:43:34 p.m.]
Web: http://www.marsdeninc.com
Visual Lisp Functions (12 kb)
Written By Michel Loftus
Below is a list of general purpose routines that I have written over the past year or so, most have
been written as part of other, more specific routines that I have written, I have included all of the
routines that are contained in the VLX file, although some may be similar to routines already
featured on this site.
These functions should all work correctly, but containing only minimal error checking
There are five Trigonometric functions :
1 (deg->rad angle): input angle in degrees as a real or int, returns angle in radians as real
eg (setq a (deg->rad 180)) = 3.14
2 (rad->deg angle): input angle in radians as a real or int, returns angle in degrees as real
eg (setq a (rad->deg (/ pi 2.0))) = 90
3 (tan angle): input angle in radians, returns tangent of angle as real
eg (setq a (tan (/ pi 4))) = 1.0
4 (asin real): input real, returns arcsine of number in radians
eg (setq a (asin 0.5)) = 0.523
5 (acos real): input real, returns arcosine of number in radians
eg (setq a (acos 0.5)) = 10.0472
G
nine general AutoCAD functions :
6 (3d->2d 3d point) returns a 2d point
eg (setq a (3d->2d '(0 0 0))) = (0 0)
7 (2d->3d 2d point level) returns a 3d point with z value equal to level or 0.0 if nil
eg (setq a (2d->3d '(0 0) 0)) = (0 0 0)
8 (stringp val): input a value, returns true if value is a string else nil
eg (stringp "Hello") = true
9 (intp atom): returns T if atom is an integer
eg (intp 1) = true
10 (realp atom): returns T if atom is a real number
eg (realp 1.0) = true
11 (c:lbo): changes layer of select object to objects colour
12 (c:ca): like the align command but copies the object(s)
13 (c:blktxt): converts text representing a number into a block
G
Nine list manipulation tools :
14 (vl-remove-last list): input list, removes last element from list
eg (setq a (vl-remove-last '(1 2 3))) = (1 2)
G
External AutoLisp Files
http://www.afralisp.com/olisp.htm (2 of 7) [23/03/2005 05:43:34 p.m.]
15 (strl_sort list): input list of strings, similar to (acad_strlsort) but sorts numbers
numerically
eg (strl_sort '("b" "a" "10" "1")) = ("1" "10" "a" "b")
16 (remove atom list): similar to (vl-remove) but only removes first occurance of atom in list
eg (remove 1 '(1 1 2 1)) = (1 2 1)
17 (nth-remove nth list): removes nth element from list
eg (nth-remove (0 '(1 2 3))) = (2 3)
18 (vl-add atom nth list): adds atom as nth element of list
eg (vl-add 2 1 '(3 3)) = (3 2 3)
19 (sublist start length list): returns a number of elements after start position from a list
eg (sublist 1 2 '(1 2 3 4 5)) = (2 3)
20 (remlist start length list): removes a number of elements after start position from a list
eg (remlist 1 2 '(1 2 3 4 5)) = (1 4 5)
21 (list->string delim list): input deliminator as string, list, converts elements of list to a
deliminated string
eg (list->string "*" '("1" "2")) = "1*2"
22 (strconv list): converts elements of list into strings
eg (strconv '(1 2.5 "h")) = ("1" "2.5" "h")
Eleven String functions :
23 (ltrim string): input string, removes any spaces from the beginning of the string
eg (ltrim " trim ") = "trim "
24 (rtrim string): input string, removes any spaces from the end of the string
eg (rtrim " trim ") = " trim"
25 (trim string): input string, removes spaces from beginning and end of string
eg (trim " trim ") = "trim"
26 (string->list string): input string, returns the string a list using spaces a delimineater
eg (string->list "Hello World") = ("Hello" "World")
27 (mid string string): input two strings, returns first string if it is found within second string
else nil
eg (mid "to" "AutoCAD") = "to"
28 (replace oldstring newstring string): replaces occurrences of oldstring in string with
newstring
eg (replace "\t" " " "Line one\tLine two") = "Line one Line two"
29 (stringtype string): returns data type of contents of the string
eg (strtype "1.5") = "REAL"
30 (right string int): returns number of characters from right of string
eg (right "AutoCAD" 3) = "CAD"
31 (left string int): returns number of characters from left of string
eg (left "Hello" 4) = "Hell"
G
External AutoLisp Files
http://www.afralisp.com/olisp.htm (3 of 7) [23/03/2005 05:43:34 p.m.]
32 (multiline string int): returns string as a list of strings, each element being no longer than
int but finishing with a full word if possible
eg (multiline "Hello New World" 3) = ("Hel" "lo " "Wor" "ld")
33 (stringcase string int): changes string case 0 or nil Upper Case, 1 Lower Case, 2 Initail
Character Upper Case rest Lower
eg (stringcase "hello world" 2) = "Hello World"

Two Selection Set Functions :


34 (sslist pickset): input selectionsel, returns list of selected entities
eg (sslist (ssget)) = (<Entity name: 40061d70> <Entity name: 40061d68>)
35 (foreachss string quoted function): iterates through entities in a selection set
eg (foreachss "i" (ssget) '(entdel i)) - this will delete all of the selected entities
G
If you have any comments or suggestions as to improvements please contact me - Michel Loftus
Bike Lisp (198 kb)
Written By : Alan - ksa@ksa-architects.com
Would you like to design your own custom bicycle?
Not only is this very clever, it's also good fun.
IDeclare.exe (28 kb).
Written By : rplaird@earthlink.net
IDECLARE searches given LISP source file(s) for undeclared local variables and declares any such
found. Any new declares made are flagged with a comment.
Global variables are recognized by having a '#' (number sign) as the first
character. The original LISP input file will be renamed with the file extension
ORG. Wildcard characters '*' and '?' can be used in the LISP input file name.
The global variable identifying character can be changed by giving the new
identifying character as the second parameter on the command line, after the
file name. A new file extension for the original LISP input to be saved under
can be given as the third command line argument.
Test DCL Lisp (1 kb).
Written By : M.P. Saju.
Testing DCL files becomes a necessity when developing a good sized lisp
application for easy input and understanding. This routine in lisp was
written for just such a necessity.
Usage is very simple... Just type "Testdcl" in Autocad text screen and press
"Enter". A file selection dialog box will open up to select the DCL file.
On entering, the DCL under test will open. This application works under
the assumption that there is an active "accept" or "cancel" button.
ISO Hole Base Tolerances. (8 kb).
Written By : Peter Best.
External AutoLisp Files
http://www.afralisp.com/olisp.htm (4 of 7) [23/03/2005 05:43:34 p.m.]
This routine will display and print ISO hole base tolerances.
Roughen (4 kb).
ROUGHEN.LSP: AutoLISP program to "roughen" a polyline.
Written By Mark Middlebrook.
Use ROUGHEN when you want to turn a polyline or line into an
irregularly zigzaggy line. For example, you can use roughened lines
to designate existing concrete surfaces that have been roughened
for better adhesion with new concrete.
This version of ROUGHEN works with AutoCAD R12 through 2000.
It roughens the newer AutoCAD R14 lwpolyline objects ("lightweight
polylines"), as well as older "heavyweight" polyline objects.
Flatten (4 kb).
FLATTEN sets the Z-coordinates of these types of objects to 0
in the World Coordinate System:
"3DFACE" "ARC" "ATTDEF" "CIRCLE" "DIMENSION"
"ELLIPSE" "HATCH" "INSERT" "LINE" "LWPOLYLINE"
"MTEXT" "POINT" "POLYLINE" "SOLID" "TEXT"
Written By Mark Middlebrook.
FLATTENing is useful in at least two situations:
You receive a DXF file created by another CAD program and discover
that all the Z coordinates contain small round-off errors. These
round-off errors can prevent you from object snapping to
intersections and make your life difficult in other ways as well.
1.
In a supposedly 2D drawing, you accidentally create one object with
a Z elevation and end up with a drawing containing objects partly
in and partly outside the Z=0 X-Y plane. As with the round-off
problem, this situation can make object snaps and other procedures
difficult.
2.
Warning: FLATTEN is not for flattening the custom objects created by
applications such as Autodesk's Architectural Desktop. ADT and similar
programs create "application-defined objects" that only the
application really knows what to do with. FLATTEN has no idea how
to handle application-defined objects, so it leaves them alone.
Hot Blocks v1.2 (120 kb).
A block manager with an INI style customization file and a dialog box, performing
collection-grouping, file path display, and slide previews as 'hot thumbnails'.
Build your own dwg block library with it, and make them ready to be inserted
easily, anytime.
Created by Lintang Darudjati :
...Lintang Lives Here...
lintangd@geocities.com
Slide Factory v1.0 (10 kb).
Automates the process of creating multiple slides and slide-libraries. It creates
External AutoLisp Files
http://www.afralisp.com/olisp.htm (5 of 7) [23/03/2005 05:43:34 p.m.]
slide files for all DWG files found in a user-selected folder. It also creates
a slide library file (SLB) if desired. Just select a folder containing one or
more DWG files, and the rest of process is in Slide Factory's hands.
Created by Lintang Darudjati :
...Lintang Lives Here...
lintangd@geocities.com
Layer Color Fixer v1.0 (17 kb).
A small program for AutoCAD users. It fixes layer colors for plotting purposes
(via a dialog box) by assigning layer colors to an INI-style config file that
matches specific pen settings.
Created by Lintang Darudjati :
...Lintang Lives Here...
lintangd@geocities.com
Visual Basic Functions Version 1.0. (5 kb).
Written by : Roger Farley, cgL Services - Cincinnati, Ohio.
Vbfunc1.Lsp contains Visual Basic type functions for the Autolisp programming language.
There are quite a few useful functions in VB, which are not available in Autolisp that would come
in rather handy, especially if you are a VB programmer working in Autolisp.
So far, this program contains only a few functions, but will be upgraded on a regular basis as the
functions are developed.
Function Catalog
1.0 LTRIM: Trims spaces from leading end of text.
e.g. (setq a (ltrim " text")) sets variable 'a' to "text".
2.0 RTRIM: Trims spaces from trailing end of text.
e.g. (setq a (rtrim "text ")) sets variable 'a' to "text".
3.0 TRIM: Trims spaces from leading and trailing end of text.
e.g. (setq a (trim " text ")) sets variable 'a' to "text".
4.0 STRICHR: Finds character in string and returns position as integer
index from left.
e.g. (setq a (strichr "text" "x")) sets variable 'a' to 3.
5.0 STRCNT: Counts number of occurrences of character in string and
returns count as integer.
e.g. (setq a (strcnt "abracadabra" "a")) sets variable 'a' to 5.
6.0 LCASE: Changes case of string to all lower case.
e.g. (setq a (lcase "TEXT" )) sets variable 'a' to "text".
7.0 UCASE: Changes case of string to all upper case.
e.g. (setq a (ucase "text" )) sets variable 'a' to "TEXT".
8.0 FCASE: Changes case of first character of string to upper case.
e.g. (setq a (fcase "text" )) sets variable 'a' to "Text".
For comments, suggestions or special requests Roger can be reached via
e-mail at rfarley@cglscvs.com.
Flanges. (10 kb).
Written By : Peter Best.
External AutoLisp Files
http://www.afralisp.com/olisp.htm (6 of 7) [23/03/2005 05:43:34 p.m.]
This programme draws Pipe Flanges using a dialogue
interface. Various flange specifications are included.
Very Good.......
Accumalative Distance. (1 kb).
Written By : Don Jacobsen.
This routine is pretty much like the Distance command with the
exception that it allows you to pick more than two points.
The routine displays the cumulative distance of all those
points picked. As you are picking the points it also displays a
running total and the distance between the last two points picked.
Metric Fasteners. (8 kb).
Written By : Peter Best.
This program will calculate standard lengths of bolts. It allows for 2 washers,
nut, and 4 pitches of thread after the nut.
Spring washer is optional. It will draw the bolt assy and individual components
as polylines after picking 2 points.
Fastener.dcl and Fastener.lst are used with this program.
Well done Peter, you're where the first on this page...

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
External AutoLisp Files
http://www.afralisp.com/olisp.htm (7 of 7) [23/03/2005 05:43:34 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The AutoCAD API's When and Why
Written by Andrew Canfield
There are three major API's with which you can extend AutoCAD. They are respectively: a C/C++ api called
objectARX, a VB/VBA api, and an AutoLisp/VisualLisp api. Every developer has their favorite but all partiality
aside people often wonder which is better, which should I use? The answer to those questions is: "It depends on
what you need to accomplish". Each API has different things, which make it better in given situations. When
deciding on which API to use there are 4 things you need to ask yourself. What language am I most comfortable
in? How much time do I have? Who is the target user and how much AutoCAD experience do they have? How
much control over AutoCAD and possibly Windows do I need to accomplish the task quickly? After I address
some of the functionality of the different API's you will see why these are relevant. I am only going to deal with
these API's as they apply internally to AutoCAD not as stand alone applications.
The objectARX API:
Out of the three API's this one has the most control over AutoCAD and Windows. You can register its commands
with AutoCAD. The user needs to know very little about AutoCAD to run your program. The drawbacks to it are it
takes longer to develop in it for most developers than VBA or Lisp, and often it is overkill especially for simple
drafting tools. To get anything done in this API you should already be very familiar with C and C++. On a personal
level this API is my favorite but that is because I do 99% of all my development in C and C++ so when I do
something for AutoCAD it's easier for me not to have to switch languages. For me it falls into the category of
"what language am I most comfortable with?". There are things within AutoCAD that this API can access that the
other API's cannot. This is the major reason for most developers who use this API. They need to do something
and it literally cannot be done using the other two API's. This is also the only API to which you can secure your
code from having others read and copy your source. If you need to develop custom objects, work with spatial
filtering, expose functionality to an application using another API, are developing third party tools for sale, or a
host of other things to which VBA and Lisp cannot access without great difficulty or at all then this is the API you
should use.
The VBA API:
If this is your first time extending the functionality of AutoCAD than this is most likely the API for you. This API is
very friendly towards new developers. The Visual Basic language reads in such a way that many times new
developers can work out simple questions by just reading the names of the functions. This API does not have as
much access to AutoCAD as the C++ or Lisp API's do however you can construct and execute Lisp commands to
give yourself access to the few things that Lisp can do which VBA cannot natively. If you are very good with VBA
you can subclass the AutoCAD command line and then there really isn't anything Lisp has access to which you
wouldn't using VBA. The major drawback to the VBA API is that it doesn't natively register your functionality with
AutoCAD. It must first be loaded as a dvb in any of the various ways you can load applications into AutoCAD and
then executed via the tools menu or by a custom button or menu item. Depending on your user base this can be a
big issue. I have worked on contracts where the drafters are all used to commands and don't want to use anything
else. In this case VBA can be a difficult sell. If the user group isn't that stuck in there ways then VBA is usually a
very easy sell. Especially after they see how fast you can create tools with it. As with Lisp this is primarily an
internal developer's tool to extend AutoCAD within your company, or if you have been contracted to work on site
to write custom tools. Out of all the API's this is the one, which can create applications the most quickly
especially applications, which require graphic dialogs. It also has the most support from AutoDesk.
The Lisp API:
When I am speaking of Lisp I am specifically referring to AutoLisp and VisualLisp I am not talking about ANSI
Common Lisp. First a quick description of AutoLisp. "AutoLisp: it combines the RAD features of iX86 with the
flexibility of COBOL". All kidding aside the major reason the Lisp API gets used is because for many developers it
satisfies the question "What language am I most comfortable in?". For many people this is where they started and
it is what they are fastest developing in. Another reason to use this API is, if the environment in which you work
has large legacy libraries of Lisp routines. Lisp is harder than VBA to learn yet still far easier than C or C++. Until
AutoCAD 2000, VBA was not very well implemented inside of AutoCAD and left a great deal to be desired. Lisp
was the primary choice for rapid in house development of macro's. Large libraries of Lisp functions exist in many
places. Re-writing these in VBA is often not cost effective in the short term. If this is the case then Lisp is the tool
for you and may God have mercy upon your soul. Kidding sort of. There are some very serious downsides to
using Lisp so if you are new to developing for AutoCAD or need to interface your functionality with any other
Windows programs or the Windows operating system you may want to look into VBA instead. On the upside if
you are interfacing with a program written for the objectARX API it is a lot easier for the objectARX developer to
AutoCAD API's
http://www.afralisp.com/vba/api.htm (1 of 4) [23/03/2005 05:44:02 p.m.]
expose their functionality to Lisp than VBA but a good developer should be able to do either so it really depends
on who is writing the C++ side of things as to which they expose their functionality to.

Here is a simple checklist for determining which API may be right for your project:
ObjectARX:
You are most comfortable working in C or C++ G
You need the absolute maximum amount of control over AutoCAD and Windows G
You need to write custom objects G
You need access to things which are not exposed to VBA or Lisp G
You require more speed than can be had using VBA or Lisp G
Your workplace requires applications be developed in C or C++ G
You need to use libraries external to AutoCAD which are only available to C or C++ G
VBA:
You are most comfortable working in VBA G
You need to use a dialogs G
You need to interface with Windows or one of the Microsoft office programs like Excel G
You are new to developing for AutoCAD or are new to developing period G
You require maximum speed of development time yet are not overly worried about application speed G
You know you are going to need a lot of help from Autodesk getting your application written G
Lisp:
The world ended and there are no other tools available G
You are most comfortable working in Lisp G
You are working with an AutoCAD version prior to 2000 G
You are working in one of those gray areas in AutoCAD where Lisp can do something that would require a
huge amount of VB knowledge to accomplish the same thing.
G
Your workplace requires it G
Your workplace may need to interface existing Lisp libraries with your tool G
You enjoy pain G
You don't need any dialogs or graphical user interaction other than the command line/screen pics in your
application
G
Parens make you happy (oh look here come the men in white coats for you now) G
Now I will provide what you all come here for really. Free code. Yes, that's right we know that's why you really
read this stuff isn't it. So since you suffered through the above I suppose I shall have to reward you with free code
so that you come back. In each of the three API's I show a way to edit the first editable attribute in a block
reference. The use of "command" will not be seen here as that is a huge pet peeve of mine. If you are using
"command" you are not programming you are scripting and they are two completely separate things.
AutoCAD API's
http://www.afralisp.com/vba/api.htm (2 of 4) [23/03/2005 05:44:02 p.m.]
ObjectARX:
void chngAtt()
{
ads_name entres;
ads_point ptres;
AcDbObjectId _Id, _attId;
AcDbObjectIterator *pIttr = NULL;
if(acedEntSel("Select a Block Reference", entres, ptres) != RTNORM )
{
//Selection failed
return;
}
acdbGetObjectId(_Id, entres);
AcDbObjectPointer pRef(_Id,AcDb::kForRead);
if(pRef.openStatus()!=Acad::eOk)
{
//Open failed
return;
}
pIttr = pRef->attributeIterator();
while(!pIttr->done())
{
_attId = pIttr->objectId();
AcDbObjectPointer pAtt(_attId,AcDb::kForWrite);
if(pAtt.openStatus()==Acad::eOk)
{
pAtt->setTextString("We changed this");
break;
}
pIttr->step();
}
delete pIttr;
}

VBA:
Option Explicit
Sub chngAtt()
Dim objEnt As AcadObject
Dim objRef As AcadBlockReference
Dim varAtts As Variant
Dim objAtt As AcadAttributeReference
Dim emptyPt As Variant
ThisDrawing.Utility.GetEntity objEnt, emptyPt, "Select Block: "
If objEnt.ObjectName = "AcDbBlockReference" Then
Set objRef = objEnt
If objRef.HasAttributes Then
varAtts = objRef.GetAttributes
Set objAtt = varAtts(0)
objAtt.TextString = "We changed this"
End If
End If
End Sub

AutoCAD API's
http://www.afralisp.com/vba/api.htm (3 of 4) [23/03/2005 05:44:02 p.m.]
Lisp:
(defun C:chngAtt ()
(setq Mainent (entsel))
(setq entList (entget (car Mainent)))
(setq entAtt (entget (entnext (cdr (assoc -1 entList)))))
(setq entNewAttVal
(subst (cons 1 "We changed this") (assoc 1 entAtt) entAtt)
)
(entmod entNewAttVal)
(entupd (car Mainent))
(princ)
)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD API's
http://www.afralisp.com/vba/api.htm (4 of 4) [23/03/2005 05:44:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
An Introduction to VB and VBA.
Visual Basic is a descendant of the BASIC programming language first developed in the
1960's. BASIC (which is short for 'Beginner's All-purpose Symbolic Instruction Code') is
probably well known to most computer programmers.
Microsoft Visual Basic allowed programmers to create stand-alone Windows
applications which previously required the use of complex C programming
languages. Visual Basic for Applications is a subset of Visual Basic, designed
specifically for certain applications such as MS Word, Excel, Access, etc.
With the release of AutoCAD R14, AutoCAD has included VBA as part of the
AutoCAD package. VBA for AutoCAD includes most of the functions and controls
available in the stand-alone version of Visual Basic alongwith specific functions and
controls specifically designed for AutoCAD.
If Visual Basic is the first experience you, as a programmer, have had with 'event driven'
programming, then read on and enter the world of Visual Basic..........
Event Driven Applications.
An event is an action recognized by a form or control. Event driven applications execute
Visual Basic code in response to an event. Each form and control in VBA has a
predefined set of events. If one of these events occurs, VBA invokes the code in the
associated event procedure.
Although objects in VBA automatically recognize a predefined set of events, you determine if and
how they respond to a particular event. When you want a control to respond to an event, you write
code called an event procedure for that event.
Many objects recognize the same event, although different objects can execute
different event procedures when the event occurs. For example, if a user clicks
a userform, the Userform_Click event procedure executes; if a user clicks a command button
named CommandButton1, the CommandButton1_Click event procedure executes.
Here's what happens in a typical event driven application:

The application starts and a form or control receives an event. The event can be caused by the
user (for example a keystroke), or by the system (for example a timer), or indirectly by your
code (for example, a Load event procedure when your code loads a form.
1.
If there is an event procedure corresponding to that event, it executes. 2.
The application waits for the next event. 3.
Note : Many events occur in conjunction with other events. For example, when the DblClick event
occurs, the MouseDown, MouseUp and Click events also occur.
Event Driven vs Traditional Programming.
In a traditional or 'procedural' application, the application itself rather than
an event controls the portions of code that execute. Execution starts with the first line of
executable code and follows a predefined path through the application, calling
procedures as needed.
An Introduction to VB and VBA
http://www.afralisp.com/vbaa/vbatut2.htm (1 of 3) [23/03/2005 05:44:03 p.m.]
In event driven programmes, a user action or system event executes an event procedure.
Thus, the order in which your code executes depends on which events occur, which in turn depends
on what the user does. This is the essence of graphical user interfaces and event driven
programming: The user is in charge, and your code responds.
Because you can't predict what the user will do, your code must make a few assumptions about 'the
state of the world' when it executes. When you must make assumptions (for example, that a text box
has text in it before a command button is pressed), you should try to structure your application so
those assumptions are always valid (for example, disabling the command button and enabling it
only in the Change event procedure for the text box).
Your code might trigger additional events as it performs additional operations. For example,
loading a Userform causes the Userforms Load event to occur, and changing the Text property of a
text box causes the text box's Change event to occur.
Objects.
Each object in VBA is defined by a 'class'. To understand the relationship between an
object and it's class, think of cookie cutters and cookies. The cookie cutter is the class. It
defines the characteristics of each cookie - for instance, size and shape. The class is
used to create objects. The objects are the cookies.
Two examples of the relationship between classes and objects in VBA may make this clearer.
The controls on the Toolbox in VBA represent classes. The object known as a control doesn't
exist until you draw it on a Userform. When you create a control, you're creating a copy or
'instance' of the control class. That instance of the class is the object you refer to in your
application.
G
The Userform you work with at design time is a class. At runtime, VBA creates an instance of
the Userforms class.
G
All objects are created as identical copies of their class. Once they exist as
individual objects, their properties can be changed. For example, if you draw three command
buttons on a Userform, each command button object is an instance of the CommandButton class.
Each object shares a common set of characteristics and capabilities (properties, methods and
events), defined by the class. However, each has it's own name, can be separately enabled and
disabled, can be placed in a different location on the form, and so on.
Working with Objects.
Visual Basic objects support properties, methods, and events. In Visual Basic,
an object's data (settings or attributes) are called 'properties', while the
various procedures that can operate on an object are called it's 'methods'.
An 'event' is an action recognized by an object, such as clicking a mouse or
pressing a key, and you can write code to respond to that event.
You can change an object's characteristics by changing it's properties.
Consider a radio: One property of a radio is its volume. In Visual Basic,
you might say that a radio has a 'Volume' property that you can adjust by
changing its value. Assume you can set the volume of a radio from 0 to 10.
If you could control a radio with Visual Basic, you might write code in a
procedure that changes the value of the 'Volume' property from 3 to 5 to
make it play louder :
Radio.Volume = 5
In addition to properties, objects have methods. Methods are part of objects
just as properties are. Generally, methods are actions you want to perform,
An Introduction to VB and VBA
http://www.afralisp.com/vbaa/vbatut2.htm (2 of 3) [23/03/2005 05:44:03 p.m.]
while properties are the attributes you set or retrieve. For example, you dial
a telephone to make a call. You might say that telephones have a 'Dial' method,
and you could use this syntax to dial a seven digit number 3334444:
Phone.Dial 3334444
Objects also have events. Events are triggered when some aspect of the object is changed. For
example, a radio might have a 'VolumeChange' event. A telephone might have a 'Ring' event.
As it would be an impossibility for me to try and explain to you all the characteristics of VB, I
strongly urge you to invest in a good VB reference book. There are many on the market and it
would make your life a whole lot easier.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
An Introduction to VB and VBA
http://www.afralisp.com/vbaa/vbatut2.htm (3 of 3) [23/03/2005 05:44:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III. Page IV.
VBA Primer.
I have had numerous requests from people asking for a tutorial on Visual Basic
for Applications. Well here it is. This tutorial will take you from the very basics
of opening the Visual Basic Editor to building a simple application.
I must stress though, that Visual Basic is a language with thousands of built in functions
and numerous custom modules and controls available. I strongly recommend that you
invest in a good Visual Basic book as I cannot possibly take you through the whole VB
language. Also, remember that AutoCAD Visual Basic for Applications is a subset of the
Visual Basic language with it's own build in functions and controls.
Anyway, enough warbling for now, let's get started with our application.
This application called, Change Layer, will allow you to change the layer of
any entity within your drawing. It will display a dialogue box with a list box
listing all of the available layers in your drawing. After you have selected
a layer to change to, it will prompt you to select the entities you would like
to change to that layer and then change them. Sound's good hey! Here we go...
Fire up AutoCAD and choose 'TOOLS-MACRO-VISUAL BASIC EDITOR' from the pull-down
menu.
The Visual Basic Editor should appear and will look like this:
Don't worry about the various windows that appear in the editor. We will go through each one as
we progress through this tutorial.
VBA Primer
http://www.afralisp.com/vbaa/vbatutor.htm (1 of 4) [23/03/2005 05:44:05 p.m.]
Now choose 'INSERT-USERFORM' from the pull down menu bar.
The following should appear :
This is the form that we will use to create our dialogue box from.
Now look in the top left hand corner of the screen. There you will find the Project dialogue. This
basically lists all the Forms, Modules, etc. that are part of your VBA project.
As you can see, because we haven't named our project yet, AutoCAD gives our
project the name Project.dvb. Before we go any further let's save our project
and give it a name. Select 'FILE-SAVE' from the menu bar and name the project
'Chlayer.dvb'. Also you will be able to see the form that we created listed
under Forms and given the default name of UserForm1. All forms, modules and
controls that you insert into your project will be given a default name. (You
can, if you wish change it later but, in this exercise we will only work with
the default names.)
Now, let's have a look at the Properties dialogue box. This you will find in
the lower left-hand corner of the Editor and should look like this:
VBA Primer
http://www.afralisp.com/vbaa/vbatutor.htm (2 of 4) [23/03/2005 05:44:05 p.m.]
This dialogue lists all the properties that an object has. The dialogue should
show all the properties available for the form, UserForm1 that you inserted.
If it doesn't, click on the form to select it.
The first property listed is (Name) - UserForm1. This is the property that
you would change if you wanted to change the name of the form. Please remember, that this is the
name that you use to programatically refer to this particular form. If you change this name once
you have written code referring to this form, you will have to manually change all the instances of
that name in your code.
Let's change the caption of the form. Select the caption property and change it
from 'UserForm1' to 'Change Layer'. Your form should now look like this :
VBA Primer
http://www.afralisp.com/vbaa/vbatutor.htm (3 of 4) [23/03/2005 05:44:05 p.m.]
Notice how the caption has changed. On the next page we will have a look at
adding controls to our form. See you there.........
Home. Page II. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Primer
http://www.afralisp.com/vbaa/vbatutor.htm (4 of 4) [23/03/2005 05:44:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III. Page IV.
VBA Primer - Page II.
When you insert the form you might have noticed that another dialogue popped up.
This is the Control Dialogue ToolBox. It look's like this :
To add a control to your form, select the desired control and click on the form
in the position that you would like the control to be. Select the CommandButton control (2nd row,
far right) and place it on your form.
Your form should now look like this :
Now, change the properties of the command button to the following :
(Name) CommandButton1
Caption OK
Default True
Font Arial - Bold - Size 8
Accelerator O
VBA Primer II
http://www.afralisp.com/vbaa/vbatutor2.htm (1 of 3) [23/03/2005 05:44:07 p.m.]
Your button should now look like this :
The Caption property is, of course, the text that appears within the button.
The Default property means that if Enter is selected the event procedure asSigned to this control is
triggered.
The Accelerator property is the letter of the caption that needs to be selected,
along with the Ctrl key, to select this control.
Now add the following controls to your form and changed the properties to the
values listed below :
Command Button
(Name) CommandButton2
Cancel True
Caption Cancel
Accelerator C
Font Arial - Bold - Size 8
The Cancel property means that if Esc is selected the event procedure assigned to this control is
triggered.
Label
(Name) Label1
Caption Choose Layer:
Font Arial - Bold - Size 8
List Box
(Name) Listbox1
Font Arial - Bold - Size 8
BackColor Yellow
You can move a control by simply dragging and dropping it. To re-size it, just
grip the re-size boxes at the edges and corners of the control.
Now move and re-size your controls and the form until the dialogue box looks
similar to this :
VBA Primer II
http://www.afralisp.com/vbaa/vbatutor2.htm (2 of 3) [23/03/2005 05:44:07 p.m.]
Note: Do you see how easy it is to create dialogue boxes in VBA compared
to DCL. "What a pleasure!!!"
Now that we have got our basic dialogue box we need to make it do something.
Page III, look out, here we come...........
Page I. Home. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Primer II
http://www.afralisp.com/vbaa/vbatutor2.htm (3 of 3) [23/03/2005 05:44:07 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home. Page IV.
VBA Primer - Page III.
O.K. we now have our basic dialogue box and would like it to do something.
Firstly, we need to code the cancel button so that we can exit the application
while we are still testing. We also need to create a Module so that we can run
the application from within AutoCAD.
Let's create the Module first.
Select INSERT - MODULE.
A new window will open looking like this:
This is the code window were you will be writing all of your Visual Basic Code.
If you look at the Project window you will find that a new Module has been created and has been
given the default name of Module1.
Now enter the following code into the module :
sub chlayer ()
'name of function
UserForm1.Show
'display the dialogue box
'UserForm1
End Sub
Thw code window should look like this :
VBA Tutor III
http://www.afralisp.com/vbaa/vbatutor3.htm (1 of 3) [23/03/2005 05:44:09 p.m.]
As you have probably worked out for yourself, any line starting with a ' is a comment. (The same as
the ; in AutoLISP).
Visual Basic also colour codes the coding but I am not going to get into that
at this time.
Next, double click on the Cancel button on UserForm1. The code window will open again,
displaying the Click Event procedure for that control.
Type in the following code :
Private Sub CommandButton2_Click()
End
'end the programme

End Sub
The code window should look like this :
This sub-routine simply ends the programme if the Cancel button is selected.
Now, let's test our dialogue box.
(This would be a good time to save your project......)
Return to AutoCAD and select TOOLS - MACROS - RUN MACRO from the menu bar.
The following dialogue should appear:
VBA Tutor III
http://www.afralisp.com/vbaa/vbatutor3.htm (2 of 3) [23/03/2005 05:44:09 p.m.]
Choose 'Module1' from the list box and 'chlayer' from the drop down list box.
Now select 'Run'. Your dialogue should appear in all it's glory.
(Thunderous applause from the audience.)
Once you have finished admiring your handywork select 'Cancel'.
We still have a couple of problems though. Firstly, there is nothing in the
list box and the OK button doesn't work.
On the next page we'll show you how to populate the list box with all the
layer names in your drawing and then we'll write the main event procedure for
the O.K. button.
While you are waiting for the next page you might as well grab yourself a beer.
I've got one.......
Page I. Page II. Home. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Tutor III
http://www.afralisp.com/vbaa/vbatutor3.htm (3 of 3) [23/03/2005 05:44:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Page III. Home.
VBA Primer - Page IV.
To populate our list box we need to first find a list of all the layers in our drawing. Double
click on the form. (The form, not a control.)
The code window will open. From the Event Procedure drop-down list box in the right
hand corner of the code window choose 'Initiliaze'.
Now add the following code to this event procedure:
Private Sub UserForm_Initialize()
Dim AllLayers As Object
Dim Layer As Object
'declare local variables
Set AllLayers = ThisDrawing.Layers
'get the layers from the layers collection
For Each Layer In AllLayers
'for every layer listed
ListBox1.AddItem Layer.Name
'add the layer name to the list box

Next
'carry on looping

End Sub
A list of all the layers in any drawing are kept in the Layers collection.
This coding is telling Visual Basic that when the form is initialized, get all of the layer names from
the layers collection, and add them to the list box.
Run the program again. Your dialogue should now look like this :
Now let's look at the coding for the OK button event procedure.
VBA Tutor IV
http://www.afralisp.com/vbaa/vbatutor4.htm (1 of 3) [23/03/2005 05:44:10 p.m.]
Double click the OK button and enter the following code under the click event procedure of the
button :
Private Sub CommandButton1_Click()
Dim Entity As Object
'declare variable as local
Me.Hide
'hide the dialogue box
Set ss = ThisDrawing.SelectionSets.Add("NEWSS")
'create a selection set reference
ss.SelectOnScreen
'select the objects to change
For Each Entity In ss
'for every entity in the selection set
Entity.Layer = ListBox1.Text
'change the layer to the layer name
'selected in the list box

Next
'process the next entity
End
'end the programme
End Sub
Now run the programme again. Select a layer from the list box and then select
some objects on your drawing. They should change to your selected layer.
Well I hope this has given you a bit more of an idea what VBA is all about.
The application is far from perfect. There is no error checking and the items
in the list box have not been sorted. Maybe that is something that you could
work on now that you have had a taste of VBA. Have a look at the other sample
applications in this section. They cover large areas of VBA and all come complete with source
coding. All the best and good luck with VBA......
If you would like to download this VBA Primer, stand on your head, say 'Yes Please' in
French, place your mouse here and Click. Enjoy.......
Page I. Page II. Page III. Home.

VBA Tutor IV
http://www.afralisp.com/vbaa/vbatutor4.htm (2 of 3) [23/03/2005 05:44:10 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Tutor IV
http://www.afralisp.com/vbaa/vbatutor4.htm (3 of 3) [23/03/2005 05:44:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Userforms.
If you have programmed with AutoLisp and the Dialogue Control Language (DCL), you will
be familiar with designing dialogue boxes. Compared to DCL though, designing dialogue
boxes in VBA is a breeze. The basis of all dialogue boxes in VBA is the Userform. This
Tutorial will show you how to display and manipulate Userforms.
A Userform is a container that holds all the controls such as labels, textboxes,
pictures, etc. that make up part of your applications interface.
A Userform has it's own Properties, Methods and Events. Let's have a look at some of them :
Displaying a Userform
The syntax for displaying a Userform is as follows :
UserFormName.Show
So, to display a Userform named Userform1, you would use the following code:
Userform1.Show
If you want to, you can preload the Userform into memory without actually displaying it. This can be
useful as it can sometimes take a few seconds for a complex Userform to appear. The ability to
preload the Userform allows you to decide when you would like this operation to take place. To
preload a Userform you would use the following code :
Load Userform1
Hiding/Unloading a Userform
To temporarily hide a Userform, you would use the Hide method. This is a very good example of how
dialogue boxes in VBA are so much simpler than in AutoLisp. To hide a Userform you would use the
following code:
Userform1.Hide
To Unload a Userform from memory use the following code :
Unload Userform1
You could also use the 'Me' keyword :
Unload Me
Useform Events
Userforms support many predefined events. Among the most commonly used events are Initiliaze,
Click and Terminate events.
Note A VBA module that contains an event procedure can be called a module
'behind' the Userform. A module that contains event procedures is not visible in the Modules
collection of the Projects window of the VBA Editor. You must double-click the body of the Userform
to view the Userform Code Module.
Let's have a look at some Userform Events. Start your VBA Editor and insert a
Userform into a new Project. Double-Click the Userform and type in the following code:
Private Sub UserForm_Click()
Me.Height = Int(Rnd * 500)
Me.Width = Int(Rnd * 750)

UserForms
http://www.afralisp.com/vbaa/vbatut1.htm (1 of 3) [23/03/2005 05:44:12 p.m.]
End Sub
Private Sub UserForm_Initialize()
Me.Caption = "Userform Events"
Me.BackColor = RGB(10, 25, 100)

End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
msg = "Now Unloading " & Me.Caption
MsgBox prompt:=msg, Title:="QueryClose Event"

End Sub
Private Sub UserForm_Resize()
msg = "Width: " & Me.Width & Chr(10) & "Height : " & Me.Height
MsgBox prompt:=msg, Title:="Resizing Event"

End Sub
Private Sub UserForm_Terminate()
msg = "Now Unloading " & Me.Caption
MsgBox prompt:=msg, Title:="Terminate Event"

End Sub
Now run the Userform.
This is what happens when you run the project:
Firstly, The Intialize event procedure changes the Caption property to "Userform Events" and the
Backcolor property to dark Blue.
When you click the Userform the Click Event procedure is initiated and the Userform is re-sized.
Also, because you created a resize event procedure, you receive 2 message boxes. The resize event
occurs twice because your code behind the click event changed both the Width and Height properties
of the Userform.
When you close the Userform, the QueryClose event procedure is triggered. This displays a message
box with the caption you gave the Userform in the code for the Initialize event. The QueryClose event
is useful when you want to perform a certain set of actions when the Userform is closed by the user.
The Terminate Event then triggers a message box which states that the Caption of the Userform is
Userform1. The Terminate Event occurs after the Userform is removed from memory and the
Caption of the Userform returns to it's original state.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
UserForms
http://www.afralisp.com/vbaa/vbatut1.htm (2 of 3) [23/03/2005 05:44:12 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
UserForms
http://www.afralisp.com/vbaa/vbatut1.htm (3 of 3) [23/03/2005 05:44:12 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Lisp to VBA.
To demonstrate the use of VBA in AutoCAD, I've taken a few of the more common
AutoLisp routines, and converted them to VBA Applications.
This will hopefully help the AutoLisper who is trying to migrate from AutoLisp To VBA.
These routines should be familiar to most AutoLispers and by having a good
understanding of how the routine is written in AutoLisp, you should find it very easy to
follow and undestand the VBA logic and coding.
Note:
I have presumed that you know how to load and run a VBA Application, work with User Forms
and controls, and know how to set the basic Properties of UserForms and Controls. The only
Properties that I have listed are those that are out of the norm.
I have NOT included any error checking for the sake of readability.
Lisp to VBA Applications.
Slotted Holes. - Draws Slotted Holes. G
Moffset. - Multiple Offset. G
Import/Export Data. - Import and Export Layer Names. G
Filter Layers. - Filtering User Defined Layers. G
Edit Text. - Edit Line Text. G
Change Text. - Change Text Height, Layer, Style or Colour. G

Lisp to VBA.
http://www.afralisp.com/vbaa/vbatut3.htm (1 of 2) [23/03/2005 05:44:12 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Lisp to VBA.
http://www.afralisp.com/vbaa/vbatut3.htm (2 of 2) [23/03/2005 05:44:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Slotted Holes.
This application will draw slotted holes as per the above diagram.
It begins by asking the user for an insertion point, the slot length, and then the slot diameter using
the VBA Get functions.
It then uses the PolarPoint function to calculate the other points required to draw the slot. Then,
using the AddLine and AddArc command, it draws the
slotted hole.
Note how we declare 'pi' as a Constant and construct a function to convert Degrees to Radians.
Open a new module and add this coding to it :
Const pi = 3.14159
'create Pi as a constant
'This function converts Degrees to Radians Function dtr(a As Double) As Double dtr = (a / 180) * pi
End Function
Sub Slot() 'define the function Dim InsertPoint As Variant Dim SlotLength As Double Dim SlotDia
As Double Dim Prompt1 As String Dim Prompt2 As String Dim Prompt3 As String Dim pt1 As
Variant Dim pt2 As Variant Dim pt3 As Variant Dim pt4 As Variant Dim pt5 As Variant Dim pt6
As Variant Dim pt7 As Variant Dim LineObj As AcadLine Dim ArcObj As AcadArc 'declare all
variables Prompt1 = vbCrLf & "Insertion Point : " 'store the prompt InsertPoint =
ThisDrawing.Utility.GetPoint(, Prompt1) 'get the insertion point Prompt2 = vbCrLf & "Slot
Length : " 'store the prompt SlotLength = ThisDrawing.Utility.GetReal(Prompt2) 'get the slot
length Prompt3 = vbCrLf & "Slot Diameter : " 'store the prompt SlotDia =
ThisDrawing.Utility.GetReal(Prompt3) 'get the slot diameter pt1 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(270#), SlotDia / 2) pt2 = ThisDrawing.Utility. _ PolarPoint(pt1,
dtr(180#), SlotLength / 2) pt3 = ThisDrawing.Utility. _ PolarPoint(pt2, dtr(90#), SlotDia) pt4 =
ThisDrawing.Utility. _ PolarPoint(pt3, dtr(0#), SlotLength) pt5 = ThisDrawing.Utility. _
PolarPoint(pt4, dtr(270#), SlotDia) pt6 = ThisDrawing.Utility. _ PolarPoint(InsertPoint, dtr(180#),
SlotLength / 2) pt7 = ThisDrawing.Utility. _ PolarPoint(InsertPoint, dtr(0#), SlotLength / 2)
'calculate all the points using the PolarPoint Function Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt1, pt2) Set LineObj = ThisDrawing.ModelSpace. _ AddLine(pt3, pt4) Set LineObj =
ThisDrawing.ModelSpace. _ AddLine(pt5, pt1) Set ArcObj = ThisDrawing.ModelSpace. _
AddArc(pt6, SlotDia / 2, dtr(90), dtr(270)) Set ArcObj = ThisDrawing.ModelSpace. _ AddArc(pt7,
SlotDia / 2, dtr(270), dtr(90)) 'Draw the Slotted Hole End Sub

Now, let's add a dialogue box to our application to streamline the user input :
Slotted Holes
http://www.afralisp.com/vbaa/vbatut31.htm (1 of 4) [23/03/2005 05:44:14 p.m.]
ScrollBar Properties :

Max = 100 G
Min = 1 G
Value = 50 G
SmallChange = 1 G
LargeChange = 5 G
TextBox1 :

Value = 50 G
TextBox1 :

Value = 20 G

Open a new module and add this coding to it :


Const pi = 3.14159
'create Pi as a constant
'This function converts Degrees to Radians Function dtr(a As Double) As Double dtr = (a / 180) * pi
End Function
Sub Slot1() 'define the function UserForm1.Show 'display the dialogue box End Sub

Now, under the Click Event for CommandButton1, add this coding :
Private Sub CommandButton1_Click()
Dim InsertPoint As Variant
Dim SlotLength As Double
Dim SlotDia As Double
Dim Prompt1 As String
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt3 As Variant
Dim pt4 As Variant
Dim pt5 As Variant
Dim pt6 As Variant
Dim pt7 As Variant
Dim LineObj As AcadLine
Dim ArcObj As AcadArc
'declare all variables
Slotted Holes
http://www.afralisp.com/vbaa/vbatut31.htm (2 of 4) [23/03/2005 05:44:14 p.m.]

SlotLength = TextBox1.Value
'retrieve the Slot Length

SlotDia = TextBox2.Value
'retrieve the Slot Diameter

UserForm1.Hide
'hide the dialogue box

Prompt1 = vbCrLf & "Insertion Point : "
'store the prompt

InsertPoint = ThisDrawing.Utility.GetPoint(, Prompt1)
'get the insertion point

pt1 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(270#), SlotDia / 2)
pt2 = ThisDrawing.Utility. _
PolarPoint(pt1, dtr(180#), SlotLength / 2)
pt3 = ThisDrawing.Utility. _
PolarPoint(pt2, dtr(90#), SlotDia)
pt4 = ThisDrawing.Utility. _
PolarPoint(pt3, dtr(0#), SlotLength)
pt5 = ThisDrawing.Utility. _
PolarPoint(pt4, dtr(270#), SlotDia)
pt6 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(180#), SlotLength / 2)
pt7 = ThisDrawing.Utility. _
PolarPoint(InsertPoint, dtr(0#), SlotLength / 2)
'calculate all the points using the PolarPoint Function

Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt1, pt2)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt3, pt4)
Set LineObj = ThisDrawing.ModelSpace. _
AddLine(pt5, pt1)
Set ArcObj = ThisDrawing.ModelSpace. _
AddArc(pt6, SlotDia / 2, dtr(90), dtr(270))
Set ArcObj = ThisDrawing.ModelSpace. _
AddArc(pt7, SlotDia / 2, dtr(270), dtr(90))
'Draw the Slotted Hole
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub ScrollBar1_Change()
TextBox1.Value = ScrollBar1.Value
'set the value of the text box
'to the value of the scrollbar

End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Slotted Holes
http://www.afralisp.com/vbaa/vbatut31.htm (3 of 4) [23/03/2005 05:44:14 p.m.]
ScrollBar1.Value = TextBox1.Value
'set the value of the scrollbar
'to the value of the text box

End Sub
If you would like to download the source code for this Application/s, Then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Slotted Holes
http://www.afralisp.com/vbaa/vbatut31.htm (4 of 4) [23/03/2005 05:44:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Muliple Offset.
This application will offset an entity multiple times. Just select the entity, enter an offset
distance, (enter a negative number if you want to offset the other way), and then enter the
number of times you would like to offset it.
Enter this coding into a new module :
Option Explicit
Public Sub Moffset()
Dim objPicked As Object
Dim BasePnt As AcadPoint
Dim returnDist As Double
Dim nuOffsets As Integer
Dim i As Integer
Dim accumDist As Double
Dim offsetObj As Variant
'declare variables
ThisDrawing.Utility.GetEntity objPicked, BasePnt, "Select A Line"
'select the object
returnDist = ThisDrawing.Utility.GetDistance(, "Enter distance: ")
'get the distance to offset
nuOffsets = ThisDrawing.Utility.GetInteger("Number of Offsets : ")
'get the number of offsets
offsetObj = objPicked.Offset(returnDist)
'offset the object
For i = 1 To nuOffsets
'set up the loop
accumDist = returnDist + accumDist
'calculate the new offset distance
offsetObj = objPicked.Offset(accumDist)
'multiple offset the object
Next i
'loop
End Sub
Now run the macro 'Moffset'. Works fine Hey!. Now run it again but this time select an empty
space on the screen when prompted to select an object.
Oh, Crikey, an error??? Re-run it once more but this time select an object.
Now press the Escape key. Oh No, another error!!!
Multiple Offset
http://www.afralisp.com/vbaa/vbatut32.htm (1 of 2) [23/03/2005 05:44:15 p.m.]
I think this application is screaming out for some error control.
Start a new application and enter this coding. I've colour coded the coding that
has been added :
Option Explicit
Public Const VK_ESCAPE = &H1B
Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Function checkkey(lngKey As Long) As Boolean If GetAsyncKeyState(lngKey) Then checkkey =
True Else checkkey = False End If End Function
Public Sub Moffset1() Dim objPicked As Object Dim BasePnt As AcadPoint Dim returnDist As
Double Dim nuOffsets As Integer Dim i As Integer Dim accumDist As Double Dim offsetObj As
Variant 'declare variables Start: On Error GoTo errControl 'if there is an error
ThisDrawing.Utility.GetEntity objPicked, BasePnt, "Select A Line" 'select the object returnDist =
ThisDrawing.Utility.GetDistance(, "Enter distance: ") 'get the distance to offset nuOffsets =
ThisDrawing.Utility.GetInteger("Number of Offsets : ") 'get the number of offsets offsetObj =
objPicked.Offset(returnDist) 'offset the object For i = 1 To nuOffsets 'set up the loop accumDist =
returnDist + accumDist 'calculate the new offset distance offsetObj = objPicked.Offset(accumDist)
'multiple offset the object Next i 'loop Exit Sub 'exit the sub routine errControl: 'define the error
control If Err.Description = "Method 'GetEntity' of object _ 'IAcadUtility' failed" Then 'if the
error matches these.. If checkkey(VK_ESCAPE) = True Then 'if the escape key is selected End 'end
Else 'or else Resume 'repeat "Select Object" End If Else MsgBox Err.Description 'it must be
another type of error End If End Sub

Now load and run Macro 'Moffset1'. Much better, Hey?


Thanks to Randall Raath for the error checking in this application.
If you would like to download the source code for this Application/s, Then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Multiple Offset
http://www.afralisp.com/vbaa/vbatut32.htm (2 of 2) [23/03/2005 05:44:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Import/Export File Data.
This application will show you how to Import and Export Data to and from external text
files. The dialogue box contains two list boxes.
The first contains a list of all the layers contained in the current drawing.
By selecting the Export Layers button, the layer names will be written to file ExLayers.txt.
Selecting the Layers Import button will bring in a list of layers contained
in the file InLayers.txt.
Note : Please ensure that all the files are in the same directory and within
your AutoCAD support path. Thanks :-))
You will need to create a new form with 2 list boxes and 3 buttons.
Keep the default names. Now create a new form and add this coding :
Option Explicit
Private Sub CommandButton1_Click()
Dim objLayer As AcadLayer
Dim Lname As String
'declare variables
Open "Exlayer.txt" For Output As #1
'open text file
For Each objLayer In ThisDrawing.Layers
'start looping thru' the layer names
Lname = objLayer.Name
'get the layer name
Print #1, Lname
'print it to the file
Import Export/File Data
http://www.afralisp.com/vbaa/vbatut33.htm (1 of 3) [23/03/2005 05:44:17 p.m.]
Next
Close #1
'close the file
Unload Me
'unload dialogue
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub CommandButton3_Click()
Dim sTemp As String
'declare variable
ListBox2.Clear
'clear the listbox
Open "Inlayer.txt" For Input As #1
'open the external file
While Not EOF(1)
'until the end of file is reached
Line Input #1, sTemp
'get a layer name
ListBox2.AddItem sTemp
'add it to the list box

Wend
Close #1
'close the file
End Sub
Private Sub UserForm_Initialize()
Dim objLayer As AcadLayer
'declare variables
For Each objLayer In ThisDrawing.Layers
'get the layer names and loop thru' them
ListBox1.AddItem objLayer.Name
'add them to the list box
Next
End Sub
Import Export/File Data
http://www.afralisp.com/vbaa/vbatut33.htm (2 of 3) [23/03/2005 05:44:17 p.m.]

Now create a new module and add this coding :

Sub EILayer()
UserForm1.Show
End Sub

Now run the macro "EILayer.....Good Hey!!!


If you would like to download the source code for this Application/s, then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Import Export/File Data
http://www.afralisp.com/vbaa/vbatut33.htm (3 of 3) [23/03/2005 05:44:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Filtering Layers.
Ever wondered how to filter your drawing for specific layers?
Well here's how. This application will filter your drawing for a specific layer using the
criteria that you will provide from within a sub-routine.
First of all the Function. Open a new module and add this coding :
Option Explicit
Public Function LayerSelection(strLayerName As String, strSSName) _
As AcadSelectionSet
Dim ssObjects As AcadSelectionSet
Dim intCode(0) As Integer
Dim varData(0) As Variant
Dim objCheck As AcadSelectionSet
'declare variables
intCode(0) = 8
'set variable for the dxf code for layer
varData(0) = strLayerName
'set variable for the layer name
Set ssObjects = ThisDrawing.SelectionSets.Add(strSSName)
'create a selection eset
ssObjects.Select acSelectionSetAll, , , intCode, varData
'select all entities on the specified layer
Set LayerSelection = ssObjects
'create a reference to the selection
End Function
Now add the sub-routine to run the function to the same module :
Public Sub FilterLayer()
Dim ssLayrObj As AcadSelectionSet
'declare variables
Set ssLayrObj = LayerSelection("0", "vbdset")
'get the entities on the layer "0"
Dim obj As Object
For Each obj In ssLayrObj
'for each of the entities
obj.Highlight True
'highlight them
Next
Filtering Layers
http://www.afralisp.com/vbaa/vbatut34.htm (1 of 2) [23/03/2005 05:44:19 p.m.]
ThisDrawing.SelectionSets.Item("vbdset").Delete
'delete the selection set
End Sub
Run the macro "FilterLayer". All the entities on Layer 0 should be highlighted.
Now you've got them, you can do anything you like with them.
But that, I will leave to your imagination.......
I would just like to thank Randall Raath for allowing me to 'steal' this.
(Saved me a lot of typing!!!!).
If you would like to download the source code for this Application/s, then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Filtering Layers
http://www.afralisp.com/vbaa/vbatut34.htm (2 of 2) [23/03/2005 05:44:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Edit Line Text.
Here's a good one for you. This will allow you to select any line of text, and then edit it
using a dialogue box.
Note : This will only work with Line Text. Sorry :-(
First of all you need a Module with this coding in it :
Option Explicit
Public objPicked As AcadObject
Public Const VK_ESCAPE = &H1B
Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Function checkkey(lngKey As Long) As Boolean If GetAsyncKeyState(lngKey) Then checkkey =
True Else checkkey = False End If End Function
Public Sub textedit() Dim BasePnt As AcadPoint 'declare variables Start: On Error GoTo
errControl 'if there is an error ThisDrawing.Utility.GetEntity objPicked, BasePnt, _ "Select Line
Text" 'select the object UserForm1.TextBox1.Text = objPicked.TextString 'get the existing
textstring and put it in 'the text box UserForm1.Show 'display the dialogue Exit Sub 'exit the sub
routine errControl: 'define the error control If Err.Description = "Method 'GetEntity' of object _
'IAcadUtility' failed" Then 'if the error matches these.. If checkkey(VK_ESCAPE) = True Then 'if
the escape key is selected End 'end Else 'or else Resume 'repeat "Select Object" End If Else
MsgBox Err.Description 'it must be another type of error End If End Sub

Now insert a userform with a text box and two buttons. Keep the default
names and add this coding to the form :

Private Sub CommandButton1_Click()


If TextBox1.Text = "" Then
'if all text is deleted
TextBox1.Text = " "
'put in a space

End If
objPicked.TextString = TextBox1.Text
Edit Line Text
http://www.afralisp.com/vbaa/vbatut35.htm (1 of 2) [23/03/2005 05:44:21 p.m.]
'get the text string from the text box
objPicked.Update
'update the text
End
End Sub
Private Sub CommandButton2_Click() End End Sub
Private Sub UserForm_Activate() UserForm1.TextBox1.SetFocus 'set focus to the textbox
UserForm1.TextBox1.SelStart = 0 'start at the first character UserForm1.TextBox1.SelLength =
Len(UserForm1.TextBox1.Text) 'highlight the text string End Sub

Now run the macro "TextEdit" and select some line text when prompted.
Change the text and select O.K. Crikey, I'm good hey!!!!
If you would like to download the source code for this Application/s, then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Edit Line Text
http://www.afralisp.com/vbaa/vbatut35.htm (2 of 2) [23/03/2005 05:44:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Change Text.
This application will change the Height, Layer, Style or Colour of selected text within a
drawing. You can use the 'Select Objects' button to select any objects on screen by
using any of the standard AutoCAD selection methods, or you can choose 'Select All' to
select all text entities. The application will automatically filter out all non-text entities.
Create a form with controls as above and add this coding :
Option Explicit
Private Sub CheckBox1_Click()
If TextBox1.Enabled = False Then

TextBox1.Enabled = True

UserForm1.TextBox1.SetFocus
'set focus to the textbox
UserForm1.TextBox1.SelStart = 0
'start at the first character
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)

Else
TextBox1.Enabled = False

End If
End Sub
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (1 of 6) [23/03/2005 05:44:23 p.m.]
Private Sub CheckBox2_Click()
If ComboBox1.Enabled = False Then

ComboBox1.Enabled = True

Else
ComboBox1.Enabled = False

End If
End Sub
Private Sub CheckBox3_Click()
If ComboBox2.Enabled = False Then

ComboBox2.Enabled = True

Else
ComboBox2.Enabled = False

End If
End Sub
Private Sub CheckBox4_Click()
If ComboBox3.Enabled = False Then

ComboBox3.Enabled = True

Else
ComboBox3.Enabled = False

End If
End Sub
Private Sub CommandButton1_Click()
Dim pt1(0) As Double
Dim pt2(0) As Double
Dim FilterSet As Object
Dim gpCode(0) As Integer
Dim gpValue(0) As Variant
'declare variables
UserForm1.Hide
'hide the dialogue
Set FilterSet = ThisDrawing.SelectionSets.Add("TEMP")
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (2 of 6) [23/03/2005 05:44:23 p.m.]
'create a selection set
gpCode(0) = 0
'set the filter DXF code
gpValue(0) = "TEXT"
'set the filter DXF value
FilterSet.Select acSelectionSetAll, pt1, pt2, gpCode, gpValue
'select all text in the drawing
Dim FilterEnt As Object
For Each FilterEnt In FilterSet
'start the loop
If CheckBox1.Value = True Then
FilterEnt.Height = TextBox1.Text
End If
'retrieve the height
If CheckBox2.Value = True Then
FilterEnt.Layer = ComboBox1.Text
FilterEnt.Color = acByLayer
End If
'retrieve the layer
If CheckBox3.Value = True Then
FilterEnt.StyleName = ComboBox2.Text
End If
'retrieve the style
If CheckBox4.Value = True Then
FilterEnt.Color = ComboBox3.Text
End If
'retrieve the color
FilterEnt.Update
'update the entity
Next FilterEnt
ThisDrawing.SelectionSets("TEMP").Delete
'delete the selection set
End
End Sub
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (3 of 6) [23/03/2005 05:44:23 p.m.]
Private Sub CommandButton2_Click()
End
End Sub
Private Sub CommandButton3_Click()
Dim pt1 As Variant
Dim pt2 As Variant
Dim FilterSet As Object
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
'declare variables
Set FilterSet = ThisDrawing.SelectionSets.Add("TEMP")
'create a selection set
FilterType(0) = 0
'set the filter DXF code
FilterData(0) = "TEXT"
'set the filter DXF type
UserForm1.Hide
'hide the dialogue
FilterSet.SelectOnScreen FilterType, FilterData
'select text on screen
Dim FilterEnt As Object
For Each FilterEnt In FilterSet
'start the loop
If CheckBox1.Value = True Then
FilterEnt.Height = TextBox1.Text
End If
'retrieve the height
If CheckBox2.Value = True Then
FilterEnt.Layer = ComboBox1.Text
FilterEnt.Color = acByLayer
End If
'retrieve the layer
If CheckBox3.Value = True Then
FilterEnt.StyleName = ComboBox2.Text
End If
'retrieve the style
If CheckBox4.Value = True Then
FilterEnt.Color = ComboBox3.Text
End If
'retrieve the colour
FilterEnt.Update
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (4 of 6) [23/03/2005 05:44:23 p.m.]
'update the entity
Next FilterEnt
ThisDrawing.SelectionSets("TEMP").Delete
'delete the selection set
End
End Sub
Private Sub UserForm_Initialize()
Dim objLayer As AcadLayer
Dim i As Integer
'declare variables
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
'switch off all checkboxes
TextBox1.Text = ThisDrawing.GetVariable("TextSize")
'retrieve the current text height
ComboBox1.Text = ThisDrawing.GetVariable("CLayer")
'retrieve the current text style
ComboBox2.Text = ThisDrawing.GetVariable("TextStyle")
'retrieve the current text style
For Each objLayer In ThisDrawing.Layers
'get the layer names and loop thru' them
ComboBox1.AddItem objLayer.Name
'add them to the list box
Next
Dim objStyle As AcadTextStyle
'declare variables
For Each objStyle In ThisDrawing.TextStyles
'get the layer names and loop thru' them
ComboBox2.AddItem objStyle.Name
'add them to the list box
Next
For i = 1 To 255
'start the loop
ComboBox3.AddItem i
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (5 of 6) [23/03/2005 05:44:23 p.m.]
'add colour number to combo box
Next i
End Sub
Now open a new module and add this coding :

Sub Chtext1()
UserForm1.Show
End Sub
To run this application run the macro "Chtext1".
There is one thing wrong with this application. The list of Layers and Styles are not sorted. I didn't
include the coding for this as it would have complicated the issue. Therefore, I have included
another version of this application within the zip file that includes the sort coding. (Many thanks to
Randall Raath.)
If you would like to download the source code for this Application/s, then click Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Change Text
http://www.afralisp.com/vbaa/vbatut36.htm (6 of 6) [23/03/2005 05:44:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and Customizable Support Files
Table of Customizable Support Files G
Order of support file loading when starting AutoCAD G
Automatically Load and Execute AutoLISP Routines G
Automatically Load ObjectARX Applications G
acad.lspAutomatically Load AutoLISP G
acaddoc.lspAutomatically Load AutoLISP G
Menu File Types G
Load Menu Files G
acad.mnlAutomatically Load AutoLISP Menu Functions G
S::STARTUP FunctionPost-Initialization Execution G
Tips for Coding AutoLISP Startup Files G
Command Autoloader G
acadvba.arxAutomatically Load VBA G
acad.dvbAutomatically Load a VBA Project G
Automatically Loading a VBA Project G
Automatically Running a VBA Macro G
Table of Customizable Support Files
AutoCAD uses support files for purposes such as storing menu definitions, loading AutoLISP and
ObjectARX applications, and describing text fonts. Many support files are text files that you can modify
with a text editor.
The following is a list of AutoCAD support files that can be edited. The support files are listed in
alphabetical order by file extension. Please make backup copies of these files before modifying them.
Customizable support files
File Description
asi.ini Database connectivity link conversion mapping file.
*.dcl AutoCAD Dialog Control Language (DCL) descriptions of dialog boxes.
*.lin AutoCAD linetype definition files.
acad.lin The standard AutoCAD linetype library file.
acadiso.lin The standard AutoCAD ISO linetype library file.
*.lsp AutoLISP program files.
acad.lsp A user-defined AutoLISP routine that loads each time you start AutoCAD.
acaddoc.lsp A user-defined AutoLISP routine that loads each time you start a drawing.
*.mln A multiline library file.
*.mnl
AutoLISP routines used by AutoCAD menus. A MNL file must have the same file
name as the MNU file it supports.
acad.mnl AutoLISP routines used by the standard AutoCAD menu.
*.mns
AutoCAD generated menu source files. Contains the command strings and macro
syntax that define AutoCAD menus.
acad.mns Source file for the standard AutoCAD menu.
*.mnu
AutoCAD menu source files. Contain the command strings and macro syntax that
define AutoCAD menus.
acad.mnu Source file for the standard AutoCAD menu.
*.pat AutoCAD hatch pattern definition files.
acad.pat The standard AutoCAD hatch pattern library file.
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (1 of 8) [23/03/2005 05:44:28 p.m.]
acadiso.pat The standard AutoCAD ISO hatch pattern library file.
acad.pgp
The AutoCAD program parameters file. Contains definitions for external commands
and command aliases.
acad.psf
AutoCAD PostScript Support file; the master support file for the PSOUT and PSFILL
commands.
acad.rx Lists ObjectARX applications that load when you start AutoCAD.
*.scr
AutoCAD script files. A script file contains a set of AutoCAD commands processed
as a batch.
*.shp
AutoCAD shape/font definition files. Compiled shape/font files have the extension
.shx.
acad.unt
AutoCAD unit definition file. Contains data that lets you convert from one set of
units to another.

Order of support file loading when starting AutoCAD


You can understand the effects that one file may have on another if you know the order in which files
are loaded when you start the software. For example, you have defined a function in an AutoLISP
routine that is loaded from the acad.lsp file, but the function does not work when you start AutoCAD.
This occurs because the function has been redefined by the acaddoc.lsp file, which is loaded after
acad.lsp.
Following is a list of AutoCAD, Express Tools, and user-defined files in the order they are loaded when
you first start the program.
File For use by:
acad2000.lsp AutoCAD
acad.rx User
acad.lsp User
acad2000doc.lsp AutoCAD
acetutil.fas Express Tools
acaddoc.lsp User
mymenu.mnc User
mymenu.mnl User
acad.mnc AutoCAD
acad.mnl AutoCAD
acetmain.mnc Express Tools
acetmain.mnl Express Tools
s::startup User
Note: If the user-defined function S::STARTUP is included in the acad.lsp or acaddoc.lsp file or a MNL
file, the function is called when you enter a new drawing or open an existing drawing. Thus, you can
include a definition of S::STARTUP in the LISP startup file to perform any setup operations.

Automatically Load and Execute AutoLISP Routines


As you build a library of useful AutoLISP routines, you may want to load them each time you run
AutoCAD. You may also want to execute certain commands or functions at specific times during a
drawing session.
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (2 of 8) [23/03/2005 05:44:28 p.m.]
AutoCAD loads the contents of four user-definable files automatically: acad.rx, acad.lsp, acaddoc.lsp,
and the .mnl file that accompanies your current menu. By default, the acad.lsp loads only once, when
AutoCAD starts, while acaddoc.lsp loads with each individual document (or drawing). This lets you
associate the loading of the acad.lsp file with application startup, and the acaddoc.lsp file with document
(or drawing) startup. The default method for loading these startup files can be modified by changing the
setting of the ACADLSPASDOC system variable.
If one of these files defines a function of the special type S::STARTUP, this routine runs immediately
after the drawing is fully initialized. The S::STARTUP function is described in S::STARTUP
FunctionPost-Initialization Execution. As an alternative, the APPLOAD command provides a Startup
Suite option that loads the specified applications without the need to edit any files.
The acad.lsp and acaddoc.lsp startup files are not provided with AutoCAD. It is up to the user to create
and maintain these files.
Automatically Load ObjectARX Applications
The acad.rx file contains a list of the ObjectARX program files that are loaded automatically when you
start AutoCAD. You can edit this file with a text editor or word processor that produces files in ASCII text
format. You can customize this file as you want, adding to or deleting from its contents and making the
appropriate ObjectARX programs available for use. As an alternative, the APPLOAD command provides
a Startup Suite option that loads the specified applications without the need to edit any files.
Because AutoCAD searches for the acad.rx file in the order specified by the library path, you can have a
different acad.rx file in each drawing directory. This makes specific ObjectARX programs available for
certain types of drawings. For example, you might keep 3D drawings in a directory called
AcadJ obs/3d_dwgs. If that directory is set up as the current directory, you could copy the acad.rx file
into that directory and modify it in the following manner:
myapp1
otherapp
If you place this new acad.rx file in the AcadJ obs/3d_dwgs directory and you start AutoCAD with that as
the current directory, these new ObjectARX programs are then loaded and are available from the
AutoCAD prompt line. Because the original acad.rx file is still in the directory with the AutoCAD program
files, the default acad.rx file will be loaded if you start AutoCAD from another directory that does not
contain an acad.rx file.
You can load ObjectARX programs from an .mnl file using the arxload function. This ensures that an
ObjectARX program, required for proper operation of a menu, will be loaded when the menu file is
loaded.
You can also autoload many ObjectARX-defined AutoCAD commands (see Command Autoloader and
"autoarxload" in the AutoLISP Reference).
acad.lspAutomatically Load AutoLISP
The acad.lsp file is useful if you want to load specific AutoLISP routines every time you start AutoCAD.
When you start AutoCAD, the program searches the library path for an acad.lsp file. If it finds one, it
loads the file into memory.
The acad.lsp file is loaded at each drawing session startup when AutoCAD is launched from the
Windows desktop. Because the acad.lsp file is intended to be used for application-specific startup
routines, all functions and variables defined in an acad.lsp file are only available in the first drawing. You
will probably want to move routines that should be available in all documents from your acad.lsp file into
the new acaddoc.lsp file.
The recommended functionality of acad.lsp and acaddoc.lsp can be overridden with the
ACADLSPASDOC system variable. If the ACADLSPASDOC system variable is set to 0 (the default
setting), the acad.lsp file is loaded just once; upon application startup. if ACADLSPASDOC is set to 1,
the acad.lsp file is reloaded with each new drawing.
The ACADLSPASDOC system variable is ignored in SDI (single document interface) mode. When the SDI
system variable is set to 1, the LISPINIT system variable controls reinitialization of AutoLISP between
drawings. When LISPINIT is set to 1, AutoLISP functions and variables are valid in the current drawing
only; each time you start a new drawing or open an existing one, all functions and variables are cleared
from memory and the acad.lsp file is reloaded. Changing the value of LISPINIT when the SDI system
variable is set to 0 has no effect.
The acad.lsp file can contain AutoLISP code for one or more routines, or just a series of load function
calls. The latter method is preferable, because modification is easier. If you save the following code as
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (3 of 8) [23/03/2005 05:44:28 p.m.]
an acad.lsp file, the files mysessionapp1.lsp, databasesynch.lsp, and drawingmanager.lsp are loaded
every time you start AutoCAD.
(load "mysessionapp1")
(load "databasesynch")
(load "drawingmanager")
Note: Do not modify the reserved acad2000.lsp file. Autodesk provides the acad2000.lsp file, which
contains AutoLISP defined functions that are required by AutoCAD. This file is loaded into memory
immediately before the acad.lsp file is loaded.

acaddoc.lspAutomatically Load AutoLISP


The acaddoc.lsp file is intended to be associated with each document (or drawing) initialization. This file
is useful if you want to load a library of AutoLISP routines to be available every time you start a new
drawing (or open an existing drawing). Each time a drawing opens, AutoCAD searches the library path
for an acaddoc.lsp file. If it finds one, it loads the file into memory. The acaddoc.lsp file is always loaded
with each drawing regardless of the settings of ACADLSPASDOC and LISPINIT.
Most users will have a single acaddoc.lsp file for all document-based AutoLISP routines. AutoCAD
searches for an acaddoc.lsp file in the order defined by the library path; therefore, with this feature, you
can have a different acaddoc.lsp file in each drawing directory, which would load specific AutoLISP
routines for certain types of drawings or jobs.
The acaddoc.lsp file can contain AutoLISP code for one or more routines, or just a series of load
function calls. The latter method is preferable, because modification is easier. If you save the following
code as an acaddoc.lsp file, the files mydocumentapp1.lsp, build.lsp, and counter.lsp are loaded every
time a new document is opened.
(load "mydocumentapp1")
(load "build")
(load "counter")
AutoCAD searches for an acaddoc.lsp file in the order defined by the library path; therefore, you can
have a different acaddoc.lsp file in each drawing directory. You can then load specific AutoLISP routines
for certain types of drawings or jobs.
Note: Do not modify the reserved acad2000doc.lsp file. Autodesk provides the acad2000doc.lsp file,
which contains AutoLISP-defined functions that are required by AutoCAD. This file is loaded into
memory immediately before the acaddoc.lsp file is loaded.
Menu File Types
The term menu file actually refers to the group of files that work together to define and control the
appearance and functionality of the menu areas. The following table describes the AutoCAD menu file
types.
AutoCAD menu files
File type Description
MNU Template menu file.
MNC
Compiled menu file. This binary file contains the command strings and menu syntax
that defines the functionality and appearance of the menu.
MNR Menu resource file. This binary file contains the bitmaps used by the menu.
MNS Source menu file (generated by AutoCAD).
MNT
Menu resource file. This file is generated when the MNR file is unavailable, for example,
read-only.
MNL
Menu LISP file. This file contains AutoLISP expressions that are used by the menu file
and are loaded into memory when a menu file with the same file name is loaded.
Load Menu Files
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (4 of 8) [23/03/2005 05:44:28 p.m.]
Use the MENU command to load a new menu. Use the MENULOAD and MENUUNLOAD commands to
load and unload additional menus (called partial menus) and to add or remove individual menus from the
menu bar.
AutoCAD stores the name of the last loaded menu in the system registry. Thisname is also saved with
the drawing, but it is used only for backward compatibility. When you start AutoCAD, the last menu used
is loaded. As of Release 14, AutoCAD no longer reloads the menu between drawings.
AutoCAD finds and loads the specified file according to the following sequence. (This sequence is also
used when AutoCAD loads a new menu with the MENU command.)
AutoCAD looks for a menu source file (MNS) of the given name, following the library search
procedure.
G
If an MNS file is found, AutoCAD looks for a compiled menu file (.mnc) of the same name in the
same directory. If AutoCAD finds a matching MNC file with the same or later date and time as the
MNS file, it loads the MNC file. Otherwise, AutoCAD compiles the MNS file, generating a new MNC
file in the same directory, and loads that file.
G
If an MNS file is not found, AutoCAD looks for a compiled menu file (.mnc) of the given name,
following the library search procedure. If AutoCAD finds the MNC file, it loads that file.
G
If AutoCAD doesn't find either a MNS or a MNC file, it searches the library path for a menu
template file (.mnc) of the given name. If this file is found, it compiles an MNC and MNS file, then
loads the MNC file.
G
If AutoCAD doesn't find any menu files of the given names, an error message is displayed and you
are prompted for another menu file name.
G
After finding, compiling, and loading the MNC file, AutoCAD looks for a menu LISP file (.mnl),
using the library search procedure. If AutoCAD finds this file, it evaluates the AutoLISP
expressions within that file.
G
The acad.mnl file contains AutoLISP code used by the standard menu file, acad.mnu. The acad.mnl file is
loaded each time the acad.mnu file is loaded.
Each time AutoCAD compiles an MNC file it generates a menu resource file (MNR) which contains the
bitmaps used by the menu. The MNS file is an ASCII file that is initially the same as the MNU file (without
comments or special formatting). The MNS file is modified by AutoCAD each time you make changes to
the contents of the menu file through the interface (such as modifying the contents of a toolbar).
Although the initial positioning of the toolbars is defined in the MNU or MNS file, changes to the
show/hide and docked/floating status or changes to the toolbar positions are recorded in the system
registry. After an MNS file has been created, it is used as the source for generating future MNC, and MNR
files. If you modify the MNU file after an MNS file has been generated, you must use the MENU command
to explicitly load the MNU file so that AutoCAD will generate new MNS and MNC files and your changes
will be recognized.
Note: If you use the interface to modify the toolbars, you should cut and paste the modified portions of
the MNS file to the MNU file before deleting the MNS file.
The MENU command initially requests the MNS or MNC file. To reload a modified MNU file, choose the
Menu Template item from the file type list, and then choose the MNU file from the list of files. Doing so
protects the MNS file from accidentally being rebuilt, thus losing any toolbar or partial menu
modifications done through the interface. While building and testing a menu file, you may find this
procedure awkward. The following AutoLISP routine defines a new command, MNU, which reloads the
current MNU file without going through all the prompts.
(defun C:MNU ()
(command "_menu" (strcat (getvar "menuname") ".mnu"))
(princ)
)
If you add this code to your acad.lsp file, the MNU command is automatically defined when you restart
AutoCAD.
acad.mnlAutomatically Load AutoLISP Menu Functions
The other type of file that AutoCAD loads automatically accompanies your current menu file and has the
extension .mnl. When AutoCAD loads a menu file, it searches for an MNL file with a matching file name.
If it finds the file, it loads the file into memory.
This function ensures that AutoCAD loads the AutoLISP functions that are needed for proper operation
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (5 of 8) [23/03/2005 05:44:28 p.m.]
of a menu. As an example, the standard AutoCAD menu, acad.mnu, relies on the file acad.mnl being
loaded properly. This file defines numerous AutoLISP functions used by the menu. The MNL file is
loaded after the acaddoc.lsp file.
Note: If a menu file is loaded with the AutoLISP command function (with syntax similar to (command
"menu" "newmenu") ), the associated MNL file is not loaded until the entire AutoLISP routine has run.
For example, if you create a custom menu called newmenu.mnu and you need to load three AutoLISP
files (new1.lsp, new2.lsp, and new3.lsp) for the menu to work properly, you should create an ASCII text
file named newmenu.mnl as follows:
(load "new1")
(load "new2")
(load "new3")
(princ "\nNewmenu utilities... Loaded.")
(princ)
In this example, calls to the princ function can be used to display status messages. The first use of princ
displays the following on the command line:
Newmenu utilities... Loaded.
The second call to princ exits the AutoLISP function. Without this second call to princ, the message
would be displayed twice. As mentioned previously, you can include the onfailure argument with calls to
the load function as an extra precaution.
S::STARTUP FunctionPost-Initialization Execution
The startup LISP files (acad.lsp, acaddoc.lsp, and .mnl) all load into memory before the drawing is
completely initialized. Typically, this does not pose a problem, unless you want to use the command
function, which is not guaranteed to work until after a drawing is initialized.
If the user-defined function S::STARTUP is included in an acad.lsp, acaddoc.lsp or a .mnl file, it is called
when you enter a new drawing or open an existing drawing. Thus, you can include a definition of
S::STARTUP in the LISP startup file to perform any setup operations.
For example, if you want to override the standard HATCH command by adding a message and then
switching to the BHATCH command, use an acaddoc.lsp file that contains the following:
(defun C:HATCH ( )
(alert "Using the BHATCH command!")
(princ "\nEnter OLDHATCH to get to real HATCH command.\n")
(command "BHATCH")
(princ)
)
(defun C:OLDHATCH ( )
(command ".HATCH")
(princ)
)
(defun-q S::STARTUP ( )
(command "undefine" "hatch")
(princ "\nRedefined HATCH to BHATCH!\n")
)
Before the drawing is initialized, new definitions for HATCH and OLDHATCH are defined with the defun
function. After the drawing is initialized, the S::STARTUP function is called and the standard definition of
HATCH is undefined.
Note: To be appended, the S::STARTUP function must have been defined with the defun-q function
rather than defun.
Because an S::STARTUP function can be defined in many places (an acad.lsp, acaddoc.lsp, .mnl file, or
any other AutoLISP file loaded from any of these), it's possible to overwrite a previously defined
S::STARTUP function. The following example shows one method of ensuring that your start-up function
works with other functions.
(defun-q MYSTARTUP ( )
... your start-up function ...
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (6 of 8) [23/03/2005 05:44:28 p.m.]
)
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
The previous code appends your start-up function to that of an existing S::STARTUP function, and then
redefines the S::STARTUP function to include your start-up code. This works properly regardless of the
prior existence of an S::STARTUP function.
Tips for Coding AutoLISP Startup Files
If an AutoLISP error occurs while you are loading a startup file, the remainder of the file is ignored and is
not loaded. Files specified in a startup file that do not exist or that are not in the AutoCAD library path
generally cause errors. Therefore, you may want to use the onfailure argument with the load function.
The following example uses the onfailure argument:
(princ (load "mydocapp1" "\nMYDOCAPP1.LSP file not loaded."))
(princ (load "build" "\nBUILD.LSP file not loaded."))
(princ (load "counter" "\nCOUNTER.LSP file not loaded."))
(princ)
If a call to the load function is successful, it returns the value of the last expression in the file (usually
the name of the last defined function or a message regarding the use of the function). If the call fails, it
returns the value of the onfailure argument. In the preceding example, the value returned by the load
function is passed to the princ function, causing that value to be displayed on the command line. For
example, if an error occurs while AutoCAD loads the mydocapp1.lsp file, the princ function displays the
following message and AutoCAD continues to load the two remaining files:
MYDOCAPP1.LSP file not loaded.
If you use the command function in an acad.lsp, acaddoc.lsp or MNL file, it should be called only from
within a defun statement. Use the S::STARTUP function to define commands that need to be issued
immediately when you begin a drawing session. The S::STARTUP function is described in S::STARTUP
FunctionPost-Initialization Execution.
Command Autoloader
When you automatically load a command using the load or command functions, the command's
definition takes up memory whether or not you actually use the command. The AutoLISP autoload
function makes a command available without loading the entire routine into memory. Adding the
following code to your acaddoc.lsp file automatically loads the commands CMD1, CMD2, and CMD3 from
the cmds.lsp file and the NEWCMD command from the newcmd.lsp file.
(autoload "CMDS" '("CMD1" "CMD2" "CMD3"))
(autoload "NEWCMD" '("NEWCMD"))
The first time you enter an automatically loaded command at the Command prompt, AutoLISP loads the
entire command definition from the associated file. AutoLISP also provides the autoarxload function for
ObjectARX applications. See "autoload" and "autoarxload" in the AutoLISP Reference.
acadvba.arxAutomatically Load VBA
You cannot load VBA until an AutoCAD VBA command is issued. If you want to load VBA automatically
every time you start AutoCAD include the following line in the acad.rx file:
acadvba.arx
You can automatically run a macro in the acad.dvb file by naming the macro AcadStartup. Any macro in
your acad.dvb file called AcadStartup automatically executes when VBA loads.
acad.dvbAutomatically Load a VBA Project
The acad.dvb file is useful if you want to load a specific VBA project that contains macros you want each
time you start AutoCAD. Each time you start a new AutoCAD drawing session, AutoCAD searches for the
acad.dvb file and loads it.
If you want a macro in your acad.dvb file to run each time you start a new drawing or open an existing
one, add the following code to your acaddoc.lsp file:
(defun S::STARTUP()
(command "_-vbarun" "updatetitleblock")
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (7 of 8) [23/03/2005 05:44:28 p.m.]
)
Automatically Loading a VBA Project
There are two different ways to load a VBA project automatically:
When VBA is loaded it will look in the AutoCAD directory for a project named acad.dvb. This file
will automatically load as the default project
G
Any project other than the default, acad.dvb, can be used by explicitly loading that project at
startup using the VBALOAD command. The following code sample uses the AutoLISP startup file
to load VBA and a VBA project named myproj.dvb when AutoCAD is started. Start notepad.exe
and create (or append to) acad.lsp the following lines:
G
(defun S::STARTUP()
(command "_VBALOAD" "myproj.dvb")
)
Automatically Running a VBA Macro
You can automatically run any macro in the acad.dvb file by calling it with the command line version of
VBARUN from an AutoCAD startup facility like acad.lsp. For example, to automatically run the macro
named drawline, first save the drawline macro in the acad.dvb file. Next, invoke notepad.exe and create
(or append to) acad.lsp the following lines:
(defun S::STARTUP()
(command "_-vbarun" "drawline")
)
You can cause a macro to run automatically when VBA loads by naming the macro AcadStartup. Any
macro in your acad.dvb file called AcadStartup will automatically get executed when VBA loads.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and Customizable Support Files
http://www.afralisp.com/lisp/custom.htm (8 of 8) [23/03/2005 05:44:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
VBA and Menu's - Page I
Before starting on this tutorial, I presume that you are familiar with AutoCAD menu's and
that you have a bit of experience in modifying menu's or creating your own partial
menu's. It will also make things a lot easier for you if you have a basic understanding of
AutoCAD's macro language.
If not, and you don't understand a word that I am talking about, I suggest you pop along
to this tutorial, Creating Menu's, which should explain the basics to you.
Right, pull up a chair, grab a beer, and let's get started.
In VBA you can only create Pulldown and Toolbar menu's, although you can access Image, Screen
and Tablet menu's.
This tutorial will demonstrate how to create Pulldown and Toolbar menu's, as well as show you a
few examples on how to use menu macro's to call AutoCAD command functions, AutoLisp routines
and Image menu's.
Let's begin with Pulldown menu's. First you need to create an empty file in Notepad called
"VbaMenu.mns". Make sure that this file is within your AutoCAD search path. Fire up AutoCAD,
open the VBA Editor and add this coding to a module :
'CODING STARTS HERE
Option Explicit
Sub VbaMenu1()
Dim currMenuGroup As AcadMenuGroup
Dim openMacro As String
Dim newMenuItem As AcadPopupMenuItem
Dim newScmenu As AcadPopupMenu
Dim newMenu As AcadPopupMenu
On Error GoTo Err_Control
'Load the VBAMENU menu
ThisDrawing.Application.MenuGroups.Load "VbaMenu.mns"
'We now need to obtain a reference to our new menu, VBAMENU
'Use MenuGroups property to obtain reference to main VBAMENU menu
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("VBAMENU")
'==========================================================
'Create Pulldown Menu
'==========================================================
'Creat the pulldown menu title
Set newMenu = currMenuGroup.Menus.Add("V&BA Menu")
'==========================================================
VBA and Menu's
http://www.afralisp.com/vba/vbamenu.htm (1 of 4) [23/03/2005 05:44:30 p.m.]
'create the first pulldown item, vbaload
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaload" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "VBA &Load", openMacro)
newMenuItem.HelpString = "Load a VBA Application"
'==========================================================
'create the second pulldown item, vbaide
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaide" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "VBA &Editor", openMacro)
newMenuItem.HelpString = "Switch to the VBA Editor"
'==========================================================
'create the third pulldown item, vbarun
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbarun" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "VBA &Macro", openMacro)
newMenuItem.HelpString = "Run a VBA Macro"
'==========================================================
'create the fourth pulldown item, vbaman
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaman" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "&VBA Manager",
openMacro)
newMenuItem.HelpString = "Display the VBA Manager"
'==========================================================
'insert a separator after the fourth menu item
newMenu.AddSeparator (5)
'==========================================================
'create a simple menu macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "zoom" & Chr(32) & "w" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "&Zoom", openMacro)
newMenuItem.HelpString = "Zoom Window"
'===================================================================
'create a menu item that loads and runs an Autolisp routine
openMacro = Chr(3) & Chr(3) & Chr(95) & "(if (not c:ddvpoint) (load ""ddvpoint"")" & Chr(32)
& "ddvpoint" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "View &Point", openMacro)
newMenuItem.HelpString = "View Point"
'===================================================================
'create a menu item that calls an Image menu
openMacro = Chr(3) & Chr(3) & Chr(95) & "$I=image_3dobjects $I=*"
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "&3D Objects", openMacro)
newMenuItem.HelpString = "3D Objects"
'===================================================================
'create a menu item with a hyperlink
openMacro = Chr(3) & Chr(3) & Chr(95) & "browser" & Chr(32) & "www.afralisp.com" &
Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, "&AfraLisp.com",
openMacro)
newMenuItem.HelpString = "Visit AfraLisp now, or else."
'===================================================================
'===================================================================
'insert the pulldown menu into the menu bar, third from the end
newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count - 2)
'===================================================================
're-compile the VBAMENU menu - VBAMENU.MNC
currMenuGroup.Save acMenuFileCompiled
'save it as a MNS file.
currMenuGroup.Save acMenuFileSource
VBA and Menu's
http://www.afralisp.com/vba/vbamenu.htm (2 of 4) [23/03/2005 05:44:30 p.m.]
Just_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'The menu exists, just exit
Case -2147024809
Err.Clear
Resume Just_Here
Case Else
MsgBox Err.Description
Exit Sub
End Select
End Sub
'CODING ENDS HERE
Save your project as VbaMenu1, return to AutoCAD and run the macro. You should have a new
Pulldown menu on the menu bar that looks like this :
Try out each menu item. It works hey! Now navigate your way to were you stored VbaMenu.mns
and open it. You should see something like this :
//
// AutoCAD menu file - O:\e51d\e51d1\VbaMenu.mns
//
***MENUGROUP=VbaMenu
***POP2
ID_mnuVBA Menu [V&BA Menu]
ID_VBA Load [VBA &Load]^C^C_vbaload
ID_VBA Editor [VBA &Editor]^C^C_vbaide
ID_VBA Macro [VBA &Macro]^C^C_vbarun
ID_VBA Manager [&VBA Manager]^C^C_vbaman
[--]
ID_Zoom [&Zoom]^C^C_zoom w
ID_View Point [View &Point]^C^C_(if (not c:ddvpoint) (load "ddvpoint") ddvpoint
ID_3D Objects [&3D Objects]^C^C_$I=image_3dobjects $I=*
ID_AfraLisp.com [&AfraLisp.com]^C^C_browser www.afralisp.com
***TOOLBARS
***HELPSTRINGS
ID_VIEW POINT [View Point]
ID_AFRALISP.COM [Visit AfraLisp now, or else.]
ID_VBA MANAGER [Display the VBA Manager]
VBA and Menu's
http://www.afralisp.com/vba/vbamenu.htm (3 of 4) [23/03/2005 05:44:30 p.m.]
ID_VBA LOAD [Load a VBA Application]
ID_ZOOM [Zoom Window]
ID_VBA MACRO [Run a VBA Macro]
ID_3D OBJECTS [3D Objects]
ID_VBA EDITOR [Switch to the VBA Editor]
//
// End of AutoCAD menu file - O:\e51d\e51d1\VbaMenu.mns
//
You should also find VbaMenu.mnc and VbaMenu.mnr in the same folder. Even though the
VbaMenu.mns file was empty when we started, VBA has created all the coding necessary and
compiled the other menu support files required for the menu to run.
On the next page, we'll have a look at creating Toolbar menu's.
Home. Page II. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Menu's
http://www.afralisp.com/vba/vbamenu.htm (4 of 4) [23/03/2005 05:44:30 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page III.
VBA and Menu's - Page II
Before continuing with this tutorial, please delete the VbaMenu.mnc, VbaMenu.mnr files, and
delete the contents of VbaMenu.mns. This is to allow the menu to be re-compiled with only the
Toolbar menu items. You must also ensure that the 4 bitmap files, VbaLoad.bmp, Vbaide.bmp,
VbaMacro.bmp, and VbaMan.bmp are in the same folder as your menu files.
Now place the following coding into a module and save it as VbaMenu2.
'CODING STARTS HERE
Option Explicit
Sub VbaMenu2()
Dim currMenuGroup As AcadMenuGroup
Dim newToolBar As AcadToolbar
Dim newToolBarButton As AcadToolbarItem
Dim openMacro As String
Dim SmallBitmapName As String
Dim LargeBitmapName As String
On Error GoTo Err_Control
'Load the VBAMENU menu
ThisDrawing.Application.MenuGroups.Load "VbaMenu.mns"
'We now need to obtain a reference to our new menu, VBAMENU
'Use MenuGroups property to obtain reference to main VBAMENU menu
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("VBAMENU")
'==========================================================
' Create Toolbar Menu
Set newToolBar = currMenuGroup.Toolbars.Add("Vba Menu")
'==========================================================
'vbaload macro and bitmaps
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaload" & Chr(32)
Set newToolBarButton = newToolBar.AddToolbarButton(newToolBar.Count + 1, "VBA Load",
"VBALoad", openMacro, False)
SmallBitmapName = "VBALOAD.BMP"
LargeBitmapName = "VBALOAD.BMP"
newToolBarButton.SetBitmaps SmallBitmapName, LargeBitmapName
newToolBarButton.HelpString = "Load a VBA Application"
'==========================================================
'vbaide macro and bitmaps
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaide" & Chr(32)
Set newToolBarButton = newToolBar.AddToolbarButton(newToolBar.Count + 1, "VBA Editor",
"VBA Editer", openMacro, False)
SmallBitmapName = "VBAIDE.BMP"
VBA and Menu's II
http://www.afralisp.com/vba/vbamenu1.htm (1 of 3) [23/03/2005 05:44:31 p.m.]
LargeBitmapName = "VBAIDE.BMP"
newToolBarButton.SetBitmaps SmallBitmapName, LargeBitmapName
'==========================================================
'vbarun macro and bitmaps
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbarun" & Chr(32)
Set newToolBarButton = newToolBar.AddToolbarButton(newToolBar.Count + 1, "Run Macro",
"Run Macro", openMacro, False)
SmallBitmapName = "VBAMACRO.BMP"
LargeBitmapName = "VBAMACRO.BMP"
newToolBarButton.SetBitmaps SmallBitmapName, LargeBitmapName
'==========================================================
'vbaman macro and bitmaps
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaman" & Chr(32)
Set newToolBarButton = newToolBar.AddToolbarButton(newToolBar.Count + 1, "VBA
Manager", "VBA Manager", openMacro, False)
SmallBitmapName = "VBAMAN.BMP"
LargeBitmapName = "VBAMAN.BMP"
newToolBarButton.SetBitmaps SmallBitmapName, LargeBitmapName
'==========================================================
're-compile the VBAMENU menu - VBAMENU.MNC
currMenuGroup.Save acMenuFileCompiled
'save it as a MNS file.
currMenuGroup.Save acMenuFileSource
Just_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'The menu exists, just exit
Case -2147024809
Err.Clear
Resume Just_Here
Case Else
MsgBox Err.Description
Exit Sub
End Select
End Sub
'CODING ENDS HERE
Run the VbaMenu2 macro. A toolbar like this should appear on your screen :
Open your VbaMenu.mns file. It should look like this :
//
// AutoCAD menu file - VbaMenu.mns
//
***MENUGROUP=VbaMenu
***TOOLBARS
VBA and Menu's II
http://www.afralisp.com/vba/vbamenu1.htm (2 of 3) [23/03/2005 05:44:31 p.m.]
**VBA_MENU
ID_Vba_Menu_0 [_Toolbar("Vba Menu", _Floating, _Show, 212, 192, 1)]
ID_VBA_Load_0 [_Button("VBA Load", "VBALOAD.BMP", "VBALOAD.BMP")]^C^C_vbaload
ID_VBA_Editor_0 [_Button("VBA Editor", "VBAIDE.BMP", "VBAIDE.BMP")]^C^C_vbaide
ID_Run_Macro_0 [_Button("Run Macro", "VBAMACRO.BMP",
"VBAMACRO.BMP")]^C^C_vbarun
ID_VBA_Manager_0 [_Button("VBA Manager", "VBAMAN.BMP",
"VBAMAN.BMP")]^C^C_vbaman
***HELPSTRINGS
ID_VBA_MANAGER_0 [VBA Manager]
ID_VBA_LOAD_0 [Load a VBA Application]
ID_RUN_MACRO_0 [Run Macro]
ID_VBA_EDITOR_0 [VBA Editer]
//
// End of AutoCAD menu file - VbaMenu.mns
//
Again, the coding for the menu has been compiled.
Crikey, this is getting interesting! Let's dig a bit deeper.
On the next page we'll have a look at accessing and adding to the AutoCAD PopUp menu's. Come
on, don't be scared.......
Home. Page II. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Menu's II
http://www.afralisp.com/vba/vbamenu1.htm (3 of 3) [23/03/2005 05:44:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page II.
VBA and Menu's - Page III
Let's look at the right-click Pop-up menu first. Up until now we've been dealing with our own
partial menu that we loaded to run alongside the AutoCAD menu. Pop-up menu's on the other
hand, are part of the AutoCAD menu. Therefore we need to access this menu and add the items
that we require.
Place this coding into a module and save it as VbaMenu3 :
'CODING STARTS HERE
Option Explicit
Sub VbaMenu3()
Dim currMenuGroup As AcadMenuGroup
Dim openMacro As String
Dim newScmenu As AcadPopupMenu
Dim newMenu As AcadPopupMenu
Dim scMenu As AcadPopupMenu
Dim entry As AcadPopupMenu
On Error GoTo Err_Control
' To add items to the right-click shortcut menu, we need to obtain
' reference to the AutoCAD menu.
' Use MenuGroups property to obtain reference to main ACAD menu
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD")
'===================================================================
'find the shortcut menu
For Each entry In currMenuGroup.Menus
If entry.ShortcutMenu = True Then
Set scMenu = entry
End If
Next entry
'create a shortcut menu item
Set newScmenu = scMenu.AddSubMenu(0, "&VBA Menu")
'create the vbaload macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaload" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Load", openMacro
'create the vbaide macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaide" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Editor", openMacro
VBA and Menu's III
http://www.afralisp.com/vba/vbamenu2.htm (1 of 5) [23/03/2005 05:44:34 p.m.]
'create the vbarun macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbarun" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Macro", openMacro
'create the vbaman macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaman" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "&VBA Manager", openMacro
'add a separator line
scMenu.AddSeparator 1
're-compile the AutoCAD MENU
currMenuGroup.Save acMenuFileCompiled
'save it as a MNS file.
currMenuGroup.Save acMenuFileSource
'===============================================
'===============================================
Just_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'The menu exists, just exit
Case -2147024809
Err.Clear
Resume Just_Here
Case Else
MsgBox Err.Description
Exit Sub
End Select
End Sub
'CODING ENDS HERE
Now run the macro VbaMenu3. Right-click anywhere on the screen to activate the right-click
pop-up menu. It should now look like this :
Now open the AutoCAD.mns file and have a look at the POP0 menu section.
***POP0
**SNAP
[&Object Snap Cursor Menu]
VBA and Menu's III
http://www.afralisp.com/vba/vbamenu2.htm (2 of 5) [23/03/2005 05:44:34 p.m.]
ID_mnuVBA Menu [->&VBA Menu]
ID_VBA Load [VBA &Load]^C^C_vbaload
ID_VBA Editor [VBA &Editor]^C^C_vbaide
ID_VBA Macro [VBA &Macro]^C^C_vbarun
ID_VBA Manager [&VBA Manager]^C^C_vbaman
[--]
ID_Tracking [Temporary trac&k point]_tt
ID_From [&From]_from
ID_MnPointFi [->Poin&t Filters]
ID_PointFilx [.X].X
ID_PointFily [.Y].Y
ID_PointFilz [.Z].Z
[--]
ID_PointFixy [.XY].XY
ID_PointFixz [.XZ].XZ
ID_PointFiyz [<-.YZ].YZ
[--]
ID_OsnapEndp [&Endpoint]_endp
ID_OsnapMidp [&Midpoint]_mid
ID_OsnapInte [&Intersection]_int
ID_OsnapAppa [&Apparent Intersect]_appint
ID_OsnapExte [E&xtension]_ext
[--]
ID_OsnapCent [&Center]_cen
ID_OsnapQuad [&Quadrant]_qua
ID_OsnapTang [Tan&gent]_tan
[--]
ID_OsnapPerp [&Perpendicular]_per
ID_OsnapPara [Para&llel]_par
ID_OsnapNode [No&de]_nod
ID_OsnapInse [In&sert]_ins
ID_OsnapNear [Nea&rest]_nea
ID_OsnapNone [&None]_non
[--]
ID_Osnap [&Osnap Settings...]'_+dsettings 2
As you can see, the AutoCAD menu has been re-compiled with our new menu items included.
Right, let's now add to the cursor menu. Place this coding into a module and save it as VbaMenu4.
'CODING STARTS HERE
Private Sub AcadDocument_BeginShortcutMenuDefault(ShortcutMenu As
AutoCAD.IAcadPopupMenu)
On Error Resume Next
'Add a menu item to the cursor menu
Dim newMenuItem As AcadPopupMenuItem
Dim openMacro As String
openMacro = Chr(27) + Chr(27) + Chr(95) + "trim" + Chr(32) + Chr(32)
Set newMenuItem = ShortcutMenu.AddMenuItem _
(11, "&Trim", openMacro)
openMacro = Chr(27) + Chr(27) + Chr(95) + "extend" + Chr(32) + Chr(32)
Set newMenuItem = ShortcutMenu.AddMenuItem _
(12, "&Extend", openMacro)
End Sub
Private Sub AcadDocument_EndShortcutMenu _
(ShortcutMenu As AutoCAD.IAcadPopupMenu)
VBA and Menu's III
http://www.afralisp.com/vba/vbamenu2.htm (3 of 5) [23/03/2005 05:44:34 p.m.]
On Error Resume Next
ShortcutMenu.Item("Trim").Delete
ShortcutMenu.Item("Extend").Delete
End Sub
'CODING ENDS HERE
Add VbaMenu4 to your startup suitcase and re-start AutoCAD. Now, trigger your curser pop-up
menu.
You should have two new menu items, namely Trim and Extend.
Do you notice that this does not force the AutoCAD menu to re-compile but just adds and deletes
from it on the fly. Worth thinking about isn't it?
Would you like to boldly go where no man ever goes? Then be brave and just click here for the
source coding.
Home. Page I. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
VBA and Menu's III
http://www.afralisp.com/vba/vbamenu2.htm (4 of 5) [23/03/2005 05:44:34 p.m.]
Search
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Menu's III
http://www.afralisp.com/vba/vbamenu2.htm (5 of 5) [23/03/2005 05:44:34 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III. Page IV.
To download this complete Tutorial including, all Menu's and Support files,
be brave and Click Here.
Creating Menu's - Page I.
You can write or, obtain, as many AutoLISP routines as you like, but it's still a pain in the
bum to have to type in something like :
(load "DDStruc_Steel_Ver2")
To have to type this in, or even remember the name every time you need to load or, run the routine,
is just basically daft and un-productive.
You could, load all your routines from the Acad.Lsp file. This though, would mean that they are all
in memory, chewing up your system resources.
What you need to be able to do is to load/run the routines from the AutoCAD menu. Not so long
ago, in earlier releases, the only option you had was to modify the standard AutoCAD menu. Not
anymore. Now you can create a custom menu known as a "Partial Menu" and install this to run
side by side with the standard AutoCAD menu.
This Tutorial will take you through all the steps of developing a fully, functional Custom Standard
Menu.
Note : I will only be covering Pull Down Menu's, Image Menu's and Toolbars in this tutorial. If you
need information on Screen, Button or Tablet Menu's, then please refer to the AutoCAD
Customization Manual.
To get started let's begin with designing a simple Pull Down or Pop Menu.
Fire up your text editor and type in the following saving the file as Test.Mnu :
(Please ensure that you save all files to a directory in the AutoCAD Search Path.)
***MENUGROUP=TEST //menu name
***POP1 //pull down name
P1-1[Test Menu] //pull down label
P1-2[Line] //menu items preceeded with ID
P1-3[Copy]
P1-4[Move]
P1-5[Zoom]
The first line :
***MENUGROUP=TEST
is the name of the Partial Menu.
The second line :
***POP1
is the name of the Drop Down or POP menu.
The third line consists of 2 parts :
P1-1
Creating Menu's I
http://www.afralisp.com/lispa/menu1.htm (1 of 3) [23/03/2005 05:44:36 p.m.]
This is the "Name Tag" or "ID" of the menu item and allows you to access the menu item
programmatically. The second part :
[Test-Menu]
is the menu label that appears in the Pull Down Menu.
The first label in a pull down menu always defines the menu bar title whilst, the succeeding labels
define menu and sub-menu items.
Now we need to load the menu.
If you already know how to Load and Un-Load menu files you can now load Test.mnu.
If not, click here for detailed instructions.
A new menu item will appear on the menu bar entitled "Test Menu".
It should look like this :
O.K. Now we've got our menu to display but, there's a problem. It doesn't do anything!! Let's make
it functional.
Create a new menu file entitled TEST1.MNU and type in the following:
***MENUGROUP=TEST1
***POP1
P1-1[&Test Menu1]
P1-2[&Line]^C^CLine
P1-3[&Copy]^C^CCopy
P1-4[M&ove]^C^CMove
P1-5[&Zoom]^C^CZoom
Load this menu, following the same routine as you did for the first menu.
"Test Menu1" will appear in the menu bar and your new pull down menu should look like this :
Let's have a close look at one of the menu items :
P1-2[&Line]^C^CLine
The first part, P1-1 is, of course, the menu item ID.
The second part, [&Line] is the menu label. But did you notice something different? What is the '&'
character doing in front of the 'L'?
If you precede any letter in the menu item label with '&', this will define the letter as the shortcut
Creating Menu's I
http://www.afralisp.com/lispa/menu1.htm (2 of 3) [23/03/2005 05:44:36 p.m.]
key to this menu item.
(There are other special label characters but, we will discuss these at a later stage.) In other words,
when you press 'ALT L' the Line Menu Item will be chosen and any action affiliated to it will be
triggered.
Following the item label, each menu item can consist of a command, parameter,
or a sequence of commands and parameters. Let's look at the Line menu item macro.
^C^CLine
Just in case we have a previous incomplete command, we use the string ^C^C to start our menu
macro. This is exactly the same as pressing CTRL+C or ESC, twice on the keyboard. We use ^C
twice because some AutoCAD commands need to be cancelled twice before they return to the
Command prompt.
(e.g. The Dim Command.)
We immediately follow this sequence with our AutoCAD command, Line.
When a menu item is selected, AutoCAD places a blank after it. A blank in a menu macro is
interpreted as ENTER or SPACEBAR. In effect, this is exactly the same as typing, at the command
prompt "Line" followed by ENTER.
More about Menu Macro's on the next page......
Home. Page II. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating Menu's I
http://www.afralisp.com/lispa/menu1.htm (3 of 3) [23/03/2005 05:44:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home Page III. Page IV.
Creating Menu's - Page II.
Menu Macro's
Let's look at some Special Menu Characters :
[ ] Encloses a Menu Label.
; Enter.
Space Enter or Spacebar.
\ Pauses for user input.
_ Translates AutoCAD commands.
+ Continues menu macro to next line.
*^C^C Prefix for repeating Item.
$ Character Code that loads a menu section.
^B Toggels Snap/Off.
^C Cancels command.
^D Toggles Coords.
^E Sets the next Isometric Plane.
^G Toggles Grid On/Off.
^H Issues Backspace.
^O Toggles Ortho On/Off.
^P Toggles Menuecho On/Off.
^Q Echoes all prompts.
^T Toggles Tablet On/Off.
^V Changes current Viewport.
^Z Null Character.
I don't really want to get too involved with Menu Macro's, but here is a few sample Macro's to show you
the general idea :
***MENUGROUP=TEST2
***POP1
P1-1[&Test Menu2]
P1-2[&Layer 2 On]^C^CLayer;M;2;;
P1-3[&Ortho On/Off]^C^C^O
P1-4[Change to Layer 3]*^C^CChange;\;P;LA;3;;
P1-5[&Hello World](alert "Hello World")
Your Menu should look like this :
The first Menu Item is again, the menu label.
The second item changes the current layer to layer 2.
(Layer Enter Make Enter 2 Enter Enter).
Creating Menu's II
http://www.afralisp.com/lispa/menu2.htm (1 of 2) [23/03/2005 05:44:37 p.m.]
The third item simply toggles Ortho On or Off.
The fourth item let's you select an object and changes it to layer 3.
(Change Enter Pause Enter Properties Enter Layer Enter 3 Enter Enter).
The * prefix will force the macro to repeat until the user hits CTRL-C or ESC.
The fourth item demonstrates the use of AutoLISP within a menu item.
Menu macro's can get quite long and complicated but my advice to you is, rather write an AutoLISP
routine than try and design complicated macro's.
Look at this for a macro :
[Box](setq a (getpoint "Enter First Corner: "));\ +
(setq b (getpoint "Enter Second Corner: "));\+
pline !a (list (car a)(cadr b))!b (list (car b) (cadr a))c;
Crazy, Hey. As I said, rather write an AutoLISP routine. You can do a hell of a lot more and, create a
much more professional routine using AutoLISP than you ever will trying to write super-duper, 20 line
macro's.
Just one small point about the above macro. Did you notice the use of the special character + at the end of
some of the lines. This allows the macro to continue to the next line.
Anyway, enough about menu macro's. Let's have a look at some special label characters that you can use
in pull-down menu's.
-- Item label that expands to become a separator line.
+ Continues macro to next line.
-> Label prefix that indicates that the pull-down menu item
has a submenu
<- Label prefix that indicates that the pull-down menu item
is the last item in a submenu.
<-<-.. Label prefix that indicates that the pull-down menu item
is the last item in the submenu, and terminates the parent
menu. One <- is required to each terminate each parent menu.
~ Lable prefix that disables a menu item.
!. Label prefix that marks a menu item.
& Label prefix that defines shortcut key.
On the next page we will have a look at an example menu using
some of these special characters.
Page I. Home. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating Menu's II
http://www.afralisp.com/lispa/menu2.htm (2 of 2) [23/03/2005 05:44:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II Home. Page IV.
Creating Menu's - Page III.
Before loading the following menu, you should really un-load any of the test menu's that you
still have loaded. If you don't, you just might run out of space on your menu bar.
OK, I see you're back. Now load the following menu file :
***MENUGROUP=TEST3
***POP1
P1-1[&Test Menu 3]
P1-2[&Layer 2 On]^C^CLayer;M;2;; //menu item
P1-3[--] //divider
P1-4[&Ortho On/Off]^C^C^O //menu item
P1-5[--] //divider
P1-6[->&Change] //submenu label
P1-7[->C&hange Layer] //submenu label
P1-8[Change to Layer 1]^C^CChange;\;P;LA;1;; //submenu items
P1-9[Change to Layer 2]^C^CChange;\;P;LA;2;;
P1-10[Change to Layer 3]^C^CChange;\;P;LA;3;;
P1-11[<-Change to Layer 4]^C^CChange;\;P;LA;4;; //submenu terminator
P1-12[->Ch&ange Colour] //submenu label
P1-13[Change to Colour 3]^C^CChange;\;P;C;1;; //submenu items
P1-14[Change to Colour 3]^C^CChange;\;P;C;2;;
P1-15[Change to Colour 3]^C^CChange;\;P;C;3;;
P1-16[<-<-Change to Colour 4]^C^CChange;\;P;C;4;; //submenu terminator
P1-17[--] //divider
P1-18[&Kenny](alert "Kenny is Handsome") //menu item
Your menu, hopefully, should look like this :

Right, enough of pull-downs for the meantime. Let's now have a look at Image Menu's.
Firstly, we need to create a couple of slides to display in our image menu.
Let's create some slides named D1 to D8, DDOOR and HDDOOR.
You can create these slides yourself using any object that you wish, as long as they are named as stated. (I
need the server space and drawing files are rather big.) Now we need to create a file library as a container
for these slides.
Ceating Menu's III
http://www.afralisp.com/lispa/menu3.htm (1 of 4) [23/03/2005 05:44:39 p.m.]
Locate the Slidelib.exe function. It is normally in your Acad Support directory. Copy it to the same
directory as your slides.
Now create a text file named Slidelist.LST and in it, make a list of all the slide names. (Remember to check
spelling and case.)
D1
D2
D3
D4
D5
D6
D7
D8
DDOOR
HDDOOR
Make sure that this file is also in the same directory as the slides.
Now go to DOS. (Remember that 'black' place?)
At the DOS prompt find your way to the directory where your slides, Slidelib.exe and Slidelist.LST are
located.
Type :
slidelib DOORS < Slidelist.LST then ENTER.
If you have done everything correct, DOORS.SLB should be created.
Next, we need to add an Image section to our menu file :
***MENUGROUP=TEST4
***POP1
P1_1[&Test Menu 4]
P1_2[&Layer 2 On]^C^CLayer;M;2;;
P1_3[--]
P1_4[&Ortho On/Off]^C^C^O
P1_5[--]
P1_6[->&Change]
P1_7[->C&hange Layer]
P1_8[Change to Layer 1]^C^CChange;\;P;LA;1;;
P1_9[Change to Layer 2]^C^CChange;\;P;LA;2;;
P1_10[Change to Layer 3]^C^CChange;\;P;LA;3;;
P1_11[<-Change to Layer 4]^C^CChange;\;P;LA;4;;
P1_12[->Ch&ange Colour]
P1_13[Change to Colour 3]^C^CChange;\;P;C;1;;
P1_14[Change to Colour 3]^C^CChange;\;P;C;2;;
P1_15[Change to Colour 3]^C^CChange;\;P;C;3;;
P1_16[<-<-Change to Colour 4]^C^CChange;\;P;C;4;;
P1_17[--]
P1_18[&Kenny](alert "Kenny is Handsome")
P1_19[--]
P1_20[Image Menu]^C^C$I=TEST4.DOORS $I=* //calls Image Menu
***IMAGE
**DOORS
[DOORS Created by Kenny Ramage ]
[DOORS(D1,DOOR1)]INSERT;*D1;\;;
[DOORS(D2,DOOR2)]INSERT;*D2;\;;
[DOORS(D3,DOOR3)]INSERT;*D3;\;;
[DOORS(D4,DOOR4)]INSERT;*D4;\;;
[DOORS(D5,DOOR5)]INSERT;*D5;\;;
[DOORS(D6,DOOR6)]INSERT;*D6;\;;
[DOORS(D7,DOOR7)]INSERT;*D7;\;;
[DOORS(D8,DOOR8)]INSERT;*D8;\;;
[DOORS(DDOOR,DOUBLE DOOR)]INSERT;*DDOOR;\;;
[DOORS(HDDOOR,DOOR & HALF)]INSERT;*HDDOOR;\;;
[ FITTINGS]$I=KENNY.FITTINGS $I=*
Ceating Menu's III
http://www.afralisp.com/lispa/menu3.htm (2 of 4) [23/03/2005 05:44:39 p.m.]
The first line, ***IMAGE, defines the Image section of the menu.
The second line, **DOORS, is the name of the Image section submenu.
The third line is the title of the label that appears at the top.
The following lines get a bit more complicated so, let's dissect them.
[DOORS(D1,DOOR)]INSERT;*D1;\;;
[DOORS is the name of the slide library.
(D1, is the name of the specific slide.
,DOOR1)] is the label that is displayed in the list box.
INSERT;*D1;\;; is the menu macro.
Your Pull Down menu should now look like this :
And your Image menu like this (with different images of course) :
Did you notice the method of calling the image menu?
P1_20[Image Menu]^C^C$I=TEST4.DOORS $I=*
Good, at least some one is awake ;-)
Phew...(Wipe's sweat off brow)....Time for a break.
Next we'll move on to Custom Toolbars.
See you on the next page......
Page I. Page II. Home. Page IV.

Ceating Menu's III


http://www.afralisp.com/lispa/menu3.htm (3 of 4) [23/03/2005 05:44:39 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Ceating Menu's III
http://www.afralisp.com/lispa/menu3.htm (4 of 4) [23/03/2005 05:44:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II Page III. Home.
Creating Menu's - Page IV.
Custom Toolbars
The easiest way of creating a custom toolbar is to use the AutoCAD interface.
First, copy and rename Test4.MNU to Test5.MNU. Edit the menu file so that it looks like this :
***MENUGROUP=TEST5
***POP1
P1_1[&Test Menu 5]
P1_2[&Layer 2 On]^C^CLayer;M;2;;
P1_3[--]
P1_4[&Ortho On/Off]^C^C^O
P1_5[--]
P1_6[->&Change]
P1_7[->C&hange Layer]
P1_8[Change to Layer 1]^C^CChange;\;P;LA;1;;
P1_9[Change to Layer 2]^C^CChange;\;P;LA;2;;
P1_10[Change to Layer 3]^C^CChange;\;P;LA;3;;
P1_11[<-Change to Layer 4]^C^CChange;\;P;LA;4;;
P1_12[->Ch&ange Colour]
P1_13[Change to Colour 3]^C^CChange;\;P;C;1;;
P1_14[Change to Colour 3]^C^CChange;\;P;C;2;;
P1_15[Change to Colour 3]^C^CChange;\;P;C;3;;
P1_16[<-<-Change to Colour 4]^C^CChange;\;P;C;4;;
P1_17[--]
P1_18[&Kenny](alert "Kenny is Handsome")
P1_19[--]
P1_20[Image Menu]^C^C$I=TEST4.DOORS $I=*
***IMAGE
**DOORS
[DOORS Created by Kenny Ramage ]
[DOORS(D1,DOOR1)]INSERT;*D1;\;;
[DOORS(D2,DOOR2)]INSERT;*D2;\;;
[DOORS(D3,DOOR3)]INSERT;*D3;\;;
[DOORS(D4,DOOR4)]INSERT;*D4;\;;
[DOORS(D5,DOOR5)]INSERT;*D5;\;;
[DOORS(D6,DOOR6)]INSERT;*D6;\;;
[DOORS(D7,DOOR7)]INSERT;*D7;\;;
[DOORS(D8,DOOR8)]INSERT;*D8;\;;
[DOORS(DDOOR,DOUBLE DOOR)]INSERT;*DDOOR;\;;
[DOORS(HDDOOR,DOOR & HALF)]INSERT;*HDDOOR;\;;
[ FITTINGS]$I=KENNY.FITTINGS $I=*
Open AutoCAD and load this new menu file.
Now, to create a new toolbar, follow these steps :
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (1 of 6) [23/03/2005 05:44:42 p.m.]
Right Click on any toolbar.
The Toolbars Dialogue will open.
Select "New".
The New Toolbar dialogue will open
In the "Toolbar Name" edit box enter "Testbar" and from the "Menu Group" drop down list
select Test5.mnu
Select O.K.
A small empty toolbar will appear on your screen.
Select "Customize" from the "Toolbars" dialogue.
The "Customize Toolbars" dialogue will open.
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (2 of 6) [23/03/2005 05:44:42 p.m.]
In the "Catagories" list box select "Custom".
Select the blank tile then drag and drop it onto your empty toolbar.
Repeat this so that you have 3 blank tiles on your toolbar.
Your toolbar should look like this :
Select "Close"
You now have a toolbar with 3 buttons that do exactly nothing!!
Right Click on the first blank tile.
The "Button Properties" dialogue will open.
In the "Name" edit box type "Test Tool 1".
This will appear as a tooltip.
In the "Help" edit box type "This is Test Button 1".
This will appear in the status bar.
In the "Macro Edit" edit box enter :
^C^C(Alert "Test Tool 1")
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (3 of 6) [23/03/2005 05:44:42 p.m.]
This is the action assigned to this button.
Now, from the "Button Icon" list, select the first blank tile, then "Edit".
The "Button Editor" will open.
Select "Grid" to place a grid over your button.
Using the edit tools and the colour palette, draw the image that you would like to appear on your
button.
When you are happy select "Save" then "Close".
In the "Buttons Properties" dialogue select "Apply".
You will notice your completed button appear in your toolbar.
Right Click on the second button and repeat the process, naming the button "Test Tool 2".
Then again for the third button naming it "Test Tool 3".
When you have finished and have closed all dialogue boxes, your toolbar should look something like
this :
Select any of the buttons on the toolbar and you should get an alert message.
Now Exit AutoCAD.
Open Test5.mnu
Do you notice that nothing has changed and there is no Toolbar section in the MNU file?
The reason for this is because when you Add, Move or Edit any toolbars using the AutoCAD
interface, the results are written to the MNS file and not to the MNU file. To update the MNU file
and make our changes permanent, we need to copy and paste the toolbars section from the MNS
file into the MNU file.
Right, let's do that. Your MNU file should now look like this :
***MENUGROUP=TEST5
***POP1
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (4 of 6) [23/03/2005 05:44:42 p.m.]
P1_1[&Test Menu 5]
P1_2[&Layer 2 On]^C^CLayer;M;2;;
P1_3[--]
P1_4[&Ortho On/Off]^C^C^O
P1_5[--]
P1_6[->&Change]
P1_7[->C&hange Layer]
P1_8[Change to Layer 1]^C^CChange;\;P;LA;1;;
P1_9[Change to Layer 2]^C^CChange;\;P;LA;2;;
P1_10[Change to Layer 3]^C^CChange;\;P;LA;3;;
P1_11[<-Change to Layer 4]^C^CChange;\;P;LA;4;;
P1_12[->Ch&ange Colour]
P1_13[Change to Colour 3]^C^CChange;\;P;C;1;;
P1_14[Change to Colour 3]^C^CChange;\;P;C;2;;
P1_15[Change to Colour 3]^C^CChange;\;P;C;3;;
P1_16[<-<-Change to Colour 4]^C^CChange;\;P;C;4;;
P1_17[--]
P1_18[&Kenny](alert "Kenny is Handsome")
P1_19[--]
P1_20[Image Menu]^C^C$I=TEST4.DOORS $I=*
***IMAGE
**DOORS
[DOORS Created by Kenny Ramage ]
[DOORS(D1,DOOR1)]INSERT;*D1;\;;
[DOORS(D2,DOOR2)]INSERT;*D2;\;;
[DOORS(D3,DOOR3)]INSERT;*D3;\;;
[DOORS(D4,DOOR4)]INSERT;*D4;\;;
[DOORS(D5,DOOR5)]INSERT;*D5;\;;
[DOORS(D6,DOOR6)]INSERT;*D6;\;;
[DOORS(D7,DOOR7)]INSERT;*D7;\;;
[DOORS(D8,DOOR8)]INSERT;*D8;\;;
[DOORS(DDOOR,DOUBLE DOOR)]INSERT;*DDOOR;\;;
[DOORS(HDDOOR,DOOR & HALF)]INSERT;*HDDOOR;\;;
[ FITTINGS]$I=KENNY.FITTINGS $I=*
***TOOLBARS
**TESTBAR
ID_1 [_Toolbar("Testbar", _Floating, _Show, 202, 163, 1)]
ID_2 [_Button("Test Tool 1", "ICON.bmp", "ICON_24_BLANK")]
^C^C(Alert "Test Tool 1")
ID_3 [_Button("Test Tool 2", "ICON0041.bmp", "ICON_24_BLANK")]
^C^C(Alert "Test Tool 2")
ID_4 [_Button("Test Tool 3", "ICON8467.bmp", "ICON_24_BLANK")]
^C^C(Alert "Test Tool 3")
Let's take a closer look at the toolbars section :
***TOOLBARS is, of course, the label for the start of the toolbars section. **TESTBAR is the label
for the Toolbar Subsection.
The first Toolbar definition line (ID_1) defines the characteristics of
the toolbar itself. This is made up of 6 parts :
tbarname The string that names the toolbar. ("Testbar")
orient The orientation of the toolbar. (Floating)
Acceptable values are Floating, Top, Bottom,
Left and Right.
visible The visibility of the toolbar. (Show)
Acceptable values are Show and Hide.
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (5 of 6) [23/03/2005 05:44:42 p.m.]
xval The x co-ordinate of the toolbar (202)
Measured from the left edge of the screen to the
right side of the toolbar. (in pixels)
yval The y co-ordinate of the toolbar. (163)
Measured from the top edge of the screen to the
top of the toolbar. (in pixels)
rows Number of rows in the toolbar (1)
The second and remaining Toolbar definition lines (ID_2 to ID_4) define the characteristics of the
buttons. They are each made up of 3 parts :
btnname The string that names the button. ("Test Tool 1")
id_small The name of the small image bitmap (ICON.bmp)
(16 x 16 bitmap)
id_big The name of the large image bitmap (ICON_24_BLANK)
(24 x 24 bitmap)
macro Action/Command assigned to the button.
Did you notice that a blank tile is in place of the large 24 x 24 bitmap.
The reason for this, of course, is because we never defined a large bitmap.
If I require large bitmaps I use an imaging editing package to increase the size of my existing 16 x
16 bitmap to 24 x 24 and save it as a large bitmap, adding "24" to the end of the name.
Anyway, that's about it. I hope that you managed to muddle your way through this lot and that you
will soon be writing your own partial menu's.
I don't know about you, but this is thirsty work, so I'm off for an extremely large, cold beer. (or 10).
Cheers for now.......
To download this complete Tutorial including, all Menu's and Support files,
be brave and Click Here.

Page I. Page II. Page III. Home.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating Menu's IV
http://www.afralisp.com/lispa/menu4.htm (6 of 6) [23/03/2005 05:44:42 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Loading Partial Menu's
Fire up AutoCAD and follow these instructions :

Select "Tools" "Customise Menu's" from pulldown. G


Select "Browse" G
Change file type to "Menu Template (*.MNU)" G
Open Directory where TEST.MNU resides. G
Select "TEST.MNU" then press "OK" G
Select "Load". G
Answer "Yes" when prompted. G
Click on "Menu Bar" tab. G
From "Menu Group" pulldown select "TEST". G
In the "Menu's" section, select "Test Menu". G
Press "Insert" to add it to the Menu Bar. G
Select "Close" G
Un-Loading Partial Menu's
To Un-Load Partial Menu's do the following :

Select "Tools" "Customise Menu's" from pulldown. G


In the Menu Groups list, highlight the menu that you wish to remove. G
Select "Unload". G
Select "Close". G
The menu will be removed.
Menu files can also be loaded and un-loaded programmatically.
The methods of doing this will be covered later in the tutorial.
Just a couple of comments on Loading and Un-Loading menu's.
When loading a menu file, AutoCAD compiles the .MNU file into .MNC and .MNR files. The .MNC
file is a compiled version of the .MNU file and the .MNR file contains the bitmaps used by the
menu.
AutoCAD also generates a .MNS file. This is an ASCII file that is initially the same as the .MNU file
but is modified by AutoCAD each time you make changes to the menu file through the interface.
(such as modifying the contents of a toolbar.
HINT : If you have modified a menu file and it does not display correctly, or gives you other
hassles, then delete the .MNC, .MNR and .MNS files. This forces the menu to re-compile.
Back to Tutorial.

Loading Partial Menu's


http://www.afralisp.com/lispa/menu1a.htm (1 of 2) [23/03/2005 05:44:43 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Loading Partial Menu's
http://www.afralisp.com/lispa/menu1a.htm (2 of 2) [23/03/2005 05:44:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
VBA and Sequential Text Files
Sometimes you may need to store and retrieve information but do no need the power of a
spreadsheet or database. (not to mention the extra coding, configuration and support files that go
along with it.) In these cases a text file may be just the thing you need. The process of storing and
retrieving information is simple, and the file can be edited by anyone - even if that person doesn't
have a spreadsheet/database tool.
Let's have a look first at reading from a sequential text file.
Let's say we have a text file containing a list of standard layers that we would like to import into
AutoCAD.
Here's what we would need to do :
1. Open the file for input.
2. Read a line from the file and store it in a variable.
3. Add the contents of the variable to a list box.
4. Repeat steps 2 and 3 for each line in the file.
5. Close the file.
O.K. first let's create our text file. Open Notepad and enter these layer names :
Annotations
Architectural
Beers
Border
Civil
Dimensions
Electrical
Existing
Instrumentation
Mechanical
Piping
Steel
Text
Now save this file as Layer.txt, ensuring that it is within your support path.
Now open a new Project and Userform. Place a Listbox on the form keeping the default name.
In the Userform Initialize event procedure, place the following code :
'CODING STARTS HERE
Private Sub UserForm_Initialize()
Dim sTemp As String
'clear listbox
ListBox1.Clear
'open the text file
Open "Layer.txt" For Input As #1
'until the end of file
While Not EOF(1)
'read the line and store it in a variable
VBA ans Sequential Text Files
http://www.afralisp.com/vba/extext.htm (1 of 4) [23/03/2005 05:44:45 p.m.]
Line Input #1, sTemp
'display in the list box
ListBox1.AddItem sTemp
'loop
Wend
'close the file
Close #1
End Sub
'CODING ENDS HERE

Run the Project. You Listbox should look like this :


In the preceding example, 1 is the file number. However, if you open and close multiple files
throughout your program, using this number might not be a good idea. In that case, you should use
the "FreeFile" function. I've re-written the coding below to include this function as well as some
basic error trapping :
'CODING STARTS HERE
Private Sub UserForm_Initialize()
Dim sTemp As String
Dim nFile As Integer
On Error GoTo err_handler
'get the next free file number
nFile = FreeFile
'clear listbox
ListBox1.Clear
'open the text file
Open "Layer.txt" For Input As #nFile
'until the end of file
While Not EOF(nFile)
'read the line and store it in a variable
Line Input #nFile, sTemp
'display in the list box
VBA ans Sequential Text Files
http://www.afralisp.com/vba/extext.htm (2 of 4) [23/03/2005 05:44:45 p.m.]
ListBox1.AddItem sTemp
'loop
Wend
'close the file
Close #nFile
Exit Sub
err_handler:
MsgBox Err.Number & " " & Err.Description
Err.Clear
Exit Sub
End Sub
'CODING ENDS HERE
To write data, you open the file for sequential output or append. Have a look at the following two
lines of code, each of which opens a file for output :
'output mode - always creates a new file, erases any existing information
Open "DwgLog.txt" for Output as #nFile
'append mode - adds to an existing file or creates one
Open "DwgLog.txt" for Append as #nFile
Append mode means data written to a file is added to the end of existing data. Opening a file for
Output means that any existing data will be erased. In either case the Open statement automatically
creates the file if it does not exist.
Have a look at the following coding that when you run it, will write a Log file containing the date,
time and Drawing Number :
'CODING ENDS HERE
Sub DrgLog ()
Dim nFile1 As Integer
Dim Dname As String
On Error GoTo err_handler
'retrieve the drawing name
Dname = ThisDrawing.GetVariable("DWGNAME")
'get the next free file number
nFile1 = FreeFile
'open the file to append to
Open "DrgLog.txt" For Append As #nFile1
'write to the file
Print #nFile1, Format$(Now, "mm-dd-yy hh:mm:ss") & " - " & Dname
'close the file
Close #nFile1
Exit Sub
err_handler:
MsgBox Err.Number & " " & Err.Description
Err.Clear
Exit Sub
End Sub
'CODING ENDS HERE
VBA ans Sequential Text Files
http://www.afralisp.com/vba/extext.htm (3 of 4) [23/03/2005 05:44:45 p.m.]
DrgLog.txt should have been created in your working directory. Open it and have a look. It should
look something like this :
11-02-01 09:57:20 - X3481.dwg
11-02-01 19:57:21 - X3482.dwg
11-02-01 14:40:20 - K2341.dwg
11-02-01 15:21:40 - K3418.dwg
Every time the routine is run, the date, time and Drawing Number is added to the file. (Hey, we
could make a good drawing log file out of this?)
On the next page we'll have a look at opening and searching a text file for multiple instances of
information required for a program to run.
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA ans Sequential Text Files
http://www.afralisp.com/vba/extext.htm (4 of 4) [23/03/2005 05:44:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
VBA and Sequential Text Files (Cont.)
To write a parametric routine, we need to store the parametric data for each individual object
somewhere. We could hard code it into the program. Safe and secure but difficult to maintain.
Alright then, a database or a spreadsheet. Also fine if you've got the software and know how to use
it. A text file on the other hand is simple to maintain and does not require any other type of
software or the knowledge to use and configure it.
Let's say for example we would like to write an application that parametrically draws structural
steel sections for us. We know all the names and basic dimensions of all the sections but just need to
be able to retrieve these values for our program to use.
O.K. let's set up our text file first. Open a new file in Notepad and add this :
ROLLED STEEL UNEQUAL ANGLES DATA
---------------------------------
H X W X T1 X R1 X R2
---------------------------------
*65x50x6
65.0,50.0,6.0,6.0,3.0
*65x50x8
65.0,50.0,8.0,6.0,3.0
*75x50x6
75.0,50.0,6.0,7.0,3.5
*75x50x8
75.0,50.0,8.0,7.0,3.5
*80x60x6
80.0,60.0,6.0,8.0,4.0
*80x60x8
80.0,60.0,8.0,8.0,4.0
*90x65x6
90.0,65.0,6.0,8.0,4.0
*90x65x8
90.0,65.0,8.0,8.0,4.0
*90x65x10
90.0,65.0,10.0,8.0,4.0
*100x65x8
100.0,65.0,8.0,10.0,5.0
*100x65x10
100.0,65.0,10.0,10.0,5.0
*100x75x6
100.0,75.0,6.0,10.0,5.0
*100x75x8
100.0,75.0,8.0,10.0,5.0
*100x75x10
100.0,75.0,10.0,10.0,5.0
*100x75x12
100.0,75.0,12.0,10.0,5.0
*125x75x8
125.0,75.0,8.0,11.0,5.5
*125x75x10
125.0,75.0,10.0,11.0,5.5
*125x75x12
125.0,75.0,12.0,11.0,5.5
*150x75x10
150.0,75.0,10.0,11.0,5.5
*150x75x12
150.0,75.0,12.0,11.0,5.5
VBA and Sequential Text Files II
http://www.afralisp.com/vba/extext1.htm (1 of 5) [23/03/2005 05:44:48 p.m.]
*150x75x15
150.0,75.0,15.0,11.0,5.5
*150x90x10
150.0,90.0,10.0,12.0,6.0
*150x90x12
150.0,90.0,12.0,12.0,6.0
*150x90x15
150.0,90.0,15.0,12.0,6.0
Save the file as Extext.dat.
The file basically contains two main lines of information required for each unequal angle.
The first line - *100x75x10" is the name of the angle and will be the string that appears in the list
box. The asterix "*" preceding the name, we will use as a marker for searching.
The second line - "100.0,75.0,10.0,10.0,5.0" is the information we are trying to retrieve. It is in
comma delimited format to allow us to read each item into it's appropriate variable.
Right onto the coding. Create a new Project and add a userform with two buttons, a list box and
two labels, maintaining the default names. Now add this coding :
'CODING STARTS HERE
Option Explicit
Private Sub UserForm_Initialize()
Dim sTempa As String
Dim nFilea As Integer
On Error GoTo err_handler
'setup and format the form
UserForm1.Caption = "Un-Equal Angles"
CommandButton1.Caption = "OK"
CommandButton1.Accelerator = "O"
CommandButton1.Default = False
CommandButton2.Caption = "Cancel"
CommandButton2.Accelerator = "C"
CommandButton2.Cancel = False
Label1.Caption = "www.AfraLisp.com"
Label2.Caption = "Select Size :"
'=============================================
'=============================================
'get the next free file number
nFilea = FreeFile
'clear listbox
ListBox1.Clear
'open the text file
Open "Extext.dat" For Input As #nFilea
'until the end of file
While Not EOF(nFilea)
'read the line and store it in a variable
Line Input #nFilea, sTempa
'isolate the first character and test
If Left$(sTempa, 1) = "*" Then
'remove the first character
sTempa = Right$(sTempa, (Len(sTempa) - 1))
'display the remainder in the list box
ListBox1.AddItem sTempa
'end if
End If
VBA and Sequential Text Files II
http://www.afralisp.com/vba/extext1.htm (2 of 5) [23/03/2005 05:44:48 p.m.]
'loop
Wend
'close the file
Close #nFilea
Exit Sub
err_handler:
MsgBox "Error No " & Err.Number & " - " & Err.Description
Err.Clear
Exit Sub
End Sub
'-------------------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()
Dim sTemp As String
Dim sTemp1 As String
Dim nFile As Integer
Dim sHeight As String
Dim sWidth As String
Dim sThickness As String
Dim sRadius1 As String
Dim sRadius2 As String
On Error GoTo err_handler
'hide the form
UserForm1.Hide
'get the selection from the list box
sTemp = ListBox1.Text
'get the next free file number
nFile = FreeFile
'open the text file
Open "Extext.dat" For Input As #nFile
'until the end of file
While Not EOF(nFile)
'read the line and store it in a variable
Line Input #nFile, sTemp1
'compare the selection
If sTemp1 = "*" & sTemp Then
'read the next line and retrieve the values from the text file
'storing them into their respective variables
Input #nFile, sHeight, sWidth, sThickness, sRadius1, sRadius2
'display the results
MsgBox "Dimensions for " & sTemp & vbCr & vbCr _
& sHeight & " " & sWidth & " " & sThickness & " " _
& sRadius1 & " " & sRadius2
'close the file
Close #nFile
'you have now retrieved all the values necessary to draw
'the un-equal angle.
'coding for that would go here.
'we're done, so exit
Exit Sub
VBA and Sequential Text Files II
http://www.afralisp.com/vba/extext1.htm (3 of 5) [23/03/2005 05:44:48 p.m.]
'end if
End If
'loop
Wend
'close the file
Close #nFile
Exit Sub
err_handler:
MsgBox "Error No " & Err.Number & " - " & Err.Description
Err.Clear
Exit Sub
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Private Sub CommandButton2_Click()
End
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'if the user double clicks the list box
CommandButton1_Click
End Sub
'CODING ENDS HERE
Run the program. A dialog like this should appear :
Highlight a size and select "OK" or double-click on the size. A message box should appear listing
the un-equal angles vital statistics :
VBA and Sequential Text Files II
http://www.afralisp.com/vba/extext1.htm (4 of 5) [23/03/2005 05:44:48 p.m.]
Now all you need to do is draw the un-equal angle. Hey, don't look at me, I've done enough for
today and I'm now off for a beer. Cheers!!!
Whoops, almost forgot! You probably want the source coding. Okey dokey, just click here.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Sequential Text Files II
http://www.afralisp.com/vba/extext1.htm (5 of 5) [23/03/2005 05:44:48 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA - Hiding Dialogs and Other Things
Recently, I posted an article regarding Hiding Dialogs in DCL. Well in this article, we're going to have a
look at hiding dialogs using VBA.
"But that's dead easy!" I can hear you saying.
I agree, it is pretty simple. The difficult part is what you do before and after hiding the dialog.
In the following example, we're going to write a routine that will allow us to select a line, and a line only,
from our drawing. Whilst we're going about the business of selecting the line, the dialog will disappear
from view. On completion of our selection, the dialog will magically re-appear and will display the layer
that the line is on, along with the x, y and x co-ordinates of the start and end points of the
aforementioned line.
As an added bonus, if you then change the layer or any of the lines co-ordinates from within the dialog,
the line itself will be updated in real time upon your screen. Interested? Then try this out :
For this you will need a UserForm containing 1 Label for the Listbox, 1 ListBox, 3 Buttons, two Frames
for the TextBoxes, 6 TextBoxes (3 in each Frame,) and 6 Labels for the TextBoxes. Retain all of their
default names and captions.
Option Explicit
'-----------------------------
'declare the public variables
Public theline As Object
Public AllLayers As AcadLayers
'------------------------------
Private Sub UserForm_Initialize()
Dim ctr As Integer
Dim layer As Object
'set up the controls
UserForm1.Caption = "Properties of a Line"
Label1.Caption = "Layer"
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (1 of 7) [23/03/2005 05:44:52 p.m.]
CommandButton1.Caption = "Select Line >>"
CommandButton1.Default = True
CommandButton1.Accelerator = "S"
CommandButton2.Caption = "Cancel"
CommandButton2.Cancel = True
CommandButton2.Accelerator = "C"
CommandButton3.Caption = "Ok"
CommandButton3.Accelerator = "O"
Frame1.Caption = "Start Point"
Frame2.Caption = "End Point"
Label2.Caption = "x"
Label3.Caption = "y"
Label4.Caption = "z"
Label5.Caption = "x"
Label6.Caption = "y"
Label7.Caption = "z"
'retrieve the layers collection
Set AllLayers = ThisDrawing.Layers
'populate the list box with the
'layer names
For Each layer In AllLayers
ListBox1.AddItem layer.Name
Next
'switch off the listbox and the texboxes
ListBox1.Enabled = False
ListBox1.BackColor = &HC0C0C0
TextBox1.Enabled = False
TextBox1.BackColor = &HC0C0C0
TextBox2.Enabled = False
TextBox2.BackColor = &HC0C0C0
TextBox3.Enabled = False
TextBox3.BackColor = &HC0C0C0
TextBox4.Enabled = False
TextBox4.BackColor = &HC0C0C0
TextBox5.Enabled = False
TextBox5.BackColor = &HC0C0C0
TextBox6.Enabled = False
TextBox6.BackColor = &HC0C0C0
End Sub
'----------------------------------
Private Sub CommandButton1_Click()
Dim ppoint(0 To 2) As Double
Dim spoint As Variant
Dim epoint As Variant
Dim layer As Object
Dim cnt As Integer
'set up the error trap
On Error GoTo ErrorTrap
'switch on the listbox and the textboxes
ListBox1.Enabled = True
ListBox1.BackColor = &H80000005
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (2 of 7) [23/03/2005 05:44:52 p.m.]
TextBox1.Enabled = True
TextBox1.BackColor = &H80000005
TextBox2.Enabled = True
TextBox2.BackColor = &H80000005
TextBox3.Enabled = True
TextBox3.BackColor = &H80000005
TextBox4.Enabled = True
TextBox4.BackColor = &H80000005
TextBox5.Enabled = True
TextBox5.BackColor = &H80000005
TextBox6.Enabled = True
TextBox6.BackColor = &H80000005
'******************************
'This is the part you've been
'waiting for.
'Hide the dialog
Me.Hide
'difficult hey??
'******************************
'select the line object
ThisDrawing.Utility.GetEntity theline, ppoint, vbCr & _
"Please Select a Line: "
'check if it's a line
If theline.EntityType <> acLine Then
Missed:

'it's not a line - inform the user
MsgBox "This is not a bloody line!!", _
vbExclamation + vbOKOnly

Else
'It is a line so we can continue.
'First get the start and end points.
With theline
spoint = .StartPoint
epoint = .EndPoint
End With
'set the counter to zero
cnt = 0
'find out which layer the line is on, and
'then set the listbox index
For Each layer In AllLayers
If theline.layer = layer.Name Then
ListBox1.ListIndex = cnt
Else
cnt = cnt + 1
End If
Next
'populate the textboxes with the start and end points
TextBox1.Text = Format(spoint(0), "0.00")
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (3 of 7) [23/03/2005 05:44:52 p.m.]
TextBox2.Text = Format(spoint(1), "0.00")
TextBox3.Text = Format(spoint(2), "0.00")
TextBox4.Text = Format(epoint(0), "0.00")
TextBox5.Text = Format(epoint(1), "0.00")
TextBox6.Text = Format(epoint(2), "0.00")
End If
GoThere:
'******************************
'And to unhide the dialog......
'redisplay the dialog
Me.Show
'Also very difficult!!!
'******************************

Exit Sub
'define the error trap
ErrorTrap:
Select Case Err
'if the user missed!!!
Case -2147352567

'let them try again
Resume Missed

'if there is another problem
Case Else

'tell the user what it is
MsgBox "There was an error " _
& Err.Number & ":" & _
Err.Description, vbCritical
Resume GoThere
Resume
End Select

End Sub
'---------------------------------
Private Sub CommandButton2_Click()
End
End Sub
'---------------------------------
Private Sub CommandButton3_Click()
End
End Sub
'---------------------------------
Private Sub ListBox1_Change()
'change the line to the layer selected
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (4 of 7) [23/03/2005 05:44:52 p.m.]
theline.layer = ListBox1.Value
'update the line
theline.Update
End Sub
'-----------------------------------
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'change the line to the layer selected
theline.layer = ListBox1.Value
'update the line
theline.Update
End Sub
'------------------------------
Private Sub TextBox1_Change()
Dim thestartx As Variant
'get the start/end point of the line
thestartx = theline.StartPoint
'substitute the new co-ordinate
thestartx(0) = TextBox1.Text
'insert the new start/endpoint
theline.StartPoint = thestartx
'update the line
theline.Update
End Sub
'----------------------------
Private Sub TextBox2_Change()
Dim thestarty As Variant
thestarty = theline.StartPoint
thestarty(1) = TextBox2.Text
theline.StartPoint = thestarty
theline.Update
End Sub
'-----------------------------
Private Sub TextBox3_Change()
Dim thestartz As Variant
thestartz = theline.StartPoint
thestartz(2) = TextBox3.Text
theline.StartPoint = thestartz
theline.Update
End Sub
'-----------------------------
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (5 of 7) [23/03/2005 05:44:52 p.m.]
Private Sub TextBox4_Change()
Dim theendx As Variant
theendx = theline.EndPoint
theendx(0) = TextBox4.Text
theline.EndPoint = theendx
theline.Update
End Sub
'-----------------------------
Private Sub TextBox5_Change()
Dim theendy As Variant
theendy = theline.EndPoint
theendy(1) = TextBox5.Text
theline.EndPoint = theendy
theline.Update
End Sub
'-----------------------------
Private Sub TextBox6_Change()
Dim theendz As Variant
theendz = theline.EndPoint
theendz(2) = TextBox6.Text
theline.EndPoint = theendz
theline.Update
End Sub
'------------------------------
Of course, you will also need something to run your program with. Insert a new module and add this :
Public Sub HideDialog()
UserForm1.Show
End Sub
Load and run the program. A dialog will appear with a ListBox containing all the Layers within your
drawing. You will find that none of the controls work with the exception of the Buttons. Press the
"Select Line >>" button and the dialog will be hidden. Now, choose any line within your drawing. If you
miss the line, or select an object that is not a line, a message box will appear informing you that you've
messed up. Don't worry, the program will let you try again. Once you've mastered the art of selecting a
line, the dialog will re-appear. The ListBox will now show you what layer your line is on, along with the
x, y and z co-ordinates of the lines Start and End points.
Choose a different Layer in the ListBox. Notice how the line is immediately change to the new Layer?
Now change one of the x or y co-ordinates. Again, the line is immediately updated and "moved" to the
new set of co-ordinates. (Oh, by the way, no validation is performed on the values entered into the x, y
and z co-ordinate TextBoxes. If you enter anything other than a number, I've a sneaky suspicion that the
program may crash.)
Play with it, have fun..........
Here's the source coding for all you lazy ones out there - Vba-Hide.zip (26 kb)

VBA - Hiding Dialogs and Other Things.


http://www.afralisp.com/vba/vba-hide.htm (6 of 7) [23/03/2005 05:44:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA - Hiding Dialogs and Other Things.
http://www.afralisp.com/vba/vba-hide.htm (7 of 7) [23/03/2005 05:44:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Hiding Dialog Boxes in DCL
Ladies and Gentlemen "WASSUP"
Hee, hee - I've always wanted to do that.
Probably the most vexing (on my part) query I get, is in regards to hiding dialog boxes.
It seems to take ages and numerous emails before the poor soul trying to grasp the concept finally
understands the principle, or (and this is more likely) gives up and joins a monastery/nunnery.
So, without further due, and absolutely no regard for my own safety, I'm going to have another shot at
explaining how to go about hiding such a wee delicate thing as a dialog box.
Okay, are you ready? Are you sat nice and comfy on your cuddly, wuddly little bottom?
The let's do it!!!
("Randall, could you please keep the noise down 'cos I'm trying to explain something here. What?
You're eating!! Try and use a knife and and fork - I know it's chicken and you're allowed to use your
fingers, but you're supposed to cook the thing and remove the feathers first.")
On to the more serious bit............
Often you need to make a selection on the screen whilst a dialog box is active. But to do this, you need
to be able to hide the dialog box to allow the user to make a selection from the screen. You must then
restore the dialog box, along with the values that the user has selected. To accomplish this lets first
have a look at two of the most critical DCL functions :
(done_dialog [status])
status : A positive integer that (start_dialog) will return instead of returning 1 for OK or 0 for
Cancel. The meaning of any status value greater than 1 is determined by your application.
G
Usage Notes : An explicit AutoLisp action for the "accept" button must specify a status of 1 (or an
application-defined value); otherwise, (start_dialog) returns the default value, 0, which makes it
appear as if the dialog box was canceled.
G
(start_dialog)
Return Values : The (start_dialog) function returns the optional status passed to (done_dialog).
The default value is 1 if the user presses OK, 0 if the user presses Cancel, or -1 if all dialog boxes
are terminated with (term_dialog). If (done_dialog) is passed an integer status greater than 1,
(start_dialog) returns this value, whose meaning is determined by the application.
G
What the heck does all this mean????
When you want to close a dialog, you call the (done_dialog) function.
But did you know that when you call the (done_dialog) function a status argument is returned? Well it's
true!!!
Now think about this. When (done_dialog) is called from a tile who's key is 'cancel' (the Cancel button),
it returns a status of 0.
If a tile who's key is 'accept' is chosen (the OK button), it will return a status value of 1.
Note carefully, YOU must define a status of 1.
Now here's the important bit, if you use the (done_dialog) function along with a status value of say 4,
you know that the dialog box has been hidden and not ended or cancelled.
But how do I retrieve that status value?
Easy, when you call (start_dialog), it returns the (done_dialog) status value.
(setq flag (start_dialogue))
By testing this value in a (while) loop we can determine whether the dialog was simply hidden or
accepted or cancelled. Below is a sample routine that should, hopefully, I hope and pray, explain it to
you a lot better.
This routine simply displays a dialog box with three buttons
If you select "OK" or "Cancel", an alert box is displayed and the dialog is simply closed.
But, if you click the "Select Object" button, the dialog is hidden and an alert box is displayed informing
you of the fact. After selecting OK, the dialog is re-displayed or, to use the words of a great magician
that I once knew, un-hidden.
CAD Encoding - Hiding Dialog Boxes in DCL - Page I
http://www.afralisp.com/lisp/hide1.htm (1 of 4) [23/03/2005 05:44:53 p.m.]
First the DCL Coding :

hidedialog1 : dialog {
label = "Hide Dialogue";
: button {
label = "Hide Dialog >>";
key = "hide";
width = 8;
fixed_width = true;
mnemonic = "H";
alignment = centered;
is_default = true;
}
: spacer { width = 1;}
ok_cancel;
}
Save this as "HideDialog1.DCL
And now the AutoLisp coding. Save this as "HideDialog1.LSP :

(defun c:hidedialog1 ( / dcl_id flag)


;set flag to 4
(setq flag 4)
;load the DCL file
(setq dcl_id (load_dialog "hidedialog1.dcl"))

;check the flag status and carry on looping
;if it is greater than 2
(while (> flag 2)

;load the dialog box
(if (not (new_dialog "hidedialog1" dcl_id))

;if not loaded exit
(exit))
;Note: I have explicitly defined the status
;return value for the "cancel" "accept" and "hide"
;tiles. I recommend you do the same.
;if Cancel button selected, close
;the dialog. This action sets the
;flag to 0.
CAD Encoding - Hiding Dialog Boxes in DCL - Page I
http://www.afralisp.com/lisp/hide1.htm (2 of 4) [23/03/2005 05:44:53 p.m.]
(action_tile "cancel" "(done_dialog 0)")
;if OK button was selected, close
; the dialog. This action
;sets the flag to 1.
(action_tile "accept" "(done_dialog 1)")

;if pick button selected, hide the dialog
;and set the flag to 4
(action_tile "hide" "(done_dialog 4)")
;start the dialog and set flag
;to value of start dialog
(setq flag (start_dialog))
;if the OK button was selected
(if (= flag 1) (alert "You chose the OK button"))
;if the Cancel button was selected
(if (= flag 0) (alert "You chose the Cancel button"))
;if the pick button was selected
(if (= flag 4) (alert "You chose the Hide Dialog button"))
);while
;unload the dialog
(unload_dialog dcl_id)
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
Let's now get really brave and have a look at a wee practical example.......................
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
CAD Encoding - Hiding Dialog Boxes in DCL - Page I
http://www.afralisp.com/lisp/hide1.htm (3 of 4) [23/03/2005 05:44:53 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
CAD Encoding - Hiding Dialog Boxes in DCL - Page I
http://www.afralisp.com/lisp/hide1.htm (4 of 4) [23/03/2005 05:44:53 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Hiding Dialog Boxes in DCL - Page II
We will now attempt to design a dialog box that will displays certain properties of a selected entity. We
would like the dialog to display first, and then hide itself whilst we go about making up our mind which
object we want to select. Once selected, the dialog will be updated with the objects property values. We
also want to be able to continue selecting objects which means that the dialog must update after each
selection.
Okay, let's give it a go.
First the DCL Coding :

hidedialog : dialog {
label = "Hide Dialogue";
: list_box {
label = "&Properties :";
key = "selections";
height = 7;
width = 25;
}
: button {
label = "Select Object >>";
key = "hide";
width = 8;
fixed_width = true;
mnemonic = "S";
alignment = centered;
is_default = true;
}
: spacer { width = 1;}
ok_cancel;
}
Save this as "HideDialog.DCL
CAD Encoding - Hiding Dialog Boxes in DCL - Page II
http://www.afralisp.com/lisp/hide2.htm (1 of 4) [23/03/2005 05:44:55 p.m.]
And now the AutoLisp coding. Save this as "HideDialog.LSP :

(defun c:hidedialog ( / dcl_id thelist lay col ltp lwt flag)


(vl-load-com)
;set up default list box values
(setq thelist '("Layer = NULL" "Color = NULL"
"Linetype = NULL" "Lineweight = NULL"))
;set flag to 4
(setq flag 4)
;load the DCL file
(setq dcl_id (load_dialog "hidedialog.dcl"))

;check the flag status and carry on looping
;if it is greater than 2
(while (> flag 2)

;load the dialog box
(if (not (new_dialog "hidedialog" dcl_id))

;if not loaded exit
(exit))
;populate the list box with the values
;in thelist
(start_list "selections")
(mapcar 'add_list thelist)
(end_list)
;if Cancel button selected, close
;the dialog. This action sets the
;flag to 0.
(action_tile "cancel" "(done_dialog 0)")
;if OK button was selected, close
; the dialog. This action
;sets the flag to 1.
(action_tile "accept" "(done_dialog 1)")

;if pick button selected, hide the dialog
;and set the flag to 4
(action_tile "hide" "(done_dialog 4)")
;start the dialog and set flag
;to value of start dialog
(setq flag (start_dialog))
;if the OK button was selected
(if (= flag 1) (alert "You chose the OK button"))
;if the Cancel button was selected
(if (= flag 0) (alert "You chose the Cancel button"))
;if the pick button was selected
CAD Encoding - Hiding Dialog Boxes in DCL - Page II
http://www.afralisp.com/lisp/hide2.htm (2 of 4) [23/03/2005 05:44:55 p.m.]
(if (= flag 4)
;do the following
(progn
;select the object
(setq ent (entsel))
;convert to vl object
(setq ent (vlax-Ename->Vla-Object (car ent)))
;get the properties and place them in a list
;the layer first
(setq lay (strcat "Layer = "
(vla-get-layer ent))
;then the color
col (strcat "Color = "
(itoa (vla-get-color ent)))
;next the linetype
ltp (strcat "Linetype = "
(vla-get-linetype ent))
;finally the lineweight
lwt (strcat "Lineweight = "
(itoa (vla-get-lineweight ent)))
;create the list
thelist (list lay col ltp lwt)
);setq
);progn
);if
);while
;unload the dialog
(unload_dialog dcl_id)
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
Hey just think! You can now design your own properties dialog.
Well that's about it regarding hiding dialog boxes.
I hope you had a good time, enjoyed the snacks (especially the chicken) and didn't drink too much beer.
Remember, don't drink and drive because you might spill some.
Did I forget? No I didn't. If you would like to download the source coding, just click here.
Home Page I
CAD Encoding - Hiding Dialog Boxes in DCL - Page II
http://www.afralisp.com/lisp/hide2.htm (3 of 4) [23/03/2005 05:44:55 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
CAD Encoding - Hiding Dialog Boxes in DCL - Page II
http://www.afralisp.com/lisp/hide2.htm (4 of 4) [23/03/2005 05:44:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
PolyLines and Arcs
by Scott McGlynn
As we are all well aware, the bulge is defined as :
So, rearranging the equation :
Ok. Now we have the included angle for the Arc.
From trigonometry, we know that Arc Length is defined as:
So all we have to do is figure out the Radius.
We can determine that using 2 pieces of information, of the chord length, and the included angle as shown in Figure
1.
PolyLines and Arcs
http://www.afralisp.com/lisp/polyarc.htm (1 of 5) [23/03/2005 05:45:00 p.m.]
The Chord length can be calculated as the straightline distance between two points. We have a function defined called
"Calculate3Ddistance" that does just that :
Passing in the 2 points, we get back the full chord length. Divide by 2 and we have the short leg of the triangle above (y).
We can calculate the Hypotenuse which is also the radius using f, and the short leg using the following formula :
However,
PolyLines and Arcs
http://www.afralisp.com/lisp/polyarc.htm (2 of 5) [23/03/2005 05:45:00 p.m.]
so we can simplify this formula to :
Unfortunately, the Cosecant function is not defined in VB, so we are left with the 1/sin version.
Tying all of this together, we have a function called "CalculatePolylineLength" We pass the function an entity. We test to
ensure it is a Polyline, then proceed to the actual work.
First, we get the upper and lower bounds of the coords variant. Then begin a For Next loop to loop through each set of 2D
coordinates. Because the "GetBulge" method of the polyline object returns the bulge for a segment, and there are the
number of segments as thare are coordinates (2 coordinates per point), we get the bulge of the loop counter/2 instead of
the loopcounter.
We then get the coordinates of the first point, x1 & y1, then the coordinates of the second point x2 & y2. Depending on
the value of the bulge, we either call the "Calculate3D Distance" or "CalculateArcLength" keeping a running total of the
lengths.
PolyLines and Arcs
http://www.afralisp.com/lisp/polyarc.htm (3 of 5) [23/03/2005 05:45:00 p.m.]

PolyLines and Arcs


http://www.afralisp.com/lisp/polyarc.htm (4 of 5) [23/03/2005 05:45:00 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PolyLines and Arcs
http://www.afralisp.com/lisp/polyarc.htm (5 of 5) [23/03/2005 05:45:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Polyline Bulges
By Stig Madsen, 2003
Bulges are something that women have (mostly to please the opposite sex it seems) and something that guys try to get by
placing socks in strategic places. At least until they get older. Which is the time they tend to develop bulges in not so strategic
places. In other words: bulges are all about curvature.
In AutoCAD, bulges are used in shapes and in arc segments of polylines. This article only deals with polyline bulges, and
because polyline bulges are describing circular arcs, let's first look at the geometry of a circular arc.
Because a circular arc describes a portion of the circumference of a circle, it has all the attributes of a circle:
Radius (r) is the same as in the circle the arc is a portion of. G
Center point (P) is also the same as in the circle. G
Included angle (&theta;). In a circle, this angle is 360 degrees. G
Arc length (le). The arc length is equal to the perimeter in a full circle. G
Adding to these attributes are some that are specific for an arc:
Start point and end point (P1 and P2) a.k.a. vertices (although sometimes it is practical to talk about specific points that a
circle passes through, there are no distinct vertices on the circumference of a circle).
G
Chord length (c). An infinite amount of chords can be described by both circles and arcs, but for an arc there is only one
distinct chord that passes through its vertices (for a circle, there is only one distinct chord that passes through the
center, the diameter, but it doesn't describe any specific vertices).
G
Given two fixed vertices, there is also a specific midpoint (P3) of an arc. G
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (1 of 8) [23/03/2005 05:45:05 p.m.]
The apothem (a). This line starts at the center and is perpendicular to the chord. G
The sagitta (s) a.k.a. height of the arc. This line is drawn from the midpoint of an arc and perpendicular to its chord. G
Except for the arc itself, an arc can describe two distinct geometric forms: Circular segment and circular sector. Both figures
includes all of the attributes above, but for doing calculations with bulges, we'll mostly use the piece of pie that the arc cuts out
of a circle, the circular sector.
So, what is a bulge for a circular arc and how is it defined? In AutoCAD's online help reference, it says about bulges for
polylines:
The bulge is the tangent of 1/4 of the included angle for the arc between the selected vertex and the next vertex in the polyline's
vertex list. A negative bulge value indicates that the arc goes clockwise from the selected vertex to the next vertex. A bulge of 0
indicates a straight segment, and a bulge of 1 is a semicircle.
What does this mean and how can an arc be defined without even knowing the radius - or at least a chord length? It says that
the only information given for arc segments in polylines are two vertices and a bulge.
Well, it also says that the bulge has something to do with the tangent of a quarter of the included angle of an arc. That must be
a clue of how to obtain the angle. In fact, once you have a bulge value, you can very quickly retrieve the included angle by
inverting the above statement. Simply use the built-in function ATAN to get an angle and multiply it by 4 in order to get the
included angle:
(* 4.0 (atan 0.57735))
2.09439
So, a bulge of 0.57735 is describing an included angle of 2.09439 radians (which is 120.0 degrees, by the way). Try it out for yourself. Start
drawing a lightweight polyline, type "A" for arc, then "A" again for Angle and "120.0" for the included angle. Drop the endpoint somewhere,
leave the polyline command and type this at the command line:
Command: (setq ent (entget (entlast)))
((-1 . < Entity name: 7ef844f8>) (0 . "LWPOLYLINE") (330 . < Entity name:
7ef5ccf8>) (5 . "31F") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0")
(100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10
-566.044 916.408) (40 . 0.0) (41 . 0.0) (42 . 0.57735) (10 -485.424 1075.7) (40
. 0.0) (41 . 0.0) (42 . -7.40144) (210 0.0 0.0 1.0))
Command: (setq bulge (cdr (assoc 42 ent)))
0.57735
Now you have a bulge value for the arc segment in the polyline, and you can try out the formula above.
Ok, fine. But why is the bulge 1/4 of the included angle and where does the tangent fit in? There are many ways to explain this. One is shown
below. The figures show a circle with a central angle describing an arc and we'll try to show that the yellow angles &epsilon; and &sigma; are
exactly one quarter of the cyan central angle &theta;.
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (2 of 8) [23/03/2005 05:45:05 p.m.]
If the full angle is cut in half - as shown with the blue angle &eta; at figure 2 - we get an isosceles triangle (green) where the angles &phi; and
&tau; are equal. Because the sum of angles in a triangle is always 180 degrees, we now know that the angles &phi; and &tau; are
= = (180 - /2)/2 => = 90 - /4
Now look at the chord from P1 to P2 in figure 3. Together with the red legs of angle &theta; it also forms an isosceles triangle, and therefore
&gamma; is equal to &xi;. The top angle is the full angle of &theta;, so &gamma; and &xi; become equal to
= = (180 - )/2 => = 90 - /2
Thus, the yellow angle &epsilon; must be the magenta angle &phi; minus the orange angle &gamma;. In other words, &epsilon; is a quarter of
the included angle &theta;:
= (90 - /4) - (90 - /2) => = /2 - /4 = /4
The bulge is describing how much the arc "bulges out" from the vertices, i.e. the height of the arc (the sagitta (s), or the distance P3 to P4 in
figure 4). The height forms a leg of a right-angled triangle that has an exact angle of 1/4 of the included angle (see the yellow triangle P-P2-P3
in figure 4) and because tangent is describing the ratio between the legs in a right-angled triangle, it's easy to describe the geometry with this
one angle:
sin /cos = tan
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (3 of 8) [23/03/2005 05:45:05 p.m.]
We could also find tangent of angle &epsilon; by simply dividing the opposite leg with the adjacant leg - which means the sagitta, s, divided by
half the distance of the chord, c, - but not knowing s and having the tangent of &epsilon; already, we would rather want to find s:
s = c/2 * tan()
Given that bulge = tan(&epsilon;), we get
s = c/2 * bulge
Radius of the arc can now be found with this formula:
r = ((c/2)
2
+s
2
)/2*s
The sign of a particular bulge is important for the way it's defined in relation to the vertices. If a bulge is positive it means that the arc is
measured counterclockwise from the starting vertex to the end vertex. If a bulge is negative it means that the arc runs the other way round, -
it's measured clockwise. The system variable ANGDIR has no influence on this.
Therefore all the formulas above has to be concerned about the absolute value of the bulge instead of the actual value - or you might end up
with a negative radius. In the code below we will find the center point. There are many ways to do this, but the method that is chosen here
relies on the angles that were defined previously. Subsequently, we will need it to test whether the bulge is postive or negative and act
accordingly.
Remember that the orange angle &gamma; in fig. 3 was found to be 90 degrees minus half of the included angle? What happens if we add (or
subtract, depending on the arc direction) this angle to the angle between the two known vertices P1 and P2? We get the angle towards the
center. Knowing the angle, the radius and the start point of the arc we can find the center point with POLAR.
(setq gamma (/ (- pi theta) 2.0)
phi (if (>= bulge 0)
(+ (angle p1 p2) gamma)
(- (angle p1 p2) gamma)
)
p (polar p1 phi r)
)
Another way to find the direction towards the center is to use good old Pythagorus. We already know radius and the chord length, so by using
radius as the hypothenuse and half the chord length as a leg in a right-angled triangle, where the apothem is the second leg, it's possible to
draw the apothem and find the center point.
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (4 of 8) [23/03/2005 05:45:05 p.m.]
(setq c|2 (/ c 2.0))
(setq a (sqrt (- (expt r 2.0) (expt c|2 2.0)))
midp (polar p1 (angle p1 p2) c|2)
p2 (if (>= bulge 0)
(polar midp (+ (angle p1 p2) (/ pi 2.0)) a)
(polar midp (- (angle p1 p2) (/ pi 2.0)) a)
)
)
By now, enough angles and distances are known to also use other trigonometric functions in order to find the center point without using
POLAR, but that has to remain a home assignment for now. Let's get some code up'n'running, utilizing the formulas and methods we just
went over. Later we will repeat some of the formulas to use with bulges.
First function will be an ordinary pick-a-polyline function. It contains no magic. The user is merely asked to pick a lightweight polyline and, if
successful, it returns a list of all segments on the form (vertex1 bulge vertex2). These segments will later be used to analyze each arc segment in
the polyline. Although it only accepts lightweight polylines, there's nothing to prevent you from adjusting it to also accept old-style polylines.
(defun getPolySegs (/ ent entl p1 pt bulge seg ptlst)
(setvar "ERRNO" 0)
;; repeat request for polyline until user either picks
;; a polyline or exits without picking
(while (and (not ent) (/= (getvar "ERRNO") 52))
(if (and (setq ent (car (entsel "\nSelect polyline: ")))
(/= (cdr (assoc 0 (setq entl (entget ent)))) "LWPOLYLINE")
)
(setq ent nil)
)
)
(cond (ent
;; save start point if polyline is closed
(if (= (logand (cdr (assoc 70 entl)) 1) 1)
(setq p1 (cdr (assoc 10 entl)))
)
;; run thru entity list to collect list of segments
(while (setq entl (member (assoc 10 entl) entl))
;; if segment then add to list
(if (and pt bulge)
(setq seg (list pt bulge))
)
;; save next point and bulge
(setq pt (cdr (assoc 10 entl))
bulge (cdr (assoc 42 entl))
)
;; if segment is build then add last point to segment
;; and add segment to list
(if seg
(setq seg (append seg (list pt))
ptlst (cons seg ptlst))
)
;; reduce list and clear temporary segment
(setq entl (cdr entl)
seg nil
)
)
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (5 of 8) [23/03/2005 05:45:05 p.m.]
)
)
;; if polyline is closed then add closing segment to list
(if p1 (setq ptlst (cons (list pt bulge p1) ptlst)))
;; reverse and return list of segments
(reverse ptlst)
)
Next function will be our workhorse. It will use everything we now know about retrieving included angle, height of arc, chord length, radius
and center point.
The function accepts a list of arguments on the form that corresponds to the segment sublists from the previous function - (vertex1 bulge
vertex2). If the argument is acceptable, it will print out information about the arc segment. We'll let the comments in the code take over any
further explanation.
(defun getArcInfo (segment / a p1 bulge p2 c c|2 gamma midp p phi r r2 s theta)
;; assign variables to values in argument
(mapcar 'set '(p1 bulge p2) segment)
;; find included angle
;; remember that bulge is negative if drawn clockwise
(setq theta (* 4.0 (atan (abs bulge))))
;; output included angle
(princ (strcat "\n Included angle: "
(rtos theta)
" rad ("
(angtos theta 0)
" degrees)"
)
)
;; find height of the arc
(setq c (distance p1 p2)
s (* (/ c 2.0) (abs bulge))
)
;; output height of arc
(princ (strcat "\n Height of arc: " (rtos s)))
;; output chord length
(princ (strcat "\n Chord length: " (rtos c)))
;; If this function is used without making sure that the segment
;; is not simply a line segment (bulge = 0.0), it will produce
;; a division-by-zero error in the following. Therefore we want
;; to be sure that it doesn't process line segments.
(cond ((not (equal bulge 0.0 1E-6))
;; find radius of arc
;; first find half the chord length
(setq c|2 (/ c 2.0)
;; find radius with Pythagoras (used as output)
r (/ (+ (expt c|2 2.0) (expt s 2.0)) (* s 2.0))
;; find radius with trigonometry
r2 (/ c|2 (sin (/ theta 2.0)))
)
(princ (strcat "\n Radius of arc: " (rtos r)))
;; find center point of arc with angle arithmetic
;; (used as output)
(setq gamma (/ (- pi theta) 2.0)
phi (if (>= bulge 0)
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (6 of 8) [23/03/2005 05:45:05 p.m.]
(+ (angle p1 p2) gamma)
(- (angle p1 p2) gamma)
)
p (polar p1 phi r)
)
;; find center point of arc with Pythagoras
(setq a (sqrt (- (expt r 2.0) (expt c|2 2.0)))
midp (polar p1 (angle p1 p2) c|2)
p2 (if (>= bulge 0)
(polar midp (+ (angle p1 p2) (/ pi 2.0)) a)
(polar midp (- (angle p1 p2) (/ pi 2.0)) a)
)
)
;; output coordinates of center point
(princ (strcat "\n Center of arc: "
(rtos (car p))
","
(rtos (cadr p))
)
)
)
(T (princ "\n Segment has no arc info"))
)
(princ)
)
To try out these two functions, first draw a lightweight polyline with a couple of arc segments. At the command line, call getPolysegs and assign
a variable to the returned list:
Command: (setq myPoly (getPolySegs))
Select polyline: [select a polyline]
If a lightweight polyline was selected, it will return a list of segments. If, for example, the second segment contains a bulge value different from
0.0 then you can call the latter function like this:
Command: (getArcInfo (nth 1 myPoly))
Included angle: 1.9265 rad (110.3830 degrees)
Height of arc: 855.2904
Chord length: 3272.6317
Radius of arc: 1992.9203
Center of arc: 34915.2223,21409.8733
The last function in this article will bind the two functions together and explore each arc segment in the selected polyline. It will appear in part
two - along with some useful formulas for dealing with bulges.
Page II

Polyline Bulges Page I


http://www.afralisp.com/lisp/Bulges1.htm (7 of 8) [23/03/2005 05:45:05 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Polyline Bulges Page I
http://www.afralisp.com/lisp/Bulges1.htm (8 of 8) [23/03/2005 05:45:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
PolyLines and Blocks.
PolyLines and Blocks!!! Come back... Don't run away....
Honestly, they are a lot easier to deal with than you think.
I know that they are called "complex entities", but the only difference between them and other
entities is that we just have to dig a bit deeper to get to what we want. In fact, once we get there I'll
show you a couple of things that you swear is magic. So bear with me, take your time, and hang on
for a ride on the magic carpet.......
PolyLines.
The lwpolyline entity, or "optimized polyline," is new to Release 14.
A lwpolyline is defined in the drawing database as a single graphic entity.
This is different than a standard polyline, which is defined as a group of subentities. Lwpolylines
display faster and consume less disk space and RAM.
In Release 14, 3D polylines are always created as standard polyline entities.
2D polylines are created as lwpolyline entities unless they have been curved or fitted with the PEDIT
command. When a drawing from a previous release is opened in Release 14, all 2D polylines convert
to lwpolylines automatically unless they have been curved or fitted or contain xdata.
We will have a look at the R13 and below Polyline first.
First of all draw 3 joined polylines. (3DPoly if you are using R14).
Then type this :
Command: (setq e (entget (car (entsel))))
AutoLisp should return something like this :
Select object: ((-1 . ) (0 . "POLYLINE") (5 . "27B") (100
. "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDb3dPolyline") (66 . 1) (10 0.0
0.0 0.0) (70 . 8) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73
. 0) (74 . 0) (75 . 0))
Hey, wait a minute!!!......AutoLisp has returned the entity list, and I can see that it's a Polyline, but there are no
co-ordinates, and where does AutoLisp get the co-ordinates for all the vertices?
As I said earlier, we need to dig a little bit deeper to get the information we require. This is where the (entnext)
function comes into play.
Now type the following 5 code segments :
Command: (setq e1 (entget (entnext (cdr (car e)))))
((-1 . ) (0 . "VERTEX") (5 . "27C") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbVertex") (100 . "AcDb3dPolylineVertex") (10
391.774 521.633 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 32) (50 . 0.0) (71
. 0) (72 . 0) (73 . 0) (74 . 0))
Command: (setq e2 (entget (entnext (cdr (car e1)))))
((-1 . ) (0 . "VERTEX") (5 . "27D") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbVertex") (100 . "AcDb3dPolylineVertex") (10
758.971 383.418 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 32) (50 . 0.0) (71
. 0) (72 . 0) (73 . 0) (74 . 0))
Command: (setq e3 (entget (entnext (cdr (car e2)))))
((-1 . ) (0 . "VERTEX") (5 . "27E") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbVertex") (100 . "AcDb3dPolylineVertex") (10
257.549 377.344 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 32) (50 . 0.0) (71
. 0) (72 . 0) (73 . 0) (74 . 0))
Command: (setq e4 (entget (entnext (cdr (car e3)))))
((-1 . ) (0 . "VERTEX") (5 . "27F") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbVertex") (100 . "AcDb3dPolylineVertex") (10
PolyLines and Blocks Page I
http://www.afralisp.com/lispa/lisp20.htm (1 of 5) [23/03/2005 05:45:06 p.m.]
391.774 521.633 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 32) (50 . 0.0) (71
. 0) (72 . 0) (73 . 0) (74 . 0))
Command: (setq e5 (entget (entnext (cdr (car e4)))))
((-1 . ) (0 . "SEQEND") (5 . "280") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (-2 . ))
The (cdr (car e)) returns the entity name of entity list e. Each code segment then uses the (entnext entity name)
of the entity that precedes it.
Take note of the entity type of each variable :
e (0 . "POLYLINE")
e1 (0 . "VERTEX")
e2 (0 . "VERTEX")
e3 (0 . "VERTEX")
e4 (0 . "VERTEX")
e5 (0 . "SEQEND")
Do you see that a 3 line Polyline consists of a master or, parent list, 4 vertex and an end-of sequence
("SEQEND") list.
To extract the entitity list for each vertex is therefore, quite easy. We just need to loop through the sequence of
vertices until we reach the SEQEND list.
Here's an example of a function that will print the coordinates for each vertex of a Polyline :
(defun c:coord ( / e r)
(setq e (entget (car (entsel))))
;get the parent entity list
(setq r 1)
;set loop control number to 1
(while r
;while loop control is not nil, carry on looping
(setq e (entget (entnext (cdr (car e)))))
;get the vertex entity list
(if (/= (cdr (assoc 0 e)) "SEQEND")
;if it is not "end-of-sequence
(progn
;do the following
(terpri)
;new line
(princ (cdr (assoc 10 e)))
;print the co-ordinates

);progn
(setq r nil)
;if end of sequence, stop looping
);if
);while
(princ)
);defun
(princ)
There is a quicker way of retrieving the entity list of a Polyline vertex.
PolyLines and Blocks Page I
http://www.afralisp.com/lispa/lisp20.htm (2 of 5) [23/03/2005 05:45:06 p.m.]
(nentsel) let's you select an entity and returns the name of the entity even if it belongs to a polyline. Try this.
Type this, then select any vertex of a polyline.
(setq e (entget (car (nentsel))))
AutoLisp should return something like this :
Select object: ((-1 . ) (0 . "POLYLINE") (5 . "270") (100
. "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDb3dPolyline") (66 . 1) (10 0.0
0.0 0.0) (70 . 9) (40 . 0.0) (41 . 0.0) (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73
. 0) (74 . 0) (75 . 0))
How's that? Straight to the entity list!!
Now, while we're here, let's have a quick look at blocks.....
Blocks.
Create a block consisting of a couple of lines and a circle with a radius of 20.
Now type this :
(setq e (entget (car (nentsel))))
Now pick the circle. AutoLisp should return something like this:
Select object: ((-1 . ) (0 . "CIRCLE") (5 . "282") (100 .
"AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbCircle") (10 0.0 -1.51849 0.0) (40
. 20.0) (210 0.0 0.0 1.0))
Hey, Hang about. It's returned the entity list of the circle even though it's part of a block!! Now type the
following:
(setq d (assoc 40 e))
(setq e1 (subst '(40 . 50.0) d e))
(entmod e1)
Now REGEN the drawing.
Did you noticed what happened? The radius of the circle has change even though it's part of a block. Not only
that, it has also redefined the block definition.
In other words, every block in the drawing with the same name would have changed.
I told you it was magic......
Let's change the layer of the circle:
(setq d (assoc 8 e1))
(setq e2 (subst '(8 . "STEEL") d e1))
(entmod e2)
Again, REGEN the drawing. The circle has changed to Layer "STEEL".
Now do you see what I mean by magic. I bet you never thought you would be able to modify a block without
exploding it. Well you can now.....
LwPolylines.
As we mentioned earlier, LwPolylines are a new feature in AutoCad Release 14.
They differ in that they are defined as a single entity. Let's have a look at a LwPolylines entity list.
Draw a LwPolyline and enter this:
(setq e (entget (car (entsel))))
AutoLisp should return something like this:
Select object: ((-1 . ) (0 . "LWPOLYLINE") (5 . "287")
(100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 3) (70 .
1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 597.908 661.3) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (10 1179.86 476.045) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 479.39
397.084) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))
As you can see, there is no need to use (entnext) to step through the vertex entities as the group 10 entity code is
already part of the parent list.
But, we do have another problem!! There are numerous group 10 entity codes.
(As well as Group 40 - Start Width; Group 41 - End Width and Group 42 - Bulge)
To extract these, we need to first, find the length of the list. Then we must loop through each code entity in the
PolyLines and Blocks Page I
http://www.afralisp.com/lispa/lisp20.htm (3 of 5) [23/03/2005 05:45:06 p.m.]
list searching for a group 10. Once found, we can easily extract the vertex co-ordinates. The following function
does just that:
(defun c:lwcoord (/ e len n e1)
(setq e (entget (car (entsel))))
;get the entity list
(setq len (length e))
;get the length of the list
(setq n 0)
;set counter to zero
(repeat len
;repeat for the length of the entity list
(setq e1 (car (nth n e)))
;get each item in the entity list
;and strip the entity code number
(if (= e1 10)
;check for code 10 (vertex)
(progn
;if it's group 10 do the following
(terpri)
;new line
(princ (cdr (nth n e)))
;print the co-ordinates

);progn
);if
(setq n (1+ n))
;increment the counter
);repeat
(princ)
);defun
(princ)
Well, that's it concerning Polylines and Blocks. I told you it was easy!!!
Remember, I've only scratched the surface with the things that you can do once you dig into entity lists,
especially with complex entities.
One last thing. Want to create your own entity?
Normally, in AutoLisp you would draw a line like this:
(command "Line" pt1 pt2 "")
Now, create you own line by doing this:
(setq e '((0 . "LINE")(8 . "0")(10 50.0 50.0 0.0)(11 100.0 100.0 0.0)))
(entmake e)
Makes you think, doesn't it??
Cheers for now................

PolyLines and Blocks Page I


http://www.afralisp.com/lispa/lisp20.htm (4 of 5) [23/03/2005 05:45:06 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PolyLines and Blocks Page I
http://www.afralisp.com/lispa/lisp20.htm (5 of 5) [23/03/2005 05:45:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Polyline Bulges - Part II
Given the two functions getPolySegs and getArcInfo we can now put together a command that inspects
all bulges in a polyline.
(defun C:POLYARCS (/ a polysegs seg)
;; make a list of polyline segments of a
;; selected polyline
(cond ((setq polysegs (getPolySegs))
;; a is just an informative counter
(setq a 0)
;; run thru each segment
(foreach seg polysegs
(setq a (1+ a))
;; only process the segment if it's an arc
;; i.e. bulge /= 0.0
(cond ((not (zerop (cadr seg)))
(princ (strcat "\nSegment " (itoa a) ": "))
;;
(getArcInfo seg)
)
)
)
)
)
)
Example:
Command: polyarcs
Select polyline:
Segment 2:
Included angle: 2.9932 rad (171.4974 degrees)
Height of arc: 1.1422
Chord length: 2.4605
Radius of arc: 1.2336
Center of arc: -9.4965,14.9290
Segment 4:
Included angle: 0.9844 rad (56.3997 degrees)
Height of arc: 0.4201
Chord length: 3.3447
Radius of arc: 3.5390
Center of arc: -5.8690,19.3390
Segment 5:
Included angle: 1.6177 rad (92.6872 degrees)
Height of arc: 0.5787
Chord length: 2.7043
Radius of arc: 1.8689
Center of arc: -2.1545,17.4054
This concludes the code for now. Below are some useful formulas for dealing with bulges. The picture
recaps some geometric details of the circular arc.
Polyline Bulges Page II
http://www.afralisp.com/lisp/Bulges2.htm (1 of 3) [23/03/2005 05:45:10 p.m.]
= (* 4.0 (atan bulge))
= (/ 2.0)
= (+ )
= (- (/ pi 2.0)(/ 4.0))
= (/ (- (* pi 2.0) ) 4.0)
= (- (/ pi 2.0)(atan bulge))
= (/ (- pi ) 2.0)
= (- (/ pi 2.0)(* 2.0 (atan bulge)))
= (atan (/ a c))
= (/ 4.0)
= (atan bulge)
= (atan (/ s c))
c = (distance p1 p2)
= (* 2.0 r (cos ))
= (* 2.0 r (sin (/ 2.0)))
s = (* (/ c 2.0) bulge)
a = (sqrt (- (expt r 2.0) (expt (/ c 2.0) 2.0)))
(* r (cos ))
r = (/ (+ (expt (/ c 2.0) 2.0)(expt s 2.0))(* 2.0 s))
= (/ s (* 2.0 (sin )(cos )))
= (/ a (cos ))
The center point is found in the code by calculating angles and distances in order to use POLAR. In
function getArcInfo are given two methods. One is calculating the apothem as a leg in the triangle
P-P2-P4 and setting out the center point from P4. The other is using the angle &gamma; and the radius
to set out the point from P1. Both methods have to read the sign of the bulge to know in which direction
the center point has to be set out.
Another method could be to view the arc as a part of the circumcircle to triangle P1-P2-P3. The medians
to the lines P1-P3 and P2-P3 intersect in the center point. We know the gradients for these medians
because both angles are known. E.g. any perpendicular to the line P1-P3 has the gradient (- (/ 1.0 gr)),
where gr is the gradient of P1-P3. Once having a point of the median (midpoint of P1-P3) and the grade,
it's possible to find the Y-interception and thereby the equation for the median. Doing this for both
medians we can use the following formulas for finding the intersection point - which is the center point
for the arc:
xi = - (m1 - m2)/(n1 - n2)
yi = m1 + n1*xi
where
m1 = gradient for median to P1-P3
n1 = Y-interception for median to P1-P3
m2 = gradient for median to P2-P3
n2 = Y-interception for median to P2-P3
There are many other solutions for finding the center point - among those some shorter trigonometric
methods - but this will have to do for now.
Because the geometry described by the 2 vertices and the bulge is relatively simple, there are many
other formulas than those depicted here. The important part is to understand how the bulge is defined
Polyline Bulges Page II
http://www.afralisp.com/lisp/Bulges2.htm (2 of 3) [23/03/2005 05:45:10 p.m.]
and how it relates to the only other two pieces of data given - the vertices. Hopefully this was able to
shed a light on some of the definitions.
For more information, refer to :
Unit Circle Definition of Sine and Cosine Functions
Page I

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Polyline Bulges Page II
http://www.afralisp.com/lisp/Bulges2.htm (3 of 3) [23/03/2005 05:45:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Unit Circle Definition of Sine and Cosine Functions
The trigonometric functions can be defined in terms of a unit circle, i.e. a circle of radius one.
The sin/cos Triangle
If the unit circle is placed at the origin of a rectangular coordinate system with the angle q measured
from the positive x-axis to the terminal side, then the point on the unit circle where the terminal side
intersects the unit circle is defined to be (cos q, sin q), i.e. the first coordinate of a point on the unit
circle is the cos q and the second coordinate is sin q.
The tan/sec Triangle
The tan q and sec q are defined by a triangle whose height is tangent to the unit circle at the point (1, 0)
and whose hypotenuse is on the terminal side of the angle.
The cot/csc Triangle
The cot q and csc q are defined by a triangle whose height is one and whose hypotenuse is on the
terminal side of the angle.
Unit Circle Definition of Sine and Cosine Functions
http://www.afralisp.com/lisp/bulge.htm (1 of 3) [23/03/2005 05:45:13 p.m.]
The sin/cos, tan/sec, and cot/csc Triangles
All three of the triangles used to define the trigonometric functions are shown in figure below.

Using the sin/cos, tan/sec, and cot/csc Triangles to Establish Basic Trigonometric
Identites
The three similar triangles sin/cos, tan/sec, and cot/csc are extracted from the figure. A fourth similar
triangle is shown with the adjacent, opposite, and hypotenuse sides labelled.
The definition of the six trigonometric functions and other useful identities follow from using the fact
that the ratio of corresponding sides of similar triangles must be the equal. The results are:
Unit Circle Definition of Sine and Cosine Functions
http://www.afralisp.com/lisp/bulge.htm (2 of 3) [23/03/2005 05:45:13 p.m.]
Using the sin/cos, tan/sec, and cot/csc Triangles to Determine the Pythagorean Idenities
The Pythagorean Theorem states: in any right-angled triangle, the sum of the squares of the lengths of
the sides containing the right angle is equal to the square of the hypothenuse. In short c
2
= a
2
+ b
2
.
Applying the Pythagorean Theorem to the sin/cos, tan/sec, and cot/csc triangles gives:

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Unit Circle Definition of Sine and Cosine Functions
http://www.afralisp.com/lisp/bulge.htm (3 of 3) [23/03/2005 05:45:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ACCESSing AutoCAD
Written by Scott McGlynn - SMcGlynn@MCECo.com
Scott has been working with AutoCAD since 1985 (Release 2.15) and with Visual Basic since 1993.
He has worked for one of the larger electrical contractors in the US since 1994 as a Project Engineer. He
recently acquired a BS in Business Administration.
In regards to VB, he has been mostly self taught with a couple of classes here and there over
the years.
Microsoft Access is a simple relational database management system, RDBMS for short. Databases are
great for storing data. An excellent use of databases can be found in what I call a "Conduit and Cable
Schedule". Creating the Database is a whole topic unto itself and I will not go into a lot of detail about it,
however, I will describe what this Conduit andCable Schedule is all about. Following is a screen shot of
the "Relationships" view of the Database we will be referencing :
You will notice this is a large and rather complex database structure, but over the next few months, we
will be going through it step by step and breaking it down. The tables we will be using today include the
LOC, CAB, CON and DWG tables. The LOC table is a list of locations, the CAB, a list of Cables, the CON,
a list of Conduits and the DWG table, a list of drawings.
In large electrical projects, there are lots and lots of pieces of equipment that need power, have control
wires and other such interconnections. When designing the electrical distribution systems it is nice to
have a method of referencing those conduits and wires between these locations. For instance, a
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (1 of 6) [23/03/2005 05:45:16 p.m.]
particular Electrical panel might have 42 separate circuit breakers. Each one feeding a different pump.
As electrical contractors, we have to install conduit and wire to feed all of these pieces of equipment.
From a purely theoretical standpoint, every location in a job must be unique. We can't have two pumps
with the same name, no one would know which one we were referring to. By the same token, we can't
have two conduits with the same number. So, in the Access Database, we will have the CAB, CON and
LOC tables with indexes that prevent the generation of records with duplicate names.
Interfacing that Database with AutoCAD has been on my wish list for a few years, with the help of
Kenny Ramage and the rest of the gang here at Afralisp and Cad Encoding, I've gotten up the courage
to tackle just that. Ok, so let's begin.
Virtually Everything I do will be done from within Microsoft Access. The biggest question I have had to
ask myself is which application to write the code in. I could Write the application in Access and have
Access talk to AutoCAD, or I could write the code in AutoCAD and have AutoCAD talk to Access. I
chose the former over the latter for the simple reason that I have thousands and thousands of lines of
code written in Access to make the Conduit and Cable Schedule Work. I didn't really want to reinvent
the wheel, so there it is. Also, for compatibility issues, I am working in AutoCAD 2002 and Microsoft
Access 97. While there shouldn't be a big difference between versions, there may be.
My First step in this little shindig was to create a new class module to contain all of the code for the
AutoCAD interface. Once the new class is created, at the top, add the following lines of code :
Option Compare Database
Option Explicit
Private WithEvents objACAD As AcadApplication
Private objDoc As AcadDocument
Private Appexists As Boolean
The "Option Compare Database and the "Option Explicit" tell the Access App to first use the Database
default for comparing strings, etc and secondly to force the dimensioning of all variables.
That third line is a big one. It defines the interface for the AutoCAD Application. The "WithEvents"
keyword allows Access to generate Event Handlers for all of the Events AutoCAD exposes. For
instance, when a new drawing is opened, Access will know about it. The objDoc variable gives us a
direct reference to the Autocad Document which is a drawing. Finally, we define a boolean value for
internal use that makes sure the App Exists before we try to use it.
Please note, this is not an actual object, but a class. In order to create the object, we have to define an
object variable as this class and instantiate it. In the case of the Access Application, I have a global
variable called "objACAD" defined that is instantiated when the Access Application starts (it is
instantiated when a splash form comes up This allows any and all objects within the Application to
incorporate Autocad information into the data.)
When the class is instantiated, the "Class_Initialize" Event is executed. The code for this follows:
Private Sub Class_Initialize()
On Error Resume Next
Set objACAD = GetObject(, "Autocad.Application")
AppExists = True
If objACAD Is Nothing Then
Set objACAD = CreateObject("AutoCad.Application")
If objACAD Is Nothing Then Appexists = False

End If
IF AppExists Then Set objDoc = objACAD.ActiveDocument
End Sub
First we set up an Error handler, then we attempt to get a reference to any existing Autocad
Applications that might be running. IF that fails, we then try to create a new instance of AutoCAD. If that
fails, we then set Set our AppExists value to false. Finally, we set a reference to the Current Document.
Using an Exhaust Fan as an example, there are power conductors that go from a Motor Control Center
(MCC) to an Exhaust Fan Disconnect (EF-DISC). Then there are Power conductors to go from EF-DISC
to the Exhaust Fan (EF). Finally, there are control conductors that go from the MCC to a Processor
Panel (PP) that indicate if the EF is Running, Faulted, etc. Schematically, it would look like this :
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (2 of 6) [23/03/2005 05:45:16 p.m.]
Notice the cable numbers. This is a cable numbering system I have come up with that seems to work
reasonably well. Each cable is defined by the piece of equipment's name (in this case, EF). The second
part, the P01, P02, and C01 define the types of cables they are, Power, Control, Signal, Data,Fiberoptic,
etc. So, our Cable Table contains a list of all the Cable Names (each being unique). Now lets take a look
at this schematic from the point of view of construction. Below is a floor plan showing the location of
each of these pieces of equipment.
Notice there is more to this than just the equipment listed in the schematic. From a construction point
of view, I have an additional pull box located on the west well (north is up) The conduit goes from MCC
to PB-1 Then a conduit from PB-1 to EF-DISC. Finally, a conduit from EF-DISC to EF. Numbering the
conduits, we get the plan shown below Notice, the cable EFC01 is contained in both Conduit 1 and
Conduit 2.
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (3 of 6) [23/03/2005 05:45:16 p.m.]
Now that we have an idea of what the conduit and cable schedule will contain, lets take a look at
interfacing it with AutoCAD. Something that would be nice to have is an ability to select a location in the
database and have AutoCAD automatically open the drawing and zoom to the location. In pseudo code,
it would be something like:
Given a Selected Location in the Database,
Open Drawing Containing Location
Find Autocad Entity that is the location
Get Boudning Box of Entity
Zoom to bounding box
Complete.
Two important pieces of information are stored in the Location Table that will help in this endeavor.
First, is an index that is the Drawing, second is the Handle of the Entity in that Drawing.
How do we obtain those two pieces of information? . .Well, lets look at some pseudocode for that one:
Given a Selected Location in the Database,
1. Ask the user if the current Autocad Drawing is the one containing the entity that is the location
(is the polyline box representing PB-1 on the current drawing?)
G
2. If it is, leave the current drawing open, if not, allow the user to select the drawing required. G
3. Allow the user to select the entity that represents the location. G
4. Retrieve the drawing name and the handle G
5. Store information in the database. G
6. Complete. G
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (4 of 6) [23/03/2005 05:45:16 p.m.]
This is a screen shot of the "Location" Form. There are many fields in
this form that are of little consequence to us here. The fields we are
most concerned with are the Handle, DWGID and the button next to it
as well as the "Show Item" command button.
Lets take a look at the code behind the button next to the Handle Text
box.
Private Sub cmdGetHandle_Click()
Dim col As Collection
Dim ent As AcadEntity
Dim strDWG As String
Set col = objACAD.GetHandle
If col.Count = 0 Then Exit Sub
Set ent = col.Item(1)
txtHandle = ent.Handle
strDWG = ent.Document.Path & "\" & ent.Document.name
txtDWGID = FindDrawing("filename", strDWG).DWGID
End Sub
Similar to our pseudo code, we call a function from our ojbACAD class called GetHandle. Notice the
return value for the GetHandle Function is a Collection. In our current example, we only want one entity.
However, there are other uses for this function. Namely, when routing cables through conduits, I can
select all the conduits and pull boxes the cable goes through and the Database will be able to add the
cable to all of those items.
Public Function GetHandle() As Collection
Dim objDoc As Object
Dim col As Collection
Dim ob As AcadEntity
Dim str As String
Dim pt As Variant
Dim str As String
Dim fname As String
Set col = New Collection
If objACAD Is Nothing Then
MsgBox "Could Not Get Autocad Application"
Exit Function
End If
If objACAD.Documents.Count = 0 Then
str = GetFileName(CurrentDb.name, "Select File to Open")
If str = "" Then
Set GetHandle = Nothing
GoTo CleanUp
End If
Set objDoc = objACAD.Documents.Open(str)
End If
Do
On Error Resume Next
Set ob = Nothing
objDoc.Utility.GetEntity ob, pt, "Select the Enetity:"
If Err.number = 80020009 Then GoTo CleanUp
col.Add ob, ob.Handle
ob.Highlight True

Loop Until ob Is Nothing
CleanUp:
For Each ob In col
ob.Highlight False
str = str & ob.Handle & ", "
Next
str = Left$(str, Len(str) - 2)
Set GetHandle = col
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (5 of 6) [23/03/2005 05:45:16 p.m.]
Set col = Nothing
End Function
To Be Continued........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Accessing AutoCAD
http://www.afralisp.com/vba/access.htm (6 of 6) [23/03/2005 05:45:16 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
File Functions in Visual Basic
Dir
One useful file function is the Dir$ function. This function works like the Dir command at an
MS-DOS command prompt. You can use the Dir$ function to retrieve a list of one or more
operating system files that match a file specification or path. A path can include the name of a
directory, a specific file name, or both. For example, C:/*.DWG is the path to all the files in the
root directory of drive C having a DWG extension. The syntax of the Dir$ function is as follows :
stringvar = Dir$(path[,attributes])

Finding Files
One use of the Dir$ function is to determine whether a file exists. If you try to open a database or
access a file that does not exist, an error occurs. However, you can use Dir$ first to check for a files
existence before opening it, as in the following example :
If Dir$("C:/MYFILE.DWG" = " " Then
Msgbox "The file was not found. Please try again!"
End If
The Dir$ function returns the filename without the full path if the specified file is found, or it
returns an empty string if no files were found. The preceding line of code displays a message box if
MYFILE.DWG does not exist in the root directory of drive C. If the file does exist, the string
"myfile.dwg" is returned. To make things even simpler, you can create a generic function that
returns a Boolean value "True" if the given file exists.
Public Function bFileExists (Sfile As String) As Boolean
If Dir$(sFile) <> " " Then
bFileExists = True
Else
bFileExists = False
End Function
This function could then be used to check any filename passed to the program by the user, as in the
following example :
Dim sUserFile As String
sUserFile = InputBox$("Enter the File Name : ")
If Not bFileExists(sUserFile) Then
MsgBox "The file does not exist. Please try again."
End
End If
File Functions in Visual Basic
http://www.afralisp.com/vba/files.htm (1 of 5) [23/03/2005 05:45:18 p.m.]
Notice that the code sample ends the program if the file does not exist, to prevent any errors that
might occur later. Another way to handle this situation would be to keep asking the user for a
filename until a valid filename is entered.
Listing Files and Folders
Another use of the Dir$ function is to return a list of files in the specified path. If you use the Dir
command at an MS DOS prompt, each matching file is listed
on the screen. However, because the Dir$ function is designed to return only a single string
variable, you have to use a loop and retrieve one filename at a time. (You can also display a list of
files with a file list box, which is one of Visual Basic's default controls.
Suppose that your C:/DRAWINGS directory contains several drawings with a DWG extension. The
path used to retrieve these files with the Dir$ function would be C:/DRAWINGS/*.DWG. You can
use the following lines of code to retrieve the filenames and add them to a list box :
sNextFile As String
sNextFile = Dir$("C:/DRAWINGS/*.DWG")
While sNextFile <> " "
lstDwgList.AddItem sNextFile
sNextFile = Dir$
Wend
In the preceding example, notice that only the file path to Dir$ is supplied on the first call. Each
subsequent call to Dir$ has no arguments, indicating that you want to use the previous file path and
move to the next filename in the list. When no more files match, Dir$ returns an empty string and
the "While" loop terminates.
Caution : When you use Dir$ in a loop, always exit the loop after an empty string is returned. If you
try to make another call to Dir$ with no arguments, a runtime error occurs.
The second, optional parameter of the Dir$ function is used to provide additional conditions
(beyond the specified path) with which to select files. For example, using the constant "vbDirectory"
returns only the subdirectories (or folders) in the specified path. The constant "vbVolume" causes
Dir$ to return the specified drive's volume label. The available constants are
summarized below :
Constant Value Purpose
vbNormal 0 (Default Value)
vbHidden 2 Include Hidden Files
vbSystem 4 Include System Files
vbVolume 8 Return Drive Volume Label
vbDirectory 16 Display SubDirectories
vbReadOnly 1 Include read-only files
Note : Constants can be added together if you want to use more than one. For example, the
following code finds the system, hidden and read only file IO.SYS on a machine :
debug.Print Dir$("C:/IO.SYS" , vbHidden+vbSystem+vbReadOnly)
Note that the "vbHidden" constant refers to a file's attributes and not the Windows Explorer option
that hides certain file types.
File Manipulation Functions
File Functions in Visual Basic
http://www.afralisp.com/vba/files.htm (2 of 5) [23/03/2005 05:45:18 p.m.]
As with the Dir$ function, most of the file manipulation commands in Visual Basic are as
straightforward as their MS-DOS equivalents, although with a few limitations. These commands
are summarised below :
Copy a File FileCopy source dest
Delete one or more Files Kill path
Rename a File Name oldname As newname
Create a Folder MkDir pathname
Remove an empty Folder RemDir pathname
Change current directory ChDir pathname
Change current drive ChDrive drive
Several of these functions are described in the following sections :
Copying Files
The "FileCopy" command has the limitation that you cannot use wildcards to
specify multiple files. "FileCopy" can copy files locally or over a network, as shown in the
following example :
'The following line copies a file while changing its name :
FileCopy "D:\DRAWING\TEST.DWG", "C:\BACKUP\TEST-BACK.DWG"
'The following lines of code use a network path for the source file :
Dim sDest As String
Dim sSource As String
sSource = "\\MYSERVER\DRAWINGS\TEST.DWG"
sDest = "C:\BACKUP\TEST-BACK.DWG"
FileCopy sSource, sDest
The "FileCopy" statement automatically overwrites an existing file, unless the
file is read-only or locked open by another application.
Deleting Files
Visual Basic also allows you to delete files by using the "Kill" statement. "Kill"
can use wildcards to specify multiple files, as in the following example :
Kill "D:\DRAWINGS\*.DWG"
Renaming Files
The "Name" statement is like the MS-DOS "RENAME" command but can be used on only one file
at a time "
Name oldname As newname
You can also use "Name" like the "MOVE" command in MS-DOS if the specified paths are
different :
'Moves the files to a new directory
MkDir "C:\BACKUP\TEST-BACK.DWG"
Name "D:\DRAWING\TEST.DWG" As "C:\BACKUP\TEST-BACK.DWG"
In the preceding example,note the "MkDir" statement, which you have probably guessed is used to
create a new directory. The "MkDir" and "RemDir" statements add and remove directories.
File Functions in Visual Basic
http://www.afralisp.com/vba/files.htm (3 of 5) [23/03/2005 05:45:18 p.m.]
Setting the Current Directory
In the examples discussed so far, the path has always included the drive and directory. However, as
you may recall from using MS-DOS, during the context of your MS-DOS session, you are always
"in" a certain directory, which is usually displayed to the left of the MS-DOS cursor. For example,
if you type CD \WINDOWS, you can rename, copy, or delete files within the WINDOWS directory
without specifying C:\WINDOWS in the pathname. The same concept of a "current directory"
applies to Visual Basic. By using the "ChDir" and "ChDrive" statements, you can set the current
working directory on each drive and switch between current drives, eliminating the need to specify
the full path for each file operation :
'Change to the desired directory and drive and rename file
ChDir "C:\DRAWINGS"
ChDrive "C:"
Name "TEST1.DWG" As "TEST2.DWG"
'Delete a file in the current directory
ChDrive "D:"
ChDir "D:\DRAWINGS"
Kill "OLDTEST.DWG"
Performing deletes can be dangerous if you don't know the current directory. Fortunately, Visual
Basic offers a function that provides this value: the "CurDir" function. The syntax of "CurDir" is :
stringvar = CurDir$([Drive])
Note - You can use the "Left$" function to get the current drive letter, as in the
following example :
sDriveLetter = Left$(CurDir$( ) , 1)
Okay, let's put this all together into a practical example.
Wouldn't it be nice to be able to backup all your drawings from your working
directory into a backup directory, either on another drive or to the network.
Have a look at this wee application, remembering to change the directory
paths to suit your own.
Open a new module and copy and paste this coding :
'VBA CODING STARTS HERE
Option Explicit
Sub Backup()
Dim sSourceDir As String
Dim sBackDir As String
Dim sNextFile As String
On Error GoTo FileCopyError
'Change these paths to suit.
sSourceDir = "C:\DRAWINGS\"
sBackDir = "D:\BACKUP\"
sNextFile = Dir$(sSourceDir & "*.DWG")
While sNextFile <> ""
FileCopy sSourceDir & sNextFile, sBackDir & sNextFile
sNextFile = Dir$
Wend
File Functions in Visual Basic
http://www.afralisp.com/vba/files.htm (4 of 5) [23/03/2005 05:45:18 p.m.]
MsgBox "Drawing Backup Complete. Have a Nice Day."
Exit Sub
FileCopyError:
MsgBox "There was a problem copying the Drawings"
End
End Sub
'VBA CODING ENDS HERE

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
File Functions in Visual Basic
http://www.afralisp.com/vba/files.htm (5 of 5) [23/03/2005 05:45:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Error Trapping
As you are writing your code, Visual Basic informs you of syntactical errors.
However, once the program is running, you may encounter unexpectedruntime errors in many circumstances.
For example, suppose you try to open a text file that the user has deleted.
When a compiled program has an error like this, an error message isdisplayed and the program ends.
Although you cannot predict and write code for every possible type of error,
"File Not Found" errors are fairly easy to handle. If you do not write code towork around the error, you can at
least provide a message that makes more sense before ending the program.
The "On Error" Statement
The most common way to handle error conditions is to use Visual Basic's"On Error" statement.The "On Error"
statement interrupts the normal flow of your program when
an error occurs and begins executing your error handling code. A typical
use is as follows :
On Error Goto FileOpenError
When this statement is executed, any errors that occur in subsequentstatements cause Visual Basic to stop normal
line-by-line execution andjump to the statement labeled as "FileOpenError".
Labeling Code Lines
Line labels in Visual Basic are similar to the line numbers of early BASIC.In Visual Basic, line labels can include
text if you want, but each label mustbe unique. They are followed by a colon (:), as in the following example :
Private Sub Form_Load ()
On Error Goto FileOpenError
Open "C:\SOMEFILE.TXT" For Unput As #1
Line Input #1, sData
Exit Sub
FileOpenError:
MsgBox "There was a problem opening the file. Stop for coffee!"
End
End Sub
In the preceding sample code, if the "Open" or "Line Input" statements causean error, the statements starting at
the label "FileOpenError" are executed,causing the message to be displayed and ending the program.
You should note a few points about the sample code. First, note the locationand style of the error handling routine.
It is usually placed near the end of thesubroutine, with the label not indented to indicate a special section of code.
Second, and more important, note the "Exit Sub" statement after the "Open" statement. It is necessary to prevent
the error handler routine from executingeven when the "Open" statement was successful.
Controlling Program Flow After an Error
In the preceding code example, you simply end the program if an error occurs.
However, you can handle the error in several (better) ways :
Exit the subroutine after informing the user of the error, and allow the program
to continue running with limited functionality.
G
Resume execution with the next statement following the error. G
Error Trapping in Visual Basic
http://www.afralisp.com/vba/error.htm (1 of 3) [23/03/2005 05:45:19 p.m.]
Provide a way for the user to correct the error and retry the offending statement. G
You can also have multiple labels within a procedure and set the current error handler
multiple times. For example, you can add a line to the code sample after the "Open"
statement that specifies a new label, "FileInputError". You can also turn off error
handling with the following statement :
On Error Goto 0
The "On Error" statement goes hand in hand with the "Resume" statement. For example, this statement causes
errors to be ignored and the program to proceed through each line of the code anyway :
On Error Resume Next
You should use the preceding line of code sparingly because it really just ignores
errors rather than handles them. A better use of "Resume" is to go to another section
of code. as in the following example :
Private Sub Form_Load ()
On Error Goto FileOpenError
RetryHere:
Open "C:\SOMEFILE.TXT" For Unput As #1
Line Input #1, sData
Exit Sub
FileOpenError:
Dim sMessage As String
sMessage = "There was a problem opening the file. " & VbCrLf
sMessage = sMessage & "Press Retry to try again, or Cancel to quit."
If MsgBox (sMessage, vbRetryCancel + vbCritical, "Error!") = vbRetry Then
Resume RetryHere
Else
End
End If
End Sub
You can though use "On Error Resume Next" if you are trying to connect to AutoCAD
from an external Visual Basic or other application :
'if error carry on with next line
On Error Resume Next
'set reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application.16")
'if there is an error (AutoCAD not open)
If Err Then
'clear the error
Err.Clear
'open AutoCAD
Set acadApp = CreateObject("Autocad.Application.16")
'setq reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application.16")
'if there is another error
If Err Then
'inform user
MsgBox Err.Description
'exit application
Exit Sub
Error Trapping in Visual Basic
http://www.afralisp.com/vba/error.htm (2 of 3) [23/03/2005 05:45:19 p.m.]
End If
End If
Next, set the document variable to the Document object in the AutoCADapplication. The Document object is
returned by the ActiveDocumentproperty of the Application object :
Dim ThisDrawing as AcadDocument
Set ThisDrawing = acadApp.ActiveDocument
From this point on, use the "ThisDrawing" variable to reference the current AutoCAD drawing just like AutoCAD
VBA.
Determining The Type of Error
After an error has occurred, your code can find out more information about the error in several ways :
Err - Contains a number that represents the error. G
Error - Contains a string describing the error. G
Err Object - Contains error number, description and additional information.
Also used to raise your own custom errors.
G
If you know how to recover from certain errors that may occur, you can use these
objects to respond intelligently to a specific error. In one of the previous examples, you received a "File Not
Found" error, which is number 53. You can easily add code
in the error handler to take appropriate action (that is, check another file) if the
value of "Err" is 53.
Hint : When you are writing an error handling routine with a message box, display the error number and
description in your message box to make troubleshooting easier.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Error Trapping in Visual Basic
http://www.afralisp.com/vba/error.htm (3 of 3) [23/03/2005 05:45:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA and Outlook.

This application will demonstrate how to connect AutoCAD and Outlook using VBA. It
will allow you to add a Task to Outlook along with a reminder time and a due time.
Special thanks to Randall Raath of VBDesign for this idea.
Here is the complete source coding :
Private Sub CommandButton1_Click()
UserForm1.Hide
AddTask
End Sub
Sub AddTask()
Dim appOutLook As Outlook.Application
Dim taskOutLook As Outlook.TaskItem
Dim Rem1 As Integer
Dim Due1 As Integer
Set appOutLook = CreateObject("Outlook.Application")
Set taskOutLook = appOutLook.CreateItem(olTaskItem)
Rem1 = (CInt(UserForm1.TextBox3.Text) * 60) _
+ CInt(UserForm1.TextBox5.Text)
Due1 = (CInt(UserForm1.TextBox4.Text) * 60) _
+ CInt(UserForm1.TextBox6.Text)
With taskOutLook
.Subject = UserForm1.TextBox1.Text
.Body = UserForm1.TextBox2.Text
.ReminderSet = True
VBA and Outlook
http://www.afralisp.com/vbaa/vba13.htm (1 of 2) [23/03/2005 05:45:21 p.m.]
.ReminderTime = DateAdd("n", Rem1, Now)
'set the reminder time
.DueDate = DateAdd("n", Due1, Now)
'set the due time
.ReminderPlaySound = True
.ReminderSoundFile = "C:\Windows\Media\Ding.WAV"
'Add the path to a .wav file on your computer.
.Save
End With
Set taskOutLook = Nothing
Set appOutLook = Nothing
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Initialize()
UserForm1.TextBox1.SelStart = 0
UserForm1.TextBox1.SelLength = _
Len(UserForm1.TextBox1.Text)
End Sub
If you would like a copy of this module, just click here. Enjoy.......

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Outlook
http://www.afralisp.com/vbaa/vba13.htm (2 of 2) [23/03/2005 05:45:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA and Powerpoint.
This application will take a selected directory of drawings, convert them to WMF format
and insert them into Powerpoint as individual slide.
Usage :
Open the Powerpoint file dwg2slide.ppt.
Run the macro 'dwg2slide'.
Choose any file in the directory you wish to process.
Select 'O.K.' to proceed and sit back.
After a couple of minutes (depending on how many drawing files are in
the directory you choose), your slides will have been created.
Here is the coding for the entire application :
(Remember, this is written in Powerpoint VBA).
First create a module named Module1:
Public dirname As String
Sub Dwg2Slide()
Dim selname As String
Dim SelName1 As String
Dim InCounter As Integer
Dim InFoundpos As Integer
UserForm1.CommonDialog1.Filter = "dwg Files (*.dwg)|*.dwg"
'set default file type
UserForm1.CommonDialog1.Flags = cdlOFNHideReadOnly
'switch off read only
UserForm1.CommonDialog1.ShowOpen
'open dialog box
selname = UserForm1.CommonDialog1.filename
'retrieve the file name
InCounter = 1
'initilize counter
InFoundpos = InStr(InCounter, selname, "\")
'look for the \
While InFoundpos <> 0
'check for the last \
SelName1 = Mid$(selname, InCounter, InFoundpos - InCounter)
'extract the directory name

InCounter = InFoundpos + 1
'increase the counter
VBA and Powerpoint
http://www.afralisp.com/vbaa/vba12.htm (1 of 5) [23/03/2005 05:45:22 p.m.]

InFoundpos = InStr(InCounter, selname, "\")
'find the next \

dirname = dirname & SelName1 & "\"
'construct the path

Wend
UserForm1.Show
'show the dialog
End Sub
Next create a userform named Userform1. The following coding goes under the event procedures of
the userforms controls:
Private Sub CommandButton1_Click()
Dim filename As String
Dim sl As Integer
Dim acadApp As Object
Dim acadDoc As Object
Dim sset As Object
Dim pViewport As Object
'declare variables


Set acadApp = CreateObject("Autocad.Application")
'open AutoCAD
If Err Then
'if there is an error
MsgBox Err.Description
'inform user
Exit Sub
'exit application
End If
'End If
acadApp.Visible = True
'Make Autocad Visible
Set acadDoc = acadApp.ActiveDocument
'set reference to active document
Me.Hide
'Hide the dialogue box
filename = Dir(dirname, vbNormal)
'retrieve the first entry
Do While filename <> ""
VBA and Powerpoint
http://www.afralisp.com/vbaa/vba12.htm (2 of 5) [23/03/2005 05:45:22 p.m.]
'start the loop
If UCase(Right$(filename, 4)) = ".DWG" Then
'ignore files that do not end with .DWG
If (GetAttr(dirname & filename) And vbNormal) = vbNormal Then
'use bitwise comparison to make sure filename is not a directory
acadDoc.Open dirname & filename
'open drawing to purge
mylen = Len(filename)
'get the length of the filename
mylen = mylen - 4
'subtract the .DWG Extension
filename1 = Left(filename, mylen)
'retrieve the drawing name
Set pViewport = acadDoc.ActiveViewport
'set reference to the viewports
pViewport.ZoomExtents
'zoom to extents
Set sset = acadDoc.SelectionSets.Add("NEWSS")
'set reference to election set
sset.Select acSelectionSetAll
'select the whole drawing
acadDoc.Export dirname & filename1, "WMF", sset
'export the drawing
acadDoc.Save
'save the drawing
End If
End If
filename = Dir
'get the next entry
Loop
'carry on looping
acadApp.Quit
'Close Autocad
filename = Dir(dirname, vbNormal)
'retrieve the first entry
sl = 1
Do While filename <> ""
'start the loop
VBA and Powerpoint
http://www.afralisp.com/vbaa/vba12.htm (3 of 5) [23/03/2005 05:45:22 p.m.]
If UCase(Right$(filename, 4)) = ".WMF" Then
'ignore files that do not end with .WMF
If (GetAttr(dirname & filename) And vbNormal) = vbNormal Then
'use bitwise comparison to make sure filename is not a directory
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add _
(Index:=sl, Layout:=ppLayoutBlank).SlideIndex
'insert a new slide

ActiveWindow.Selection.SlideRange.Shapes.AddPicture _
(filename:=filename, LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, Left:=-2, Top:=58, Width:=727, _
Height:=423).Select
'import WMF File into slide

sl = 1 + sl
'increment the slide number

End If
End If
filename = Dir
'get the next entry
Loop
'carry on looping
MsgBox ("Process Complete.."), , "Drawings to Slide"
'inform user that we have finished
End
End Sub
Private Sub CommandButton2_Click()
End
End Sub
If you would like a copy of this module, just click here. Enjoy.......

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
VBA and Powerpoint
http://www.afralisp.com/vbaa/vba12.htm (4 of 5) [23/03/2005 05:45:22 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Powerpoint
http://www.afralisp.com/vbaa/vba12.htm (5 of 5) [23/03/2005 05:45:22 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA Command Line Project.
As good as VBA is, there are still certain things that are difficult or just impossible to
achieve using VBA. For example, have you ever tried to Explode a block using VBA or
Load and Run an AutoLisp routine. Not easy is it?
The following code module sends a user defined string to the AutoCAD command line.
Theoretically, this means that you can run any AutoCAD command that you wish.
Copy and paste the following coding into a module in VBA and run any of the 4 sub- routines. The
four sub-routines available as examples are :
Zoome - This simply Zooms to the drawing extents. G
Xplode - Will explode a block. The block must be
the last item entered into the drawing.
G
DwfExport - This will export the current drawing as a DWF File. G
RunLisp - This will Load and Run an AutoLisp file. G
Thanks to Michael Hunter, ActiveCad, and Joe Sutphin for this Module and the idea. Sorry guys,
but it is to good not to spread around :-)
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Declare Function GetForegroundWindow Lib "user32" () As Long
Public Const WM_COPYDATA = &H4A
Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As String
End Type
Public Sub SendToCommandPrompt(strMessage As String) Dim DataStruct As COPYDATASTRUCT
DataStruct.dwData = 1 DataStruct.lpData = strMessage DataStruct.cbData = Len(strMessage) + 2 AppActivate
ThisDrawing.Application.Caption SendMessage GetForegroundWindow, WM_COPYDATA, 0, DataStruct End
Sub
Sub xplode() SendToCommandPrompt "explode" & vbCr & "last" & vbCr & vbCr End Sub
Sub DwfExport() SendToCommandPrompt "DWFOUT" & vbCr & vbCr & "A" & vbCr & "YES" & vbCr End
Sub
Sub Zoome() SendToCommandPrompt "ZOOM" & vbCr & "EXTENTS" & vbCr End Sub
Sub RunLisp() SendToCommandPrompt "(Load ""ALispFile"")" & vbCr & "ALispFile" & vbCr End Sub
If you would like a copy of this module, just click here. Enjoy.......

VBA Command Line Project


http://www.afralisp.com/vbaa/vba11.htm (1 of 2) [23/03/2005 05:45:24 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Command Line Project
http://www.afralisp.com/vbaa/vba11.htm (2 of 2) [23/03/2005 05:45:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA Fax (23 Kb)
A lot of people now have E-Mail which makes the sharing of drawings a lot easier. But, not
everybody has got AutoCAD, so even if you E-Mail the drawing to them they still cannot open it.
You could fax it, but that has it's own problems.
Firstly, you must plot the drawing out to suit the size format of the fax machine,
or cut the drawing up into strips and fax it that way.
If you have a fax card and modem connected to your computer you can use a little bit of Visual
Basic to send the drawing to your fax.
First of all you need to set your fax as the default system printer.
Next, open AutoCAD and go to Preferences - Printers and set up a default system Printer. Finally,
open up the Fax VBA Application and change the Fax name to that of your Fax. That's it, you are
ready to Fax any drawing.
Here is the coding for the application :
Private Sub CommandButton1_Click()
ThisDrawing.Plot.PlotToDevice "WinFax"
'change the name of the Fax to suit

End Sub
Private Sub CommandButton2_Click()
End
End Sub
Thanks to Randall Rath of VBDesign for the idea for this project.....

VBA Fax
http://www.afralisp.com/vbaa/vba10.htm (1 of 2) [23/03/2005 05:45:26 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Fax
http://www.afralisp.com/vbaa/vba10.htm (2 of 2) [23/03/2005 05:45:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Timesheet Project (28 Kb)
This project demonstrates a method of extracting system variable data from AutoCAD and
importing it into Microsoft Excel.
The application calculates the length of time a user has spent in a drawing session and extracts this
data to a timesheet created in Excel. It then totals the daily drawing hours along with with the date,
the draughtsman's login name, the drawing number and the job number.
To use this VBA application, simply extract all of the files into your working
directory then load and run Timesheet.Lsp.
(If you have problems when writing or running this project, ensure that
the Microsoft Excel 8.0 Object Library is selected in your VBA References.)
After running the application, open the Excel file Timesheet.xls. You should have something
looking like this :
Timeshet Project
http://www.afralisp.com/vbaa/vba9.htm (1 of 5) [23/03/2005 05:45:28 p.m.]
Here is the source coding for this application.
Public ElapseTime As String
Public Dwgname As String
Public Username As String
'declare global variables
Private Sub CommandButton1_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim Colnum As Integer
Dim Rownum As Integer
Dim Currcell As Range
'declare local variables
Set xlbook = GetObject("Timesheet.xls")
'set reference to Excel file
Set xlapp = xlbook.Parent
'set reference to workbook
xlapp.Visible = True
'make Excel visible
xlapp.Windows("TIMESHEET.XLS").Visible = True
'make the workbook visible
'the 2 preceeding lines can be commented out if you
'do not want to see Excel in action
Set xlsheet = xlbook.Sheets("SHEET1")
'set reference to the worksheet Sheet1
Rownum = 10
'set initial row number
Timeshet Project
http://www.afralisp.com/vbaa/vba9.htm (2 of 5) [23/03/2005 05:45:28 p.m.]
Colnum = 3
'set initial column number
Set Currcell = xlsheet.Cells(Rownum, Colnum)
'position the current cell
Do While Currcell <> ""
'while the current cell is NOT empty
Rownum = Rownum + 1
'increase the row number by one

Set Currcell = xlsheet.Cells(Rownum, Colnum)
'reset the current cell

Loop
'carry on looping
xlsheet.Cells(Rownum, Colnum) = Format(ElapseTime, "h:m:s")
'enter the elapsed time
xlsheet.Cells(Rownum, (Colnum - 1)) = UCase(Dwgname)
'enter the drawing number
xlsheet.Cells(Rownum, (Colnum - 2)) = UCase(UserForm1.TextBox1.Text)
'enter the job number
xlsheet.Cells(5, 2) = UCase(Username)
'enter Login Name
xlsheet.Cells(3, 2) = Date
'enter the date
xlbook.Close savechanges:=True
'save the changes in Excel
xlapp.Quit
'quit Excel
Set xlsheet = Nothing
Set xlbook = Nothing
Set axlapp = Nothing
'clean up
UserForm1.Hide
'hide the dialog box
If Not ThisDrawing.Saved Then
'if the current drawing is not saved
If MsgBox(" OK to Save Drawing?", 4) = vbNo Then
'do nothing

Else
ThisDrawing.Save
'if Yes save the drawing

End If
Timeshet Project
http://www.afralisp.com/vbaa/vba9.htm (3 of 5) [23/03/2005 05:45:28 p.m.]
End If
ThisDrawing.Application.Quit
'close the drawing and exit AutoCAD
End Sub
Private Sub CommandButton2_Click()
End
'end the application
End Sub
Private Sub UserForm_Initialize()
ElapseTime = ThisDrawing.GetVariable("TDUSRTIMER")
'get the elapsed time
Dwgname = ThisDrawing.GetVariable("DWGNAME")
'get the drawing number
Username = ThisDrawing.GetVariable("LOGINNAME")
'get the login name
UserForm1.TextBox2.Text = UCase(Dwgname)
'display the drawing number
UserForm1.TextBox3.Text = Format(ElapseTime, "h:m:s")
'display the elapsed time
UserForm1.TextBox4.Text = UCase(Username)
'display the login name
UserForm1.TextBox5.Text = Date
'display the date
UserForm1.TextBox1.Text = "Job No"
'display a default Job No value
UserForm1.TextBox1.SetFocus
'set the focus to the Job No text box
UserForm1.TextBox1.SelStart = 0
'select the start of the text
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)
'highlight the text
End Sub
You must also create a new module:
Sub timesheet ()
userform1.show
End Sub

Timeshet Project
http://www.afralisp.com/vbaa/vba9.htm (4 of 5) [23/03/2005 05:45:28 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Timeshet Project
http://www.afralisp.com/vbaa/vba9.htm (5 of 5) [23/03/2005 05:45:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Loading VBA Projects
When you load an AutoLisp file you just type (load "MYLISPFILE") and AutoCAD will find
the file and load it, as long as it is located within the AutoCAD search path.
Loading a VBA Project file though, is slightly different. AutoCAD will only search the
current working directory for the VBA file. The way to get around this, and to force
AutoCAD into searching the AutoCAD search path, is to use the "Findfile" function.
The following AutoLisp coding will load any VBA Project file that is within the AutoCAD
search path, run the Project and then unload it on completion.
Thanks to Randall Rath of VBDesign for this idea.
(defun c:ldvb ()
;define function
(setvar "CMDECHO" 0)
;switch off command echo
(if (findfile "yourproject.dvb")
;if the project file is found
;in your AutoCAD search path
(progn
;do the following
(setvar "FILEDIA" 0)
;switch off dialogue boxes
(command "_vbaload"
(findfile "yourproject.dvb"))
;load the project file
(command "-vbarun" "yourprojectmacro")
;run the project macro
(command "_vbaunload")
;unload the file
(setvar "FILEDIA" 1)
;switch dialogues back on
);progn
(princ "\nyourproject.dvb not found")
;if project not found, inform the user
);if
(setvar "CMDECHO" 1)
;switch command echo back on
(princ)
Loading VBA Projects
http://www.afralisp.com/vbaa/vba8.htm (1 of 2) [23/03/2005 05:45:30 p.m.]
;finish clean
);defun
(princ "\nyourproject.dvb Loaded")
;inform user
(princ "\nType 'Ldvb' to Run")
;tell him how to run it
(princ)
;load clean

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Loading VBA Projects
http://www.afralisp.com/vbaa/vba8.htm (2 of 2) [23/03/2005 05:45:30 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA and Excel (85 Kb)
This is a sample VBA routine written for AutoCAD Rel 14.
This application will demonstrate how to export data to Microsoft Excel, perform calculations on
that data and then re-import the results of the calculations back into AutoCAD.
Usage.
Unzip the files matlist.dvb, matlist.Lsp, matlist.Dwg and matlist.xls to your working directory.
Insert the matlist.Dwg. as a block into any drawing.
It should look like this :
Type (load "matlist") at the command prompt.
Type "matlist" to run the application.
(If you have problems when writing or running this projects, ensure that the Microsoft Excel 8.0
Object Library is selected in your VBA References.)
After running the application you can inspect the results of the exported data
in the file matlist.xls. It should look something like this:
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (1 of 7) [23/03/2005 05:45:32 p.m.]
The Source Code.
Public acad As Object
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public Theatts As Variant
Public MsgBoxResp As Integer
'declare global variables
Private Sub CommandButton1_Click()
UpdateAttrib 0, UserForm1.txt1.Text
UpdateAttrib 1, UserForm1.txt2.Text
UpdateAttrib 2, UserForm1.txt3.Text
UpdateAttrib 3, UserForm1.txt4.Text
UpdateAttrib 4, UserForm1.txt5.Text
UpdateAttrib 5, UserForm1.txt6.Text
UpdateAttrib 6, UserForm1.txt7.Text
UpdateAttrib 7, UserForm1.txt8.Text
UpdateAttrib 8, UserForm1.txt9.Text
UpdateAttrib 9, UserForm1.txt10.Text
UpdateAttrib 10, UserForm1.txt11.Text
UpdateAttrib 11, UserForm1.txt12.Text
UpdateAttrib 12, UserForm1.txt13.Text
UpdateAttrib 13, UserForm1.txt14.Text
UpdateAttrib 14, UserForm1.txt15.Text
UpdateAttrib 15, UserForm1.txt16.Text
UpdateAttrib 16, UserForm1.txt17.Text
UpdateAttrib 17, UserForm1.txt18.Text
UpdateAttrib 18, UserForm1.txt19.Text
UpdateAttrib 19, UserForm1.txt20.Text
UpdateAttrib 20, UserForm1.txt21.Text
UpdateAttrib 21, UserForm1.txt22.Text
UpdateAttrib 22, UserForm1.txt23.Text
UpdateAttrib 23, UserForm1.txt24.Text
UpdateAttrib 24, UserForm1.txt25.Text
UpdateAttrib 25, UserForm1.txt26.Text
UpdateAttrib 26, UserForm1.txt27.Text
UpdateAttrib 27, UserForm1.txt28.Text
UpdateAttrib 28, UserForm1.txt29.Text
UpdateAttrib 29, UserForm1.txt30.Text
UpdateAttrib 30, UserForm1.txt31.Text
UpdateAttrib 31, UserForm1.txt32.Text
UpdateAttrib 32, UserForm1.txt33.Text
UpdateAttrib 33, UserForm1.txt34.Text
UpdateAttrib 34, UserForm1.txt35.Text
UpdateAttrib 35, UserForm1.txt36.Text
'get the attribute values

ssnew.Item(0).Update
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (2 of 7) [23/03/2005 05:45:32 p.m.]
'update the attribute block

End
End Sub
Sub UpdateAttrib(TagNumber As Integer, BTextString As String)
'This Sub Procedure tests the attribute data to check
'that is not a null value

If BTextString = "" Then
'if the attribute is empty

Theatts(TagNumber).TextString = ""
'put a '-' place holder

Else
'if it is not empty

Theatts(TagNumber).TextString = BTextString
'use the attribute value

End If

End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub CommandButton3_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
'declare local variables
Set xlbook = GetObject("matlist.xls")
'set reference to Excel file
Set xlapp = xlbook.Parent
'set reference to workbook
xlapp.Visible = True
'make Excel visible
xlapp.Windows("MATLIST.XLS").Visible = True
'make the workbook visible
'the 2 preceeding lines can be commented out if you
'do not want to see Excel in action
Set xlsheet = xlbook.Sheets("SHEET1")
'set reference to the worksheet Sheet1
xlsheet.Cells(2, 1) = UserForm1.txt1.Text
xlsheet.Cells(3, 1) = UserForm1.txt8.Text
xlsheet.Cells(4, 1) = UserForm1.txt15.Text
xlsheet.Cells(5, 1) = UserForm1.txt22.Text
xlsheet.Cells(6, 1) = UserForm1.txt29.Text
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (3 of 7) [23/03/2005 05:45:32 p.m.]
xlsheet.Cells(2, 2) = UserForm1.txt2.Text
xlsheet.Cells(3, 2) = UserForm1.txt9.Text
xlsheet.Cells(4, 2) = UserForm1.txt16.Text
xlsheet.Cells(5, 2) = UserForm1.txt23.Text
xlsheet.Cells(6, 2) = UserForm1.txt30.Text
xlsheet.Cells(2, 3) = UserForm1.txt3.Text
xlsheet.Cells(3, 3) = UserForm1.txt10.Text
xlsheet.Cells(4, 3) = UserForm1.txt17.Text
xlsheet.Cells(5, 3) = UserForm1.txt24.Text
xlsheet.Cells(6, 3) = UserForm1.txt31.Text
xlsheet.Cells(2, 4) = UserForm1.txt4.Text
xlsheet.Cells(3, 4) = UserForm1.txt11.Text
xlsheet.Cells(4, 4) = UserForm1.txt18.Text
xlsheet.Cells(5, 4) = UserForm1.txt25.Text
xlsheet.Cells(6, 4) = UserForm1.txt32.Text
xlsheet.Cells(2, 5) = UserForm1.txt5.Text
xlsheet.Cells(3, 5) = UserForm1.txt12.Text
xlsheet.Cells(4, 5) = UserForm1.txt19.Text
xlsheet.Cells(5, 5) = UserForm1.txt26.Text
xlsheet.Cells(6, 5) = UserForm1.txt33.Text
xlsheet.Cells(2, 7) = UserForm1.txt7.Text
xlsheet.Cells(3, 7) = UserForm1.txt14.Text
xlsheet.Cells(4, 7) = UserForm1.txt21.Text
xlsheet.Cells(5, 7) = UserForm1.txt28.Text
xlsheet.Cells(6, 7) = UserForm1.txt35.Text
'fill the worksheet cells with the attribute values
UserForm1.txt6.Text = xlsheet.Cells(2, 6)
UserForm1.txt13.Text = xlsheet.Cells(3, 6)
UserForm1.txt20.Text = xlsheet.Cells(4, 6)
UserForm1.txt27.Text = xlsheet.Cells(5, 6)
UserForm1.txt34.Text = xlsheet.Cells(6, 6)
UserForm1.txt36.Text = xlsheet.Cells(7, 6)
'retrieve the calculated attribute values
xlbook.Close savechanges:=True
'save the changes in Excel
xlapp.Quit
'quit Excel
Set xlsheet = Nothing
Set xlbook = Nothing
Set axlapp = Nothing
'clean up
End Sub
Private Sub UserForm_Initialize()
Dim BlkG(0) As Integer
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
'declare local variables

Set acad = GetObject(, "AutoCAD.Application")
'set reference to AutoCAD
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (4 of 7) [23/03/2005 05:45:32 p.m.]

Set doc = acad.ActiveDocument
'set reference to the drawing

Set ms = doc.ModelSpace
'set reference to model space

Set ssnew = doc.SelectionSets.Add("TBLK")
'create a selection set

Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
Pt2(0) = 3: Pt2(1) = 3: Pt2(2) = 0
'set up the array

BlkG(0) = 2
'group code 2 for block name

TheBlock(0) = "MATLIST"
'the name of the attribute block

ssnew.Select 5, Pt1, Pt2, BlkG, TheBlock
'get the block

If ssnew.Count >= 1 Then
'if the block is found

Theatts = ssnew.Item(0).GetAttributes
'get the attributes

UserForm1.txt1.Text = UCase(LTrim(Theatts(0).TextString))
'get the title attribute
'clear any leading spaces and
'convert to uppercase

UserForm1.txt2.Text = UCase(LTrim(Theatts(1).TextString))
UserForm1.txt3.Text = UCase(LTrim(Theatts(2).TextString))
UserForm1.txt4.Text = UCase(LTrim(Theatts(3).TextString))
UserForm1.txt5.Text = UCase(LTrim(Theatts(4).TextString))
UserForm1.txt6.Text = UCase(LTrim(Theatts(5).TextString))
UserForm1.txt7.Text = UCase(LTrim(Theatts(6).TextString))
UserForm1.txt8.Text = UCase(LTrim(Theatts(7).TextString))
UserForm1.txt9.Text = UCase(LTrim(Theatts(8).TextString))
UserForm1.txt10.Text = UCase(LTrim(Theatts(9).TextString))
UserForm1.txt11.Text = UCase(LTrim(Theatts(10).TextString))
UserForm1.txt12.Text = UCase(LTrim(Theatts(11).TextString))
UserForm1.txt13.Text = UCase(LTrim(Theatts(12).TextString))
UserForm1.txt14.Text = UCase(LTrim(Theatts(13).TextString))
UserForm1.txt15.Text = UCase(LTrim(Theatts(14).TextString))
UserForm1.txt16.Text = UCase(LTrim(Theatts(15).TextString))
UserForm1.txt17.Text = UCase(LTrim(Theatts(16).TextString))
UserForm1.txt18.Text = UCase(LTrim(Theatts(17).TextString))
UserForm1.txt19.Text = UCase(LTrim(Theatts(18).TextString))
UserForm1.txt20.Text = UCase(LTrim(Theatts(19).TextString))
UserForm1.txt21.Text = UCase(LTrim(Theatts(20).TextString))
UserForm1.txt22.Text = UCase(LTrim(Theatts(21).TextString))
UserForm1.txt23.Text = UCase(LTrim(Theatts(22).TextString))
UserForm1.txt24.Text = UCase(LTrim(Theatts(23).TextString))
UserForm1.txt25.Text = UCase(LTrim(Theatts(24).TextString))
UserForm1.txt26.Text = UCase(LTrim(Theatts(25).TextString))
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (5 of 7) [23/03/2005 05:45:32 p.m.]
UserForm1.txt27.Text = UCase(LTrim(Theatts(26).TextString))
UserForm1.txt28.Text = UCase(LTrim(Theatts(27).TextString))
UserForm1.txt29.Text = UCase(LTrim(Theatts(28).TextString))
UserForm1.txt30.Text = UCase(LTrim(Theatts(29).TextString))
UserForm1.txt31.Text = UCase(LTrim(Theatts(30).TextString))
UserForm1.txt32.Text = UCase(LTrim(Theatts(31).TextString))
UserForm1.txt33.Text = UCase(LTrim(Theatts(32).TextString))
UserForm1.txt34.Text = UCase(LTrim(Theatts(33).TextString))
UserForm1.txt35.Text = UCase(LTrim(Theatts(34).TextString))
UserForm1.txt36.Text = UCase(LTrim(Theatts(35).TextString))

UserForm1.txt1.SetFocus
UserForm1.txt1.SelStart = 0
UserForm1.txt1.SelLength = Len(UserForm1.txt1.Text)
'set the focus to the drawing title and highlight it

Else
'if no attribute title block is found

MsgBox "Sorry - No Material List Attributes....", vbCritical, _
"AfraLisp Tutorial"
'inform the user that there is no attribute title block

ThisDrawing.SelectionSets("TBLK").Delete
End
'end the application

End If

ThisDrawing.SelectionSets("TBLK").Delete
End Sub

Now create a Module named Tblock :


Sub matlist()
UserForm1.Show
End Sub
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (6 of 7) [23/03/2005 05:45:32 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and Excel
http://www.afralisp.com/vbaa/vba7.htm (7 of 7) [23/03/2005 05:45:32 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA and DataBases (67kb)
This is a sample VBA routine written for AutoCAD Rel 14, 2000, 2000i and 2002.
This application will demonstrate how to import and export Title Block attribute data, to and from an Access 2000
database.
Usage AutoCAD 14 and 2000.
Unzip the files Tblock2000.dvb, Tblock2000.Lsp, Tblock.Dwg and Tblock.Mdb to your working directory.
Insert the Tblock.Dwg. as a block into any drawing.
Usage AutoCAD 2000i and 2002.
Unzip the files Tblock2002.dvb, Tblock2002.Lsp, Tblock.Dwg and Tblock.Mdb to your working directory.
Insert the Tblock.Dwg. as a block into any drawing.
It should look like this :
Type (load "tblock2000(2)") at the command prompt.
Type "tblock2000(2)" to run the application.
(If you have problems when writing or running this projects, ensure that the Microsoft DAO 3.6 Object Library is
selected in your VBA References.)
The Source Code.
VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (1 of 6) [23/03/2005 05:45:37 p.m.]
Public acad As Object
Public doc As Object
Public ms As Object
Public ss As Object
Public ssnew As Object
Public Theatts As Variant
Public MsgBoxResp As Integer
Public dbInfo As Database
Public rsInfo As Recordset
'declare global variables
Private Sub CommandButton1_Click()
UpdateAttrib 0, UserForm1.TextBox1.Text
UpdateAttrib 1, UserForm1.TextBox2.Text
UpdateAttrib 2, UserForm1.TextBox3.Text
UpdateAttrib 3, UserForm1.TextBox4.Text
UpdateAttrib 4, UserForm1.TextBox5.Text
'get the attribute values

ssnew.Item(0).Update
'update the attribute block

End
End Sub
Sub UpdateAttrib(TagNumber As Integer, BTextString As String)
'This Sub Procedure tests the attribute data to check
'that is not a null value

If BTextString = "" Then
'if the attribute is empty

Theatts(TagNumber).TextString = "-"
'put a '-' place holder

Else
'if it is not empty

Theatts(TagNumber).TextString = BTextString
'use the attribute value
ThisDrawing.SelectionSets.Item("TBLK").Delete
'delete the block

End If

End Sub
Private Sub CommandButton2_Click()
ThisDrawing.SelectionSets.Item("TBLK").Delete
End
End Sub
Private Sub CommandButton3_Click()
Dim DrgNumber As String
Dim Msg As String
Dim Msg1 As String
Dim Style As String
Dim TitleLine As String
VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (2 of 6) [23/03/2005 05:45:37 p.m.]
Dim Response As String
'declare local variables
DrgNumber = UserForm1.TextBox2.Text
'get the drawing number
Set dbInfo = OpenDatabase("TBLOCK.MDB")
'set the reference to the database
'if the database is not an Access dadtabase use the following line
'Set dbInfo = OpenDatabase("
'C:\DATABASE PATH\", False, False, "dBASE III;C:\DATABASE PATH\TBLOCK.DBF;")
Set rsInfo = dbInfo.OpenRecordset("SELECT *
FROM TITLEBLOCK WHERE DRGNO = '" & DrgNumber & "'", dbOpenDynaset)
'search for the drawing number
UserForm1.Hide
'hide the dialogue box
If (rsInfo.RecordCount <> 0) Then
'if the drawing number is found
Msg = "Drawing already Exists in the DataBase."
Msg1 = "Would you like to Update the Drawing Details?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
Title = "Existing Entry in DataBase"
'set variables for message box

Response = MsgBox(Msg & Chr(13) & Chr(10) & Msg1, Style, Title)
'display the message box

If Response = vbYes Then
'if the user wants to update the database

UserForm1.rsInfo.Edit
'open the database for edit
'-------------------
'this section is for AutoCAD 14/2000
UserForm1.rsInfo("TITLE") = UserForm1.TextBox1.Text
UserForm1.rsInfo("DRGNO") = UserForm1.TextBox2.Text
UserForm1.rsInfo("DATE") = UserForm1.TextBox3.Text
UserForm1.rsInfo("DRAWN") = UserForm1.TextBox4.Text
UserForm1.rsInfo("SCALE") = UserForm1.TextBox5.Text
'get the field values
'--------------------
'For AutoCAD 2000i/2002 replace the preceding section with this :
'UserForm1.rsInfo.Fields("TITLE") = UserForm1.TextBox1.Text
'UserForm1.rsInfo.Fields("DRGNO") = UserForm1.TextBox2.Text
'UserForm1.rsInfo.Fields("DATE") = UserForm1.TextBox3.Text
'UserForm1.rsInfo.Fields("DRAWN") = UserForm1.TextBox4.Text
'UserForm1.rsInfo.Fields("SCALE") = UserForm1.TextBox5.Text
'get the field values
'---------------------

UserForm1.rsInfo.Update
'update the database

MsgBox ("DataBase has been Updated"), , "Update DataBase"
'inform the user

VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (3 of 6) [23/03/2005 05:45:37 p.m.]
UserForm1.Show
'reinstate the dialogue box

Else
'if the user does not want to update

UserForm1.Show
'reinstate the dialogue

End If
Else
'if the drawing number has not been found

Msg = "Drawing has not been Entered Into DataBase."
Msg1 = "Would you like to Enter the Drawing Details?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
Title = "New Entry in DataBase"
'set up the message box variables

Response = MsgBox(Msg & Chr(13) & Chr(10) & Msg1, Style, Title)
'display the message box
If Response = vbYes Then
'if the user wants to enter the drawing details

UserForm1.rsInfo.AddNew
'open the dtabase to add a new record

'-------------------
'this section is for AutoCAD 14/2000
UserForm1.rsInfo("TITLE") = UserForm1.TextBox1.Text
UserForm1.rsInfo("DRGNO") = UserForm1.TextBox2.Text
UserForm1.rsInfo("DATE") = UserForm1.TextBox3.Text
UserForm1.rsInfo("DRAWN") = UserForm1.TextBox4.Text
UserForm1.rsInfo("SCALE") = UserForm1.TextBox5.Text
'get the field values
'--------------------
'For AutoCAD 2000i/2002 replace the preceding section with this :
'UserForm1.rsInfo.Fields("TITLE") = UserForm1.TextBox1.Text
'UserForm1.rsInfo.Fields("DRGNO") = UserForm1.TextBox2.Text
'UserForm1.rsInfo.Fields("DATE") = UserForm1.TextBox3.Text
'UserForm1.rsInfo.Fields("DRAWN") = UserForm1.TextBox4.Text
'UserForm1.rsInfo.Fields("SCALE") = UserForm1.TextBox5.Text
'get the field values
'---------------------

UserForm1.rsInfo.Update
'update the database

MsgBox ("Drawing has been Entered into DataBase"), ,
"Enter Into DataBase"
'inform the user

UserForm1.Show
'reinstate the dialogue box

Else
'if the user does not want to enter the drawing details

UserForm1.Show
'reinstate the dialoge box

End If
End If
VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (4 of 6) [23/03/2005 05:45:37 p.m.]
End Sub
Private Sub UserForm_Initialize()
Dim BlkG(0) As Integer
Dim TheBlock(0) As Variant
Dim Pt1(0 To 2) As Double
Dim Pt2(0 To 2) As Double
'declare local variables

Set acad = GetObject(, "AutoCAD.Application")
'set reference to AutoCAD

Set doc = acad.ActiveDocument
'set reference to the drawing

Set ms = doc.ModelSpace
'set reference to model space

Set ssnew = doc.SelectionSets.Add("TBLK")
'create a selection set

Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
Pt2(0) = 3: Pt2(1) = 3: Pt2(2) = 0
'set up the array

BlkG(0) = 2
'group code 2 for block name

TheBlock(0) = "TBLOCK"
'the name of the attribute block

ssnew.Select 5, Pt1, Pt2, BlkG, TheBlock
'get the block

If ssnew.Count >= 1 Then
'if the block is found

Theatts = ssnew.Item(0).GetAttributes
'get the attributes

UserForm1.TextBox1.Text = UCase(LTrim(Theatts(0).TextString))
'get the title attribute
'clear any leading spaces and
'convert to uppercase


UserForm1.TextBox2.Text = UCase(LTrim(Theatts(1).TextString))
'get the drawing number attribute
'clear any leading spaces and
'convert to uppercase

UserForm1.TextBox3.Text = Date
'get todays date

UserForm1.TextBox4.Text = UCase(LTrim(Theatts(3).TextString))
'get the draughtsmans name
'clear any leading spaces and
'convert to uppercase

UserForm1.TextBox5.Text = "1:" & CStr(doc.GetVariable("DIMSCALE"))
'get the drawing scale, convert it to a string
VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (5 of 6) [23/03/2005 05:45:37 p.m.]
'and prefix it with 1:


UserForm1.TextBox1.SetFocus
UserForm1.TextBox1.SelStart = 0
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)
'set the focus to the drawing title and highlight it

Else
'if no attribute title block is found

MsgBox "Sorry - No Title Block Attributes....", vbCritical,
"AfraLisp Tutorial"
'inform the user that there is no attribute title block

End
'end the program

End If

End Sub
Create a new module and add this :
Sub TBlock()
UserForm1.Show
End Sub

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA and DataBases
http://www.afralisp.com/vbaa/vba6.htm (6 of 6) [23/03/2005 05:45:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VBA Steel Project (28 Kb)
This is a sample VBA routine written for AutoCAD Rel 14.
This application will parametrically draw metric structural steel sections and is intended as an aid
towards a better understanding of VBA and AutoCAD.
Usage.
Unzip the files VbaSteel.dvb and VbaSteel.Lsp to any directory in your AutoCAD search path.
Type (load "vbasteel") at the command prompt.
Type "vbasteel" to run the application.
The Source Code.
Private Sub cmdCancel1_Click()
Me.Hide
UserForm2.Show
End Sub
Private Sub cmdOK1_Click()
Const PI = 3.141592654
'define PI as constant
Dim Height As Double
Dim Width As Double
Dim t1 As Double
Dim t2 As Double
Dim r1 As Double
Dim acadApp As Object
Dim acadDoc As Object
Dim acadUtil As Object
Dim inPnt As Variant
Dim North As Variant
Dim South As Variant
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (1 of 7) [23/03/2005 05:45:39 p.m.]
Dim West As Variant
Dim East As Variant
'declare variables
West = (PI * (180# / 180#))
'convert 180 degrees to radians
North = (PI * (90# / 180#))
'Convert 90 degrees to radians
East = 0
'convert 0 degrees to radians
South = (PI * (270# / 180#))
'convert 270 degrees to radians
NL = Chr(13) & Chr(10)
'define New Line
prompt1 = NL & "Insertion Point: "
'define prompt
Set acadApp = GetObject(, "AutoCAD.Application")
'get reference to AutoCAD
Set acadDoc = acadApp.ActiveDocument
'get reference to Drawing
Set acadUtil = acadDoc.Utility
'get reference to Utility Object
Me.Hide
'hide the dialogue
Select Case ListBox1.ListIndex
'use the select case function to retrieve
'section choosen in list box
Case 0
'if case index = 0
Height = 152.4
'set height

Width = 152.4
'set width

t1 = 6.1
'set web thickness

t2 = 6.8
'set flange thickness

r1 = 7.6
'set root radius

Case 1
Height = 157.5
Width = 152.9
t1 = 6.6
t2 = 6.4
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (2 of 7) [23/03/2005 05:45:39 p.m.]
r1 = 7.6
Case 2
Height = 161.8
Width = 154.4
t1 = 8.1
t2 = 11.5
r1 = 7.6
Case 3
Height = 203.2
Width = 203.2
t1 = 7.3
t2 = 11#
r1 = 10.2
Case 4
Height = 206.2
Width = 203.9
t1 = 8#
t2 = 12.5
r1 = 10.2
Case 5
Height = 209.6
Width = 205.2
t1 = 9.3
t2 = 14.2
r1 = 10.2
End Select
'end select case
inPnt = acadUtil.GetPoint(, prompt1)
'get the insertion point
Dim inPntv(0 To 2) As Double
'declare point variable
For i = 0 To 2
'convert x, y & z from variables to doubles
inPntv(i) = inPnt(i)
Next
Dim pt1 As Variant
'declare variants
pt1 = acadUtil.PolarPoint(inPntv, East, t1 / 2)
'use polar function to calculate point
Dim pt1v(0 To 2) As Double
For i = 0 To 2
pt1v(i) = pt1(i)
Next
Dim pt2 As Variant
pt2 = acadUtil.PolarPoint(pt1v, North, (Height - t2 - t2) / 2)
Dim pt2v(0 To 2) As Double
For i = 0 To 2
pt2v(i) = pt2(i)
Next
Dim pt2a As Variant
Dim pt2b As Variant
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (3 of 7) [23/03/2005 05:45:39 p.m.]
Dim pt3 As Variant
pt2a = acadUtil.PolarPoint(pt2v, South, r1)
pt2b = acadUtil.PolarPoint(pt2v, East, r1)
pt3 = acadUtil.PolarPoint(pt2v, East, (Width - t1) / 2)
Dim pt3v(0 To 2) As Double
For i = 0 To 2
pt3v(i) = pt3(i)
Next
Dim pt4 As Variant
pt4 = acadUtil.PolarPoint(pt3v, North, t2)
Dim pt4v(0 To 2) As Double
For i = 0 To 2
pt4v(i) = pt4(i)
Next
Dim pt5 As Variant
pt5 = acadUtil.PolarPoint(pt4v, West, Width)
Dim pt5v(0 To 2) As Double
For i = 0 To 2
pt5v(i) = pt5(i)
Next
Dim pt6 As Variant
pt6 = acadUtil.PolarPoint(pt5v, South, t2)
Dim pt6v(0 To 2) As Double
For i = 0 To 2
pt6v(i) = pt6(i)
Next
Dim pt7 As Variant
pt7 = acadUtil.PolarPoint(pt6v, East, (Width - t1) / 2)
Dim pt7v(0 To 2) As Double
For i = 0 To 2
pt7v(i) = pt7(i)
Next
Dim pt7a As Variant
Dim pt7b As Variant
Dim pt8 As Variant
pt7a = acadUtil.PolarPoint(pt7v, West, r1)
pt7b = acadUtil.PolarPoint(pt7v, South, r1)
pt8 = acadUtil.PolarPoint(pt7v, South, Height - t2 - t2)
Dim pt8v(0 To 2) As Double
For i = 0 To 2
pt8v(i) = pt8(i)
Next
Dim pt8a As Variant
Dim pt8b As Variant
Dim pt9 As Variant
pt8a = acadUtil.PolarPoint(pt8v, North, r1)
pt8b = acadUtil.PolarPoint(pt8v, West, r1)
pt9 = acadUtil.PolarPoint(pt8v, West, (Width - t1) / 2)
Dim pt9v(0 To 2) As Double
For i = 0 To 2
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (4 of 7) [23/03/2005 05:45:39 p.m.]
pt9v(i) = pt9(i)
Next
Dim pt10 As Variant
pt10 = acadUtil.PolarPoint(pt9v, South, t2)
Dim pt10v(0 To 2) As Double
For i = 0 To 2
pt10v(i) = pt10(i)
Next
Dim pt11 As Variant
pt11 = acadUtil.PolarPoint(pt10v, East, Width)
Dim pt11v(0 To 2) As Double
For i = 0 To 2
pt11v(i) = pt11(i)
Next
Dim pt12 As Variant
pt12 = acadUtil.PolarPoint(pt11v, North, t2)
Dim pt12v(0 To 2) As Double
For i = 0 To 2
pt12v(i) = pt12(i)
Next
Dim pt13 As Variant
pt13 = acadUtil.PolarPoint(pt12v, West, (Width - t1) / 2)
Dim pt13v(0 To 2) As Double
For i = 0 To 2
pt13v(i) = pt13(i)
Next
Dim pt13a As Variant
Dim pt13b As Variant
pt13a = acadUtil.PolarPoint(pt13v, East, r1)
pt13b = acadUtil.PolarPoint(pt13v, North, r1)
Dim moSpace As Object
'declare model space object
Set moSpace = acadDoc.ModelSpace
'get the model space object
Dim lwpolyObj As Object
'declare the light weight polyline object
Dim ptArray(0 To 35) As Double
'declare the array of doubles
ptArray(0) = pt1(0)
'set the array points
ptArray(1) = pt1(1)
ptArray(2) = pt2a(0)
ptArray(3) = pt2a(1)
ptArray(4) = pt2b(0)
ptArray(5) = pt2b(1)
ptArray(6) = pt3(0)
ptArray(7) = pt3(1)
ptArray(8) = pt4(0)
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (5 of 7) [23/03/2005 05:45:39 p.m.]
ptArray(9) = pt4(1)
ptArray(10) = pt5(0)
ptArray(11) = pt5(1)
ptArray(12) = pt6(0)
ptArray(13) = pt6(1)
ptArray(14) = pt7a(0)
ptArray(15) = pt7a(1)
ptArray(16) = pt7b(0)
ptArray(17) = pt7b(1)
ptArray(18) = pt8a(0)
ptArray(19) = pt8a(1)
ptArray(20) = pt8b(0)
ptArray(21) = pt8b(1)
ptArray(22) = pt9(0)
ptArray(23) = pt9(1)
ptArray(24) = pt10(0)
ptArray(25) = pt10(1)
ptArray(26) = pt11(0)
ptArray(27) = pt11(1)
ptArray(28) = pt12(0)
ptArray(29) = pt12(1)
ptArray(30) = pt13a(0)
ptArray(31) = pt13a(1)
ptArray(32) = pt13b(0)
ptArray(33) = pt13b(1)
ptArray(34) = pt1(0)
ptArray(35) = pt1(1)
Set lwpolyObj = moSpace.AddLightWeightPolyline(ptArray)
'draw the beam
Dim newBulge As Double
'declare the bulge (Radius)
newBulge = 0 - (Tan(1.570796327 / 4))
'Calculate the bulge (radius)
Call lwpolyObj.SetBulge(1, newBulge)
'radius vertice number 1
Call lwpolyObj.SetBulge(7, newBulge)
'radius vertice number 7
Call lwpolyObj.SetBulge(9, newBulge)
'radius vertice number 9
Call lwpolyObj.SetBulge(15, newBulge)
'radius vertice number 15
Rot = CDbl(Txb1.Text)
'get the rotation angle and convert
'to double
Rot1 = PI * (Rot / 180)
'convert to radians
Call lwpolyObj.Rotate(inPntv, Rot1)
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (6 of 7) [23/03/2005 05:45:39 p.m.]
'rotate the beam
End Sub
Private Sub ListBox1_Click()
Txb1.SetFocus
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
cmdOK1_Click
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
'add the beam sizes to the list box
ListBox1.AddItem "152x152x23"
ListBox1.AddItem "152x152x30"
ListBox1.AddItem "152x152x37"
ListBox1.AddItem "203x203x46"
ListBox1.AddItem "203x203x52"
ListBox1.AddItem "203x203x60"
ListBox1.ListIndex = 0
End Sub

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VBA Steel Project
http://www.afralisp.com/vbaa/vba5.htm (7 of 7) [23/03/2005 05:45:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Drawing Setup Project (119 Kb)
This is a Drawing Setup Routine written in VBA for AutoCAD R14.
The user is given a choice of 4 Drawing Sheets, 5 Drawing Sizes, and a Drawing Scale Factor. All sizes
are Metric.
Usage.
Unzip the files to a temporary directory.
Copy all DWT (Drawing Template files) to the Template drawing sub-directory in you AutoCAD Rel
14 directory. (No files will be overwritten.)
Copy VbaSetup.dvb and VbaSetup.Lsp to any directory in your AutoCAD search path.
Type (load "vbasetup") at the command prompt.
Type "vbasetup" to run the application.
The Source Code.
Private Sub cmdCancel_Click()
End
End Sub
Private Sub cmdOk_Click()
Dim acadApp As Object
Dim acadDoc As Object
Dim templateFileName As String
Dim DrgSheet As String
Dim DrgSize As String
Dim newLimits(0 To 3) As Double
Dim pViewport As Object
Dim sc As Double
Dim oldTextStyle As Object
Dim Blockref As Object
Dim InsertionPoint(0 To 2) As Double
Drawing Setup Project
http://www.afralisp.com/vbaa/vba4.htm (1 of 5) [23/03/2005 05:45:41 p.m.]
Dim Mspace As Object
Dim Insertsheet As String
'declare variables
Me.Hide
'hide the dialogue box
Set acadApp = GetObject(, "AutoCAD.Application")
'setq reference to AutoCAD Application
If Err Then
'if there is another error
MsgBox Err.Description
'inform user
Exit Sub
'exit application
End If
Set acadDoc = acadApp.ActiveDocument
'set reference to active document
If Not acadDoc.Saved Then
'if the current drawing is not saved
If MsgBox(" OK to Save Drawing?", 4) = vbNo Then
'ask the user what he wants to do

End
'if No end application

Else
acadDoc.Save
'if Yes save the drawing

End If
End If
sc = CDbl(TextBox1.Text)
'get the scale and convert to double
If Opt1.Value = True Then
'if this button selected
DrgSheet = "E"
'set first letter of drawing sheet

templateFileName = "acadeng.dwt"
'set the relevant template file

Set doc = acadDoc.New(templateFileName)
'open new drawing with selected template file

End If
If Opt2.Value = True Then
Drawing Setup Project
http://www.afralisp.com/vbaa/vba4.htm (2 of 5) [23/03/2005 05:45:41 p.m.]
DrgSheet = "A"
templateFileName = "acadarch.dwt"
Set doc = acadDoc.New(templateFileName)
End If
If Opt3.Value = True Then
DrgSheet = "EL"
templateFileName = "acadelec.dwt"
Set doc = acadDoc.New(templateFileName)
End If
If Opt4.Value = True Then
DrgSheet = "B"
templateFileName = "acadblank.dwt"
Set doc = acadDoc.New(templateFileName)
End If
Select Case ListBox1.ListIndex
'get the item selected from list box
Case 0
'if the index is 0 (first item)
DrgSize = "A0"
'set the drawing size

newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 1189# * sc
newLimits(3) = 841# * sc
'set the limits

Set oldTextStyle = acadDoc.ActiveTextStyle
'get the current text style

Case 1
DrgSize = "A1"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 841# * sc
newLimits(3) = 594# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 2
DrgSize = "A2"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 594# * sc
newLimits(3) = 420# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 3
DrgSize = "A3"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 420# * sc
newLimits(3) = 297# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 4
DrgSize = "A4"
newLimits(0) = 0#
newLimits(1) = 0#
Drawing Setup Project
http://www.afralisp.com/vbaa/vba4.htm (3 of 5) [23/03/2005 05:45:41 p.m.]
newLimits(2) = 297# * sc
newLimits(3) = 210# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
End Select
acadDoc.Limits = newLimits
'set drawing limits
Set pViewport = acadDoc.ActiveViewport
'get reference to viewports
pViewport.ZoomExtents
'zoom to extents
Call acadDoc.SetVariable("Ltscale", sc * 10)
'set Ltscale
Call acadDoc.SetVariable("Dimscale", sc)
'set Dimscale
Call acadDoc.SetVariable("Userr1", sc)
'store scale in Userr1 for later use
Call acadDoc.SetVariable("Regenmode", 1)
'set Regenmode
Call acadDoc.SetVariable("Tilemode", 1)
'set Tilemode
oldTextStyle.Height = 3.5 * sc
'set Text Height
Insertsheet = DrgSheet & DrgSize
'String Drawing Sheet Name Together
InsertionPoint(0) = 0
InsertionPoint(1) = 0
InsertionPoint(2) = 0
'set the insertion point
Set Mspace = acadDoc.ModelSpace
'get reference to Model Space
Set Blockref = Mspace.InsertBlock(InsertionPoint, Insertsheet, sc, sc, 0)
'Insert the drawing sheet
'MsgBox ("Drawing Setup Complete"), , "AfraLisp Drawing Setup"
End
End Sub
Private Sub ListBox1_Click()
TextBox1.SetFocus
End Sub
Drawing Setup Project
http://www.afralisp.com/vbaa/vba4.htm (4 of 5) [23/03/2005 05:45:41 p.m.]
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
cmdOk_Click
End Sub
Private Sub Opt1_Click()
TextBox1.SetFocus
End Sub
Private Sub Opt2_Click()
TextBox1.SetFocus
End Sub
Private Sub Opt3_Click()
TextBox1.SetFocus
End Sub
Private Sub Opt4_Click()
TextBox1.SetFocus
End Sub
Private Sub UserForm_Initialize()
ListBox1.AddItem "A0 - 1189 x 841"
ListBox1.AddItem "A1 - 841 x 594"
ListBox1.AddItem "A2 - 594 x 420"
ListBox1.AddItem "A3 - 420 x 297"
ListBox1.AddItem "A4 - 297 x 210"
ListBox1.ListIndex = 0
End Sub

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Setup Project
http://www.afralisp.com/vbaa/vba4.htm (5 of 5) [23/03/2005 05:45:41 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp/VBA Drawing Setup
A well written drawing setup routine can save hours in any drawing office and is invaluable when it
comes to enforcing drawing office standards. There is nothing worse than a drawing office where
everybody "does there own thing" in regards to drawing setups. As well as this, a setup routine and
template drawings/drawing sheets can be given to third party companies to ensure that they comply
with your standards and specifications. This month we're going to have a look at a simple but powerful
setup routine first written in plain old AutoLisp and then written using the Dark Side - otherwise known
as VBA for the uninitiated. Let's have a look at the program in action :
Usage :
Select your Drawing Sheet type first,
then the Drawing Size, select a Scale
and then the OK button and away you
go.
To use your own drawing sheets in this
routine, please refer to the Readme file
which is included within the
downloadable drawing sheet zip file.
(The download link is at the bottom of
the next page - hey, we have to make
sure you read everything.)

This program not only inserts a chosen type and size of drawing sheet into your drawing, but also sets
your text height and dimension scaling to suit the scale factor.
You can even preset your own system variables within the program. Go for it, it's yours for ever and
ever to do with as you wish.
First the DCL coding.
Copy and paste this into Notepad and save it as "ALSetup.dcl."
//DCL CODING STARTS HERE
alsetup : dialog {
label = "CAD Encoding Drawing Setup";
: row {
: boxed_radio_column {
label = "Choose Sheet";
: radio_button {
label = "&Engineering Sheets";
key = "rb1";
value = "1";
}
: radio_button {
label = "&Architectural Sheets";
AutoLisp/VBA Drawing Setup Page I
http://www.afralisp.com/lisp/setup1.htm (1 of 5) [23/03/2005 05:45:45 p.m.]
key = "rb2";
}
: radio_button {
label = "&Electrical Sheets";
key = "rb4";
}
: radio_button {
label = "&Blank Sheets";
key = "rb5";
}
}
: boxed_radio_column {
label = "Choose Size :";
: radio_button {
label = "A&0 - 1189 x 841";
key = "rb6";
value = "1";
}
: radio_button {
label = "A&1 - 841 x 594";
key = "rb7";
}
: radio_button {
label = "A&2 - 594 x 420";
key = "rb8";
}
: radio_button {
label = "A&3 - 420 x 297";
key = "rb9";
}
: radio_button {
label = "A&4 - 297 x 210";
key = "rb10";
}
}
}
: edit_box {
label = "&Enter Drawing Scale :" ;
key = "eb1" ;
edit_width = 8 ;
}
:spacer { width = 1;}
ok_cancel ;
: paragraph {
: text_part {
label = "Designed and Created";
}
: text_part {
label = "by CAD Encoding";
}
AutoLisp/VBA Drawing Setup Page I
http://www.afralisp.com/lisp/setup1.htm (2 of 5) [23/03/2005 05:45:45 p.m.]
}
}
//DCL CODING ENDS HERE
And next, here's the AutoLisp coding. No Visual Lisp this time, just plain AutoLisp. ("Phew," I can hear a
lot of you saying, wiping your delicate brows in relief.)
Copy and paste this into Notepad and save it as "ALSetup.lsp."
;CODING STARTS HERE
(prompt "\nCAD Encoding Setup loaded - Type \"ALSETUP\" to run....")
(defun C:ALSETUP ( / userclick dcl_id siz typ x y l size n oldblip
oldecho oldsnap #dwgsc)
;save system settings
(setq oldblip (getvar "BLIPMODE")
oldecho (getvar "CMDECHO")
oldsnap (getvar "OSMODE")
);setq
;set system variables
(setvar "BLIPMODE" 0)
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
;load the dialog
(setq dcl_id (load_dialog "alsetup.dcl"))
(if (not (new_dialog "alsetup" dcl_id))
(exit)
);if
;define default settings
(set_tile "rb1" "1")
(set_tile "rb6" "1")
(set_tile "eb1" "1")
(mtile)
(setq siz "A0")
(setq typ "e")
;define radio buttons action statements
(action_tile "rb1" "(setq typ \"e\") (mtile)")
(action_tile "rb2" "(setq typ \"a\") (mtile)")
(action_tile "rb4" "(setq typ \"el\") (mtile)")
(action_tile "rb5" "(setq typ \"b\") (mtile)")
(action_tile "rb6" "(setq siz \"A0\") (mtile)")
(action_tile "rb7" "(setq siz \"A1\") (mtile)")
(action_tile "rb8" "(setq siz \"A2\") (mtile)")
(action_tile "rb9" "(setq siz \"A3\") (mtile)")
(action_tile "rb10" "(setq siz \"A4\") (mtile)")
;define Cancel action statements
(action_tile "cancel"
AutoLisp/VBA Drawing Setup Page I
http://www.afralisp.com/lisp/setup1.htm (3 of 5) [23/03/2005 05:45:45 p.m.]
"(done_dialog)(setq userclick nil)")
;define OK action statements
(action_tile "accept"
(strcat
"(progn (setq #dwgsc (atof (get_tile \"eb1\")))"
"(done_dialog) (setq userclick T))"
);progn
)
;display the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;check the flag setting
(if userclick
;if it's set, do the following
(progn
;set up the sheet size
(cond
((= siz "A0") (setq x 1189.0 y 841.0))
((= siz "A1") (setq x 841.0 y 594.0))
((= siz "A2") (setq x 594.0 y 420.0))
((= siz "A3") (setq x 420.0 y 297.0))
((= siz "A4") (setq x 297.0 y 210.0))
);cond

;Construct drawing sheet name
(setq size (strcat typ siz))
;set system variables according to scale
(setvar "DIMSCALE" #dwgsc)
(setvar "USERR1" #dwgsc)
(setvar "LTSCALE" (* #dwgsc 10))
(setvar "REGENMODE" 1)
(setvar "TILEMODE" 1)
(setq n (* 3.5 #dwgsc))
;define the limits list
(setq L (list (* x #dwgsc) (* y #dwgsc)))
;set up the drawing
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict" "italict" N "" "" "" "" ""
"INSERT" size "0,0" #dwgsc "" "" )
;inform the user
(prompt "\n ")
(prompt "\nOkay - Setup Routine Complete")

);progn
AutoLisp/VBA Drawing Setup Page I
http://www.afralisp.com/lisp/setup1.htm (4 of 5) [23/03/2005 05:45:45 p.m.]
);if
;reset system variables
(setvar "BLIPMODE" oldblip)
(setvar "CMDECHO" oldecho)
(setvar "OSMODE" oldsnap)
;finish clean
(princ)
);defun
;;;---------------------------
;function to set the focus to
;the scale edit box
(defun mtile ()
(mode_tile "eb1" 2)
);defun
;;;--------------------------
;load clean
(princ)
;CODING ENDS HERE
Store both files and the drawing sheet files in a directory within your AutoCAD search path. Now type
(load "ALSetup") at the AutoCAD command prompt, and then "ALSetup" to run the setup program.
On the next page we'll have a look at doing the same thing using VBA, but this time we'll make use of
drawing template files.
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp/VBA Drawing Setup Page I
http://www.afralisp.com/lisp/setup1.htm (5 of 5) [23/03/2005 05:45:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp/VBA Drawing Setup II
Welcome to the Dark Side!!
Just to be different, instead of using drawing files, this time we are going to use drawing template files within our
setup routine.
As well as that, just to show off, we are going to make our dialog a wee bit more colorful than the boring old
AutoLisp dialog. (eat your hearts out Lispers.)
Okay, here's a preview of what our dialog will look like on completion :
Usage :
Select your Drawing Sheet type first,
then the Drawing Size, select a Scale
and then the OK button and away you
go.
To use your own template drawings in
this routine, please refer to the Readme
file which is included within the
downloadable drawing sheet zip file.
(The download link is at the bottom of
this page )

As for the AutoLisp version, you can customise this program to your little hearts desire.
Right, let's have a look at a wee bit of coding. Fire up AutoCAD and open a new Project in the Visual Basic Editor.
First you need to insert a new UserForm keeping the default name. (UserForm1)
Now add the following controls, naming them as shown :
Button - "cmdOk" G
Button - "cmdCancel" G
Frame containing 4 Option Buttons - "Opt1", "Opt2", "Opt3" and "Opt4". G
Listbox - "Listbox1" G
Edit Box - "Textbox1" G
Now add the following coding under General Declarations :
Option Explicit
'------------------------------------------------
Private Sub cmdCancel_Click()
End
End Sub
'-------------------------------------------------
Private Sub cmdOk_Click()
'declare variables
Dim acadApp As Object
Dim acadDoc As Object
Dim doc As Object
Dim templateFileName As String
Dim DrgSheet As String
AutoLisp/VBA Drawing Setup Page II
http://www.afralisp.com/lisp/setup2.htm (1 of 5) [23/03/2005 05:45:47 p.m.]
Dim DrgSize As String
Dim newLimits(0 To 3) As Double
Dim sc As Double
Dim oldTextStyle As Object
Dim Blockref As Object
Dim InsertionPoint(0 To 2) As Double
Dim Mspace As Object
Dim Insertsheet As String
'hide the dialogue box
Me.Hide
'set a reference to the AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application")
'if there is an error
If Err Then

'inform user
MsgBox Err.Description

'exit application
Exit Sub

End If
'set reference to active document
Set acadDoc = acadApp.ActiveDocument
'if the current drawing is not saved
If Not acadDoc.Saved Then
'ask the user what he wants to do
If MsgBox(" OK to Save Drawing?", 4) = vbNo Then

'if No end application
End

Else
'if Yes save the drawing
acadDoc.Save

End If
End If
'get the scale and convert to double
sc = CDbl(TextBox1.Text)
'if this button selected
If Opt1.Value = True Then
'set first letter of drawing sheet
DrgSheet = "E"

'set the relevant template file
templateFileName = "acadeng.dwt"

'open new drawing with selected template file
Set doc = acadDoc.New(templateFileName)

End If
AutoLisp/VBA Drawing Setup Page II
http://www.afralisp.com/lisp/setup2.htm (2 of 5) [23/03/2005 05:45:47 p.m.]
If Opt2.Value = True Then
DrgSheet = "A"
templateFileName = "acadarch.dwt"
Set doc = acadDoc.New(templateFileName)
End If
If Opt3.Value = True Then
DrgSheet = "EL"
templateFileName = "acadelec.dwt"
Set doc = acadDoc.New(templateFileName)
End If
If Opt4.Value = True Then
DrgSheet = "B"
templateFileName = "acadblank.dwt"
Set doc = acadDoc.New(templateFileName)
End If
'get the item selected from list box
Select Case ListBox1.ListIndex
'if the index is 0 (first item)
Case 0
'set the drawing size
DrgSize = "A0"

'set the limits
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 1189# * sc
newLimits(3) = 841# * sc

'get the current text style
Set oldTextStyle = acadDoc.ActiveTextStyle

Case 1
DrgSize = "A1"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 841# * sc
newLimits(3) = 594# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 2
DrgSize = "A2"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 594# * sc
newLimits(3) = 420# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 3
DrgSize = "A3"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 420# * sc
newLimits(3) = 297# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
Case 4
DrgSize = "A4"
newLimits(0) = 0#
newLimits(1) = 0#
newLimits(2) = 297# * sc
newLimits(3) = 210# * sc
Set oldTextStyle = acadDoc.ActiveTextStyle
AutoLisp/VBA Drawing Setup Page II
http://www.afralisp.com/lisp/setup2.htm (3 of 5) [23/03/2005 05:45:47 p.m.]
End Select
'set drawing limits
acadDoc.Limits = newLimits
'zoom to extents
ZoomExtents
'set Ltscale
Call acadDoc.SetVariable("Ltscale", sc * 10)
'set Dimscale
Call acadDoc.SetVariable("Dimscale", sc)
'store scale in Userr1 for later use
Call acadDoc.SetVariable("Userr1", sc)
'set Regenmode
Call acadDoc.SetVariable("Regenmode", 1)
'set Tilemode
Call acadDoc.SetVariable("Tilemode", 1)
'set Text Height
oldTextStyle.Height = 3.5 * sc
'String Drawing Sheet Name Together
Insertsheet = DrgSheet & DrgSize
'set the insertion point
InsertionPoint(0) = 0
InsertionPoint(1) = 0
InsertionPoint(2) = 0
'get reference to Model Space
Set Mspace = acadDoc.ModelSpace
'Insert the drawing sheet
Set Blockref = Mspace.InsertBlock(InsertionPoint, Insertsheet, sc, sc, sc, 0)
End
End Sub
'-------------------------------------------------
Private Sub ListBox1_Click()
TextBox1.SetFocus
End Sub
'--------------------------------------------------
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
cmdOk_Click
End Sub
'--------------------------------------------------
Private Sub Opt1_Click()
TextBox1.SetFocus
End Sub
'--------------------------------------------------
Private Sub Opt2_Click()
TextBox1.SetFocus
End Sub
AutoLisp/VBA Drawing Setup Page II
http://www.afralisp.com/lisp/setup2.htm (4 of 5) [23/03/2005 05:45:47 p.m.]
'--------------------------------------------------
Private Sub Opt3_Click()
TextBox1.SetFocus
End Sub
'--------------------------------------------------
Private Sub Opt4_Click()
TextBox1.SetFocus
End Sub
'--------------------------------------------------
Private Sub UserForm_Initialize()
'Populate the List Box
ListBox1.AddItem "A0 - 1189 x 841"
ListBox1.AddItem "A1 - 841 x 594"
ListBox1.AddItem "A2 - 594 x 420"
ListBox1.AddItem "A3 - 420 x 297"
ListBox1.AddItem "A4 - 297 x 210"
ListBox1.ListIndex = 0
End Sub
Next, you need to add a new Module.
Then add this coding :
Sub VbaSetup()
UserForm1.Show
End Sub
Save your project as "VbaSetup.dvb", then run the macro "VbaSetup."
The dialog should appear in all it's glory. Congratulations!
Quick, call your colleagues, call your boss, in fact, call all your friends and family to come and have a look and what
you've done. Who's a clever boy then? (sorry, or girl.)
To download the AutoLisp and VBA source coding, just click here.
To download the drawings sheets and template files, click here
Home Page I

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp/VBA Drawing Setup Page II
http://www.afralisp.com/lisp/setup2.htm (5 of 5) [23/03/2005 05:45:47 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Utils (33 Kb)
Utils is a selection of Utility Functions written in VBA for use in Autocad Rel 14.
It consists of 3 Files :
CHL.DVB--Change Layer
CHLT.DVB-Change Linetype
CHC.DVB--Change Color
Along with them I have Included UTIL.LSP and UTIL.MNU
These 2 files provide the link between Autocad and VBA by providing a Toolbar to select a routine and a
lisp file that loads and runs the routine.
I have provided these files mainly to show what can be done using VBA and Autocad.
P.S.
Please ensure that all files are in a directory called c:\utils and that this directory is in you Autocad search
Path.
Source Code For Chl.Dvb
Dim ss As IAcadSelectionSet
Option Explicit

Private Sub CommandButton1_Click()
Dim Entity As Object
Me.Hide
Set ss = ThisDrawing.SelectionSets.Add("NEWSS")
ss.SelectOnScreen
For Each Entity In ss
Entity.Layer = lstLayers.Text
Next
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Utils
http://www.afralisp.com/vbaa/vba1.htm (1 of 3) [23/03/2005 05:45:51 p.m.]
Private Sub lstLayers_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Entity As Object
Me.Hide
Set ss = ThisDrawing.SelectionSets.Add("NEWSS")
ss.SelectOnScreen
For Each Entity In ss
Entity.Layer = lstLayers.Text
Next
Unload Me
End Sub
Private Sub UserForm_Activate()
Dim AcadApp As Object
Dim AllLayers As Object
Dim Layer As Object
Set AcadApp = GetObject(, "AutoCAD.Application")
Set AllLayers = AcadApp.ActiveDocument.Layers
For Each Layer In AllLayers
lstLayers.AddItem Layer.Name
Next
End Sub
Source Code For Utils.Lsp
(prompt "\nPlease Wait...CadKen VBA Utilities Loading...")
(defun c:chl ()
(setvar "filedia" 0) ; disable all file dialog boxes
(command "_VBALOAD" "c:\\UTILS\\chl.dvb") ; load the VBA routine
(setvar "filedia" 1) ; enable all file dialog boxes
(command "_-VBARUN" "module1.ChangeLayer") ; run the defined macro
(princ) ; finish clean
) ; c:chl
(defun c:chlt ()
(setvar "filedia" 0)
(command "_VBALOAD" "c:\\UTILS\\chlt.dvb")
(setvar "filedia" 1)
(command "_-VBARUN" "module1.ChangeLineType")
(princ)
)
(defun c:chc ()
(setvar "filedia" 0)
(command "_VBALOAD" "c:\\UTILS\\chc.dvb")
(setvar "filedia" 1)
(command "_-VBARUN" "module1.ChangeColor")
(princ)
)
(princ)
Source Code For Utils.Mnu
***MENUGROUP=UTILS
***TOOLBARS
**UTILITIES
TB_Utility [_Toolbar("Utilities", _Floating, _Show, 0, 0, 1)]
TB_ChLayer [_Button("Change Layer", "chl.bmp", "ICON_32_BLANK")]^C^C^P+
(cond ((null C:UTILS) (prompt "Please Wait...")(load "UTILS"))) CHL
TB_ChLType [_Button("Change Line Type", "chlt.bmp", "ICON_32_BLANK")]^C^C^P+
(cond ((null C:UTILS) (prompt "Please Wait...")(load "UTILS"))) CHLT
Utils
http://www.afralisp.com/vbaa/vba1.htm (2 of 3) [23/03/2005 05:45:51 p.m.]
TB_ChColor [_Button("Change Color", "chc.bmp", "ICON_32_BLANK")]^C^C^P+
(cond ((null C:UTILS) (prompt "Please Wait...")(load "UTILS"))) CHC

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Utils
http://www.afralisp.com/vbaa/vba1.htm (3 of 3) [23/03/2005 05:45:51 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Drawing Layer Manager
This contribution is stolen from Frank Zander with his blessing.
Contract CADD Group - http://www.contractcaddgroup.com
This application is the perfect example of how something so simple can be so powerful. My immediate reaction on
reading this article and then running the coding was, "Why didn't I think of that?" I implemented it into my office
so quickly you wouldn't believe it.
Using VBA in AutoCAD R14 / 2000 to Control Layer Standards.
by Frank Zander
Introduction
Have you ever wondered why drawings can contain many layers, but objects such as "text",
"dimensions" and "hatch" do not always end up on the correct layers? This article addresses a
potential solution to that problem. First, I talk briefly about layer standards and show you how to create
a small VBA project for AutoCAD r14.01 or 2000 to control layers.
Layer Standards
Several times in the past, I have been asked by new users, "Why doesn't AutoCAD put text objects on
the text layer and hatch objects on a hatch layer, etc?" The answer is that Autodesk has designed
AutoCAD to give users unrestricted flexibility with layer names and to allow companies to create or
adopt any layer standard. Unfortunately, this flexibility of open-architecture layer names within
AutoCAD has allowed many an AutoCAD user to recklessly create layer names. Sometimes, it seems,
layer names are chosen according to what pops into the user's head while staring at the AutoCAD layer
dialogue box! And after several other users in the same company use these layer names, the results are
then called the "company layer standards".
There are many recognized layer standards in existence, such as AIA, Master Format, British BSD, etc.
that companies can adopt, but it seems to be more trendy for companies to make up their own layer
names and standards on the fly. The rationale seems to be "Those other existing layer standards could
not possibly accommodate the type of work that our company does. " How many times have you come
across a drawing (done by someone else, of course) containing layers called dim, dimension, and
dimensions? The purpose of this small VBA project is to create a mini layer-manager that enforces
layers for "text", "hatch" and "dimension" objects as they are created in a drawing. Text goes on to a
layer called "text", hatch patterns are placed on a layer called "hatch", and dimensions are placed on a
layer called "dim". Seems almost too obvious! Sure, this is a rather simplistic way of managing layers
for objects, but it works! For those interested in modifying the code to fit your own company layer
standard or for working with multiple disciplines, take a look at the section called "Extending the Code"
later in the article.
I was recently exposed to the "AcadDocument_BeginCommand" sub-program when I began a technical
review for WROX press of a book called AutoCAD - VBA Programmers Reference (currently being
written by Joe Sutphin). Joe's example code made me think, "Wow! I could apply his technique to do
some layer management of my own!" In the program outlined in this article, I access this sub-program
to check on the command being accessed by AutoCAD. Once the command being used is checked, it
creates the appropriate layer settings before AutoCAD starts the command. Therefore, when a user
enters the text command, my VBA program sets-up and/or creates the text layer, transparently in the
background, before the text command starts. The sub-program "AcadDocument_BeginCommand" picks
up on AutoCAD commands used in LISP programs and any alias (defined in the ACAD.pgp) that
references an AutoCAD command. For example, if a user types "BH" (standard short cut alias for the
"bhatch" command), the sub-program "AcadDocument_BeginCommand" still traps the "bhatch"
command.
The compliment to the "AcadDocument_BeginCommand" sub-program is the sub-program
"AcadDocument_EndCommand". I use the latter sub-program to check for the name of the command
that has just been completed. If the command name matches my criteria (using the "select case"
method), the layer is set back to the original layer in use before the command was started. Look at the
Drawing Layer Manager
http://www.afralisp.com/vbaa/drawman.htm (1 of 5) [23/03/2005 05:45:52 p.m.]
following commented code to see if you can follow what is happening inside the VBA program. Start
with the "AcadDocument_BeginCommand" sub-program and finish with the
"AcadDocument_EndCommand" sub-program.
Place this coding into a VBA Module and save it as DrawMan.dvb. Then add it to your startup suitcase.
' Using Option Explicit -- you must explicitly declare all variables using the
' Dim, Private, Public, ReDim, or Static statements.
' If you attempt to use an undeclared variable name,
' an error occurs at compile time.
' Option Explicit is a great way to make sure you do not have wonkie typo mistakes
' in your code.
Option Explicit
' set the public object current Layer to be an AutoCAD Layer
Public objCurrentLayer As AcadLayer
' set the public object Previous Layer to be an AutoCAD Layer
Public objPreviousLayer As AcadLayer
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
' Save the current / active AutoCAD layer
Set objPreviousLayer = ThisDrawing.ActiveLayer
' Check for the folowing cases of the AutoCAD command.
Select Case CommandName
' Check the AutoCAD command,
' is there a match for TEXT, MTEXT, or DTEXT
Case "TEXT", "MTEXT", "DTEXT" ' then do the following..
' check for to see if the current layer is Text
' if the current layer is not TEXT then set up the TEXT
' layer for use.
If Not ThisDrawing.ActiveLayer.Name = "4" Then
' set up the TEXT layer
' this layer will be created if it does not exist
Set objCurrentLayer = ThisDrawing.Layers.Add("4")
' make the TEXT layer blue
objCurrentLayer.Color = acCyan
' turn the TEXT layer ON
objCurrentLayer.LayerOn = True
' Thaw the TEXT layer
objCurrentLayer.Freeze = False
' Unlock the TEXT layer
Drawing Layer Manager
http://www.afralisp.com/vbaa/drawman.htm (2 of 5) [23/03/2005 05:45:52 p.m.]
objCurrentLayer.Lock = False
' Make the TEXT layer the current
' active layer in this drawing.
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for TEXT being the current layer.
End If
' Check the AutoCAD command,
' is there a match for HATCH, or the BHATCH command.
Case "HATCH", "BHATCH"
' check for to see if the current layer is HATCH
' if the current layer is not HATCH then set up the HATCH
' layer for use.
If Not ThisDrawing.ActiveLayer.Name = "8" Then
' set up the HATCH layer
Set objCurrentLayer = ThisDrawing.Layers.Add("8")
' make the HATCH layer red
objCurrentLayer.Color = 8
' turn the HATCH layer ON
objCurrentLayer.LayerOn = True
' Thaw the HATCH layer
objCurrentLayer.Freeze = False
' Unlock the HATCH layer
objCurrentLayer.Lock = False
' Make the HATCH layer the current
' active layer in this drawing.
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for HATCH being the current layer.
End If
' check for AutoCAD dimension commands..
Case "DIMALIGNED", "DIMANGULAR", "DIMCENTER", _
"DIMCONTINUE", "DIMDIAMETER", "DIMLINEAR", "LEADER", _
"DIMORDINATE", "DIMRADIUS", "DIM", "DIM1"
If Not ThisDrawing.ActiveLayer.Name = "4" Then
Set objCurrentLayer = ThisDrawing.Layers.Add("4")
objCurrentLayer.Color = acCyan
objCurrentLayer.LayerOn = True
objCurrentLayer.Freeze = False
Drawing Layer Manager
http://www.afralisp.com/vbaa/drawman.htm (3 of 5) [23/03/2005 05:45:52 p.m.]
objCurrentLayer.Lock = False
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for DIM being the current layer.
End If
' end of the Select
End Select
' end of Private Sub AcadDocument_BeginCommand
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
' Check for the folowing cases of the AutoCAD command that has just ended.
Select Case CommandName
' check for a match on the following AutoCAD commands
Case "HATCH", "BHATCH", "TEXT", "MTEXT", "DTEXT", "DIMALIGNED", "DIMANGULAR",
"DIMCENTER", _
"DIMCONTINUE", "DIMDIAMETER", "DIMLINEAR", "LEADER", _
"DIMORDINATE", "DIMRADIUS", "DIM", "DIM1"
' make the current active AutoCAD layer the previously saved layer.
ThisDrawing.ActiveLayer = objPreviousLayer
' clear the objCurrentLayer
Set objPreviousLayer = Nothing
End Select
' clear the objCurrentLayer
Set objCurrentLayer = Nothing
' end Private Sub AcadDocument_EndCommand
End Sub
Would you like the coding for this routine? Then put one leg in the air,
close one eye, scream as loud as you can and click here. Enjoy.......

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Drawing Layer Manager
http://www.afralisp.com/vbaa/drawman.htm (4 of 5) [23/03/2005 05:45:52 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Layer Manager
http://www.afralisp.com/vbaa/drawman.htm (5 of 5) [23/03/2005 05:45:52 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Save Manager
The Autosave feature in AutoCAD does not save the drawing you are working on, but saves a copy of your drawing
to a directory stored in the Savefilepath system variable. This drawing does not have the same name as your
drawing file and can be overwritten with subsequent Autosaves. Here's a little VBA application which I wrote that
will save your drawings at a user determined interval. (or very close.) It basically takes the time from the system
clock and stores it in one of the User system variables. Every time you select "Line," "Pline," or "Zoom," the
application checks to see if 15 minutes have passed. If it hasn't, it does nothing. If it has, it saves the drawing and
then resets the stored time to the system time. (Phew!)
Stick this coding in a module, save it as "SaveMan.dvb," and add it to your startup suitcase.
'<--Start Coding Here
Option Explicit
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim OldTime
Dim NewTime
'trigger when user selects
Case "LINE", "PLINE", "ZOOM"
'get the time now
NewTime = (Hour(Time) * 60) + Minute(Time)
'get the time stored in USERI2
OldTime = ThisDrawing.GetVariable("Useri2")
'If the time has not been set
If OldTime = 0 Then
'set the time
ThisDrawing.SetVariable ("Useri2"), NewTime
'then end
End
End If
'if the difference is greater that 15 minutes
If (NewTime - OldTime) > 15 Then
'save the drawing
ThisDrawing.Save
'and then reset Useri2
ThisDrawing.SetVariable ("Useri2"), NewTime
End If
' end of the Select
End Select
Save Manager
http://www.afralisp.com/vbaa/saveman.htm (1 of 2) [23/03/2005 05:45:54 p.m.]
End
End Sub
'End Coding Here-->
If you wish, you can download the source coding here. (4Kb)
Sorry!! I mean Here. (4Kb)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Save Manager
http://www.afralisp.com/vbaa/saveman.htm (2 of 2) [23/03/2005 05:45:54 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Attributes and VBA
You can find the AutoLisp equivalent to this application here.
When you want to edit attributes in AutoCAD most of us use the "Attedit" command. Firstly,
we must select the attribute we would like to edit. Then the "Edit Attribute" dialogue box
appears which allows us to add or change the values of our attribute. Personally, I think this
dialogue leaves a lot to be desired. You cannot customise it in any way, and it displays all
attributes whether you want them or not. As well, if you have a lot of attributes you need to
page your way through numerous dialogues before reaching the attribute you want to edit.
In this tutorial we are going to have a look at extracting attribute data from a block,
displaying the data in a custom dialogue box, and then updating the attribute data on exit.
Right, what do we need to do?
Find the block containing the attribute data. (Why select it when we can get AutoCAD
to find it for us.)
G
Extract the attribute data and display it in a dialogue box. G
Allow the user to change the data if he so wishes. G
Update the attribute data with the new information entered into the dialogue box. G
O.K. fire up AutoCAD and open the drawing Attab.dwg.
Alright, I admit that it's not much of a title block, but it's enough to give you the general idea.
Load run run the macro.
This dialogue should appear :
Change some of the data and then press the "OK" button.
The title block data should be updated. Clever hey?
Attributes and VBA
http://www.afralisp.com/vba/attabvba.htm (1 of 4) [23/03/2005 05:45:57 p.m.]
You can expand on this routine as much as you like using the following coding as a
template.
Hint : You don't have to display all the attribute data stored in a block. Only display what you
want the user to modify. As well, you can split your data over multiple dialogue boxes. eg.
One for title block, one for revisions, one for reference drawings, etc. All the data though is
contained in one attribute.
Here's the coding :
'CODING STARTS HERE
'All Tutorials and Code are provided "as-is" for purposes of instruction and
'utility and may be used by anyone for any purpose entirely at their own risk.
'Please respect the intellectual rights of others.
'All material provided here is unsupported and without warranty of any kind.
'No responsibility will be taken for any direct or indirect consequences
'resulting from or associated with the use of these Tutorials or Code.
'*******************************************************************************
' AfraLisp
' http://www.afralisp.com
' afralisp@afralisp.com
' afralisp@mweb.com.na
'*******************************************************************************
'This application will extract attributes from a block and display them in a
'dialog box. The attributes will then be updated.
Option Explicit
Public Tatts As Variant
Public ssnew As Object
Private Sub CommandButton1_Click()

'Update the attribute values
UpdateAttrib 0, UserForm1.TextBox1.Text
UpdateAttrib 1, UserForm1.TextBox2.Text
UpdateAttrib 2, UserForm1.TextBox3.Text
UpdateAttrib 3, UserForm1.TextBox4.Text
UpdateAttrib 4, UserForm1.TextBox5.Text

'update the block
ssnew.Item(0).Update

'delete the selection set
ThisDrawing.SelectionSets.Item("TBLK").Delete

End

End Sub
Private Sub CommandButton2_Click()
'delete the selection set
ThisDrawing.SelectionSets.Item("TBLK").Delete
End
End Sub
Private Sub UserForm_Initialize()
Attributes and VBA
http://www.afralisp.com/vba/attabvba.htm (2 of 4) [23/03/2005 05:45:57 p.m.]
Dim EntGrp(0) As Integer
Dim EntPrp(0) As Variant
Dim BlkObj As Object
Dim Pt1(0) As Double
Dim Pt2(0) As Double

'define error function
On Error GoTo Err_Control

'create a selection set
Set ssnew = ThisDrawing.SelectionSets.Add("TBLK")

'Filter for Group code 2, the block name
EntGrp(0) = 2

'The name of the block to filter for
EntPrp(0) = "attab-info"

'find the block
ssnew.Select acSelectionSetAll, Pt1, Pt2, EntGrp, EntPrp

'If a block is found
If ssnew.Count >= 1 Then

'Get the block's attributes
Tatts = ssnew.Item(0).GetAttributes

'display the attributes in the dialogue
UserForm1.TextBox1.Text = (LTrim(Tatts(0).TextString))
UserForm1.TextBox2.Text = (LTrim(Tatts(1).TextString))
UserForm1.TextBox3.Text = (LTrim(Tatts(2).TextString))
UserForm1.TextBox4.Text = (LTrim(Tatts(3).TextString))
UserForm1.TextBox5.Text = (LTrim(Tatts(4).TextString))

'set the focus to TextBox1 and highlight the text
UserForm1.TextBox1.SetFocus
UserForm1.TextBox1.SelStart = 0
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)

Else
'no attribute block, inform the user
MsgBox "No Title Block Attributes - Use Manual Edit..", vbCritical, "AfraLisp Title Block"

'delete the selection set
ThisDrawing.SelectionSets.Item("TBLK").Delete

End

End If

Exit Sub

Err_Control:
'display error number and description
MsgBox Err.Number & " " & Err.Description

End

End Sub
Attributes and VBA
http://www.afralisp.com/vba/attabvba.htm (3 of 4) [23/03/2005 05:45:57 p.m.]
Sub UpdateAttrib(TagNumber As Integer, BTextString As String)

'This procedure checks to see if the text box has a value.
'If it does, it applies the text to the attribute.
'If not, it applies an empty string to the attribute.
If BTextString = "" Then

Tatts(TagNumber).TextString = ""

Else

Tatts(TagNumber).TextString = BTextString

End If

End Sub
'CODING ENDS HERE
OK, I know you can't type. Here's the coding.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Attributes and VBA
http://www.afralisp.com/vba/attabvba.htm (4 of 4) [23/03/2005 05:45:57 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Attributes and Dialog Boxes
You can find the VBA equivalent to this application here.
When you want to edit attributes in AutoCAD most of us use the "Attedit" command.
Firstly, we must select the attribute we would like to edit. Then the "Edit Attribute"
dialogue box appears which allows us to add or change the values of our attribute.
Personally, I think this dialogue leaves a lot to be desired. You cannot customise it in any
way, and it displays all attributes whether you want them or not. As well, if you have a lot
of attributes you need to page your way through numerous dialogues before reaching the
attribute you want to edit.
In this tutorial we are going to have a look at extracting attribute data from a block,
displaying the data in a custom dialogue box, and then updating the attribute data on
exit.
Right, what do we need to do?
1. Find the block containing the attribute data. (Why select it when we can get AutoCAD
to find it for us.)
2. Extract the attribute data and display it in a dialogue box.
3. Allow the user to change the data if he so wishes.
4. Update the attribute data with the new information entered into the dialogue box.
O.K. fire up AutoCAD and open the drawing Attab.dwg.
Alright, I admit that it's not much of a title block, but it's enough to give you the general
idea.
Now, at the command prompt type (load "Addat") and then enter.
Now, type "Addat" and press enter again.
This dialogue should appear :
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (1 of 8) [23/03/2005 05:45:59 p.m.]
Change some of the data and then press the "OK" button.
The title block data should be updated. Clever hey?
You can expand on this routine as much as you like using the following coding as a
template.
Hint : You don't have to display all the attribute data stored in a block. Only display what
you want the user to modify. As well, you can split your data over multiple dialogue
boxes. eg. One for title block, one for revisions, one for reference drawings, etc. All the
data though is contained in one attribute.
Here's the coding, DCL code first :
attab : dialog {
label = "Drawing Title Block";
: edit_box {
label = "&Drawing Number";
key = "eb1";
edit_width = 30;
}
: edit_box {
label = "&Revision";
key = "eb2";
edit_width = 30;
}
: edit_box {
label = "Drawn &By";
key = "eb3";
edit_width = 30;
}
: edit_box {
label = "D&ate";
key = "eb4";
edit_width = 30;
}
: edit_box {
label = "&Title";
key = "eb5";
edit_width = 30;
}
ok_cancel ;
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (2 of 8) [23/03/2005 05:45:59 p.m.]
:text_part {
label = "AfraLisp - http://www.afralisp.com";
}

}
And now the AutoLisp coding with plenty of in-line comments to assist you :
;CODING STARTS HERE
;
;All Tutorials and Code are provided "as-is" for purposes of instruction and
;utility and may be used by anyone for any purpose entirely at their own risk.
;Please respect the intellectual rights of others.
;All material provided here is unsupported and without warranty of any kind.
;No responsibility will be taken for any direct or indirect consequences
;resulting from or associated with the use of these Tutorials or Code.
;*******************************************************************************
; AfraLisp
; http://www.afralisp.com
; afralisp@afralisp.com
; afralisp@mweb.com.na
;*******************************************************************************
;This application will extract attributes from a block and display them in a
;dialog box. The attributes will then be updated. Attab.dcl and Attab.dwg are
;required and must be within the AutoCAD search path.
;
;Usage : Open Attab.dwg then load and run Attab.lsp.
;*******************************************************************************
(prompt "\nATTAB Loaded....Type ATTAB to run.....")
(defun c:attab (/)
;first find all the blocks with attributes in the drawing
(setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1))))
;if there are blocks
(if ss1
;do the following
(progn
;set up the counter
(setq count 0
emax (sslength ss1)
)
;extract the block name
(while (< count emax)
(setq en (ssname ss1 count)
ed (entget en)
blkn (dxf 2 ed)
)
;check if it is our block
(if (= "attab-info" blkn)
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (3 of 8) [23/03/2005 05:45:59 p.m.]
;if it is, switch off the counter
;and set the found flag
(setq count emax
found T
)
;it's not our block, increment the counter
;and loop
(setq count (1+ count))
);if
);while
;if we find our block
(if found
;display the dialog
(ddisplay)
;cannot find our block
(alert
"\nDrawing Sheet has No Attributes
\n Use Manual Edit"
)
);if
);progn
;there are no blocks in the drawing
(alert
"\nIncorrect Drawing Sheet
\n Use Manual Edit"
)
);if
;finish clean
(princ)
);defun
;;;**********************************************************
(defun ddisplay (/)
;load the dialog
(setq dcl_id (load_dialog "attab.dcl"))
;check it exists
(if (not (new_dialog "attab" dcl_id))
(exit)
);if
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (4 of 8) [23/03/2005 05:45:59 p.m.]
;get the block entity data
(setq edata (entget en))
;get the first attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;get the drawing number
(setq eb1 (dxf 1 edata))
;get the second attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;get the revision
(setq eb2 (dxf 1 edata))
;get the third attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;get the name
(setq eb3 (dxf 1 edata))
;get the fourth attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;get the date
(setq eb4 (dxf 1 edata))
;get the fifth attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;get the title
(setq eb5 (dxf 1 edata))
;put the info into the dialog
(set_tile "eb1" eb1)
(set_tile "eb2" eb2)
(set_tile "eb3" eb3)
(set_tile "eb4" eb4)
(set_tile "eb5" eb5)
;set the focus to the drawing number
(mode_tile "eb1" 2)
;if cancel selected exit
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
;if OK selected, retrieve the tile values
(action_tile
"accept"
(strcat
"(progn (setq eb1a (get_tile \"eb1\"))"
"(setq eb2a (get_tile \"eb2\"))"
"(setq eb3a (get_tile \"eb3\"))"
"(setq eb4a (get_tile \"eb4\"))"
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (5 of 8) [23/03/2005 05:45:59 p.m.]
"(setq eb5a (get_tile \"eb5\"))"
" (done_dialog)(setq userclick T))"
)
)
;start the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;if OK was selected
(if userclick
(progn
;get the block entity data
(setq edata (entget en))
;get the first attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;change the list with the new values, if any
(setq el (subst (cons 1 eb1a) (assoc 1 edata) edata))
;update the attribute
(entmod el)
;get the second attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;change the list with the new values, if any
(setq el (subst (cons 1 eb2a) (assoc 1 edata) edata))
;update the attribute
(entmod el)
;get the third attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;change the list with the new values, if any
(setq el (subst (cons 1 eb3a) (assoc 1 edata) edata))
;update the attribute
(entmod el)
;get the fourth attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
;change the list with the new values, if any
(setq el (subst (cons 1 eb4a) (assoc 1 edata) edata))
;update the attribute
(entmod el)
;get the fifth attribute entity list
(setq edata (entget (entnext (dxf -1 edata))))
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (6 of 8) [23/03/2005 05:45:59 p.m.]
;change the list with the new values, if any
(setq el (subst (cons 1 eb5a) (assoc 1 edata) edata))
;update the attribute
(entmod el)
;regen the drawing
(command "REGEN")
);progn
);if
(princ)
);defun
;;;***********************************************************

(defun dxf (code elist)
(cdr (assoc code elist))
);defun
;;;**********************************************************
;load clean
(princ)
;;;**********************************************************
;
;CODING ENDS HERE
Please note that there is no error checking in this routine and I have left all variables as
global to assist you in checking their values whilst you are analyzing the code.
If you are too lazy to type, and don't know how to copy and paste, you can download the
coding and sample drawing by very gently placing your cursor here and clicking once.
"Ouch, I did say gentle!!!!

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (7 of 8) [23/03/2005 05:45:59 p.m.]
Search
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Attributes and Dialog Boxes
http://www.afralisp.com/lisp/attab.htm (8 of 8) [23/03/2005 05:45:59 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and HTML
This article first appeared in the September 2002 issue of "CAD Encoding."
In this article, we are going to have a look at extracting information from AutoCAD and displaying the
results in an HTML file.
Just to be clever, and to keep everybody happy, we'll be writing the coding using VBA, AutoLisp, Visual
Lisp and last but not least VB. Each of the routines will be slightly different to give you an idea of the
capabilities of each language.
Let's have a look at VBA first.
This wee routine will extract all the layer names contained within a drawing, create an HTML file on the
fly, and list all the layer names :
Insert a Userform and add a listbox and two buttons, retaining their default names :
UserForm1 G
ListBox1 G
CommandButton1 G
Commandbutton2 G
Add the following coding to the General Declarations section :
(I recommend you download the source coding for this project as word-wrapping can cause major
problems. The download link is at the end of Page IV.)
Option Explicit
'-----------------------------------------------------
Public AllLayers As AcadLayers
'-----------------------------------------------------
Private Sub CommandButton1_Click()
Dim nFile As Integer
Dim Layer As AcadLayer
Dim dName As String
Dim mylen As Integer
Dim dPrefix As String
'if there is an error
Cad Encoding - Layers to HTML
http://www.afralisp.com/lisp/html1.htm (1 of 4) [23/03/2005 05:46:05 p.m.]
On Error GoTo Err_Control
'hide the dialog
Me.hide
'get the drawing name
dName = ThisDrawing.GetVariable("DWGNAME")
'get the drawing name
dPrefix = ThisDrawing.GetVariable("DWGPREFIX")
'get the length of the filename
mylen = Len(dName)
'subtract the .DWG Extension
mylen = mylen - 4
'retrieve the drawing name
dName = Left(dName, mylen)
'get the next free file number
nFile = FreeFile
'open the html file to write to
Open dPrefix & dName & " - AllLayers.htm" _
For Output As #nFile
'write the header
Print #nFile, "<html><head><title> _
Cad Encoding - Layers to HTML</title></head>
<body><h3>Layers - Drawing No : " & dPrefix & _
dName & "</h3><hr>"
'process each layer
For Each Layer In AllLayers
'write to the HTML file
Print #nFile, "Layer Name = " & Layer.Name & "<p>"
'process next layer
Next
'write the footer
Print #nFile, "<hr><h3>Created by CAD Encoding</h3> _
</body></html>"
'close the file
Close #nFile
'display message box
MsgBox ("Layers written to HTML File :" & vbCr & _
dPrefix & dName &" - AllLayers.htm"), , "Layers to HTML"
'error control
Exit_Here:
Exit Sub
Err_Control:
MsgBox Err.Description
Cad Encoding - Layers to HTML
http://www.afralisp.com/lisp/html1.htm (2 of 4) [23/03/2005 05:46:05 p.m.]
Resume Exit_Here

End Sub
'----------------------------------------------------
Private Sub CommandButton2_Click()
End
End Sub
'---------------------------------------------------
Private Sub UserForm_Initialize()
Dim Layer As AcadLayer
'if there is an error
On Error GoTo Err_Control
'get the layers collection
Set AllLayers = ThisDrawing.Layers
'process each layer
For Each Layer In AllLayers
'display each layer name in the list box
ListBox1.AddItem Layer.Name

'process next layer
Next

'error control
Exit_Here:
Exit Sub

Err_Control:
MsgBox Err.Description
Resume Exit_Here

End Sub
Now insert a new Module and add this :
Sub AllLayers()
UserForm1.Show
End Sub
Save this as "AllLayers.dvb."
Now open any drawing and run the macro.
The List Box should be populated with the drawings Layer names.
Select the "HTML" button. A dialog should appear informing you that an HTML file has been created.
Navigate to the directory containing the HTML file and open it.
A list of all the Layers in your drawing should have been created.
On the next page we'll have a look at something similar, but this time using AutoLisp.
Cad Encoding - Layers to HTML
http://www.afralisp.com/lisp/html1.htm (3 of 4) [23/03/2005 05:46:05 p.m.]
Home Page II Page III Page IV

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Cad Encoding - Layers to HTML
http://www.afralisp.com/lisp/html1.htm (4 of 4) [23/03/2005 05:46:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and HTML - Page II
This time we're going to have a look at creating an HTML file that lists a directory of DWF drawings
using AutoLisp. To select the DWF files and the relevant directory, we are going to make use of a very
powerful DosLib function "dos_filem." Oh, before I forget, you will need to have the DosLib library
installed on your workstation. If you don't have DosLib, you can download the latest version from
Robert McNeel & Associates.
I'd like to thank Andy Canfield(Cornbread) for his ideas and input into this routine. Andy wrote about
90% of this program and in fact, gave me the initial idea for this article. I've changed a couple of things
and tidied it up for publishing, but Andy did the major work. Any errors or typos are from my desk.
Right, enough waffle, lets get on with it. Copy and paste this into Notepad and then save it as
"Dwf-Html.lsp."
(defun C:Dwf-Html ( / flag thelist thedir nfiles thefile fn ctr dname)
;set the flag
(setq flag T)
;check Doslib is loaded
(if (not (member "doslib2k.arx" (arx)))
(progn
(if (findfile "doslib2k.arx")
(arxload "doslib2k")
(progn
(alert "DosLib not installed")
(setq flag nil)
);progn
);if
);progn
);if
;if DosLib is installed and loaded
(if flag
;do the following
(progn
;select the DWF files
(setq thelist (dos_getfilem "Select Drawings"
"C:\\" "DWF Files (*.dwf)|*.dwf"))
;retrieve the directory
(setq thedir (car thelist))
;retrieve the file names
(setq thelist (cdr thelist))
;get the number of files
(setq nfiles (length thelist))
;create the HTML file
AutoCAD and HTML - Page II
http://www.afralisp.com/lisp/html2.htm (1 of 3) [23/03/2005 05:46:06 p.m.]
(setq thefile (strcat thedir "Dwf-Html.html"))
;open the HTML file
(setq fn (open thefile "w"))
;write the header information
(write-line "<html><head>
<title>AutoCAD and HTML</title>
</head><body>" fn)
;give it a title
(write-line "<h1>AutoCAD and HTML</h1><hr>" fn)
;set the counter
(setq ctr 0)
;start the loop
(repeat nfiles
;get the drawing name
(setq dname (nth ctr thelist))
;create the HTML link
(write-line (strcat "<a href =" "\""
thedir dname "\"" ">" thedir dname "
</a><br>") fn)
;increment the counter
(setq ctr (1+ ctr))
);end repeat
;write the HTML footer
(write-line "<hr><h3>Brought to you by CAD Encoding</h3>
</body></html>" fn)
;close the file
(close fn)
;inform the user
(alert (strcat "File saved as" "\n" thedir "Dwf-Html.html"))
);progn
);if flag
;finish clean
(princ)
);defun
;load clean
(princ)
Now, load and run this routine.
A file dialog will appear. Choose the directory your DWf files are located in, and then select the DWF
files you would like listed in the HTML report.
The HTML file will be created and stored in the same directory as your DWF files and will be named
"Dwf-Html.html." Open this file in your browser. You should have a list of links to all the DWF files you
selected.
As I mentioned earlier, we make use of the DosLib function "dos_filem" to allow the user to select the
DWF files that he/she/it wants to process.
The "dos_filem" function displays a file open dialog box that allows for multiple file selection. The
function returns a list of filenames if successful. The first element of the list is a qualified path to the
selected directory. eg.
(setq thedir (car thelist))
returns the file directory and
AutoCAD and HTML - Page II
http://www.afralisp.com/lisp/html2.htm (2 of 3) [23/03/2005 05:46:06 p.m.]
(setq thelist (cdr thelist))
returns a list of file names. Do yourself a favour and read the help file that comes with DosLib as you'll
find a lot of useful functions that will make your AutoLisp coding a lot easier.
Right, now let's have a look at doing something with HTML using Visual Lisp.
Home Page I Page III Page IV

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and HTML - Page II
http://www.afralisp.com/lisp/html2.htm (3 of 3) [23/03/2005 05:46:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and HTML - Page III
Time for another wee bit of a break for me. By sleuth of hand and the use of threats to various
appendages stuck on his body, I finally conned someone else into writing the next section for me. Say
hi to David Stein everyone, ("Hi Dave!!")
If you don't know Dave, well he is the gentleman responsible for "DSX Tools" and the "Visual Lisp
Bible." You can find his new permanent home at http://www.dsxcad.com. Pop along as it's well worth
the visit. (just check for your wife and wallet when you leave.)
Okey dokey. Dave is the author of this nice little program written using Visual Lisp that will not only
write the Layer Names to an HTML file, but will also write the Layer properties and status. Let's have a
look at the coding.
Copy and paste this into Notepad and save it as "DumpLayers.lsp."
;; This example involves the task of producing an HTML report of all
;; layers in the current drawing, including their properties (color, linetype, etc.)
;; and opening the report in a web browser after completion.
;; When loaded, the command is DUMPLAYERS.
(defun C:DUMPLAYERS
( / acad doc dwg layers name col ltp lwt pst onoff frz dat
path olist outfile output)
;load the VL extensions
(vl-load-com)
;get reference to AutoCAD
(setq acad (vlax-get-acad-object)
;reference the drawing
doc (vla-get-activedocument acad)
;get the drawing name
dwg (vla-get-name doc)
;get the drawing path
path (vla-get-path doc)
;get the layers cpllection
layers (vla-get-layers doc)
);setq
;process each layer
(vlax-for each layers
;get the layer name
(setq name (vla-get-name each)
;get the layer color
col (itoa (vla-get-color each))
;get the linetype
ltp (vla-get-linetype each)
;get the lineweight
lwt (itoa (vla-get-lineweight each))
;get the plotstyle
pst (vla-get-plotstylename each)
;on-off status
AutoCAD and HTML - Pge III
http://www.afralisp.com/lisp/html3.htm (1 of 3) [23/03/2005 05:46:08 p.m.]
onoff (if (= :vlax-true (vla-get-layeron each))
"ON" "OFF")
;frozen-thawed status
frz (if (= :vlax-true (vla-get-freeze each))
"FROZEN" "THAWED")
;list them
dat (list name col ltp lwt pst onoff frz)
;add to main list
olist (cons dat olist)
);setq
); vlax-for
;release all objects
(vlax-release-object layers)
(vlax-release-object doc)
(vlax-release-object acad)
;create the HTML file
(cond
( olist
(setq outfile (strcat (vl-filename-base dwg) ".htm"))
(setq outfile (strcat path outfile))
(cond
( (setq output (open outfile "w"))
(write-line "<html>" output)
(write-line "<head><title>" output)
(write-line (strcat "Layer Dump: " dwg) output)
(write-line "</title></head><body>" output)
(write-line (strcat "<b>Drawing: " dwg "</b><br>") output)
(write-line "<table border=1>" output)
(foreach layset olist
(write-line "<tr>" output)
(foreach prop layset
(write-line (strcat "<td>" prop "</td>") output)
)
(write-line "</tr>" output)
); foreach layer set
(write-line "</table></body></html>" output)
(close output)
(setq output nil)
;inform the user
(princ "\nReport finished! Opening in browser...")
;open the HTML report in the browser
(vl-cmdf "_.browser" outfile)
)
( T (princ "\nUnable to open output file.") )
)
)
( T (princ "\nUnable to get layer table information.") )
)
);defun
(princ)
Load and run this routine. The HTML file should automatically open in your browser.
Hey, is that not nice? All your layers, layer properties and status all nicely tabulated in a report! By the
way, if you are not very clued up on Visual Lisp, there are a whole set of Tutorials posted on AfraLisp
that you can use to familiarise yourself with this powerful addition to the AutoLisp language.
Okay, one more page to go. (phew.)
Now let's look at AutoCAD and HTML using Visual Basic. (Oooh, I can hear you say.)
Home Page I Page II Page IV
AutoCAD and HTML - Pge III
http://www.afralisp.com/lisp/html3.htm (2 of 3) [23/03/2005 05:46:08 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and HTML - Pge III
http://www.afralisp.com/lisp/html3.htm (3 of 3) [23/03/2005 05:46:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and HTML - Page IV
Programming for AutoCAD using Visual Basic brings quite a few advantages as well as a few
disadvantages. The main advantage is having full access to all the Visual Basic functions, tools,
controls, etc. The biggest disadvantage is having to make sure that the target computer has all the
support and system files necessary to run your program.
One area that Visual Basic stands out is in Batch Processing. In this example, we're going to design a
simple little standalone Visual Basic program that will "plot" a directory of drawings to DWF files. and
then create an HTML web page with a list of links to these DWF files.
By the way, this program can very easily be modified to suit any type of Batch Processing that your little
heart desires.
Open Visual Basic and create a new Standard.exe Project.
Firstly, you will need to insert a new Form with the following controls :
DriveListBox - Drive1 G
DirListBox - Dir1 G
FileListBox - File1 G
5 Labels - Label1 to Label5 G
CommandButton - btnExport G
CommandButton - btnCancel G
Now enter the following coding under the General Declarations section :
(I recommend you download the source coding for this project as word-wrapping can cause major
problems. The download link is at the bottom of this page.)
AutoCAD and HTML - Page IV
http://www.afralisp.com/lisp/html4.htm (1 of 5) [23/03/2005 05:46:11 p.m.]
Option Explicit
'----------------------
Private Sub btnCancel_Click()
End
'End the Application
End Sub
'----------------------
Private Sub btnExport_Click()
'declare variables
Dim acadApp As Object
Dim acadDoc As Object
Dim filename As String
Dim dirname As String
Dim pViewport As Object
Dim mylen As Integer
Dim filename1 As String
Dim nFile As Integer
Dim MMode As Integer
'test for root directory
If Right(File1.Path, 1) <> "\" Then
'if not root add \
dirname = File1.Path & "\"
Else
'if root directory do nothing
dirname = File1.Path
End If
'check if A:Drive has been choosen
If UCase(dirname) = "A:\" Then
'Hide the dialogue box
Me.Hide
'inform the user
MsgBox ("Insufficient Space to Process Drawings on Drive A:"), 16, _
"DWF Batcher"
'end the application
End
End If
'inform the user that we are about to connect to AutoCAD
Label5.Caption = "Please Wait......" & vbCr & "Connecting to AutoCAD"
'if error carry on with next line
On Error Resume Next
'set reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application")
'if there is an error (AutoCAD not open)
If Err Then
'clear the error
Err.Clear
'open AutoCAD
Set acadApp = CreateObject("Autocad.Application")
AutoCAD and HTML - Page IV
http://www.afralisp.com/lisp/html4.htm (2 of 5) [23/03/2005 05:46:11 p.m.]
'set reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application")
'if there is another error
If Err Then
'inform user
MsgBox Err.Description
'exit application
Exit Sub
End If
End If
'Make Autocad Visible
acadApp.Visible = True
'set reference to active document
Set acadDoc = acadApp.ActiveDocument
'Retrieve the SDI mode
MMode = acadDoc.GetVariable("SDI")
'Check SDI
If MMode = 0 Then
'Switch it on
acadDoc.SetVariable "SDI", 1
End If
'Hide the dialogue box
Me.Hide
'get the next free file number
nFile = FreeFile
'open the html file to write to
Open dirname & "DWFBatcher.htm" For Output As #nFile
'write the header
Print #nFile, "<html><head><title>WMF Batcher</title></head><body> _
<h3>DWF _ Batcher</h3>"
'retrieve the first entry
filename = Dir(dirname, vbNormal)
'start the loop
Do While filename <> ""
'ignore files that do not end with .DWG
If UCase(Right$(filename, 4)) = ".DWG" Then
'use bitwise comparison to make sure filename is not a directory
If (GetAttr(dirname & filename) And vbNormal) = vbNormal Then
'if drawing not saved
If Not acadDoc.Saved Then
'save the drawing
acadDoc.Save
End If
End If
'*******************************************************************
'This is the section of the program where you process each drawing.
'You can do anything your little heart desires........
AutoCAD and HTML - Page IV
http://www.afralisp.com/lisp/html4.htm (3 of 5) [23/03/2005 05:46:11 p.m.]
'open drawing to process
acadDoc.Open dirname & filename
'get the length of the filename
mylen = Len(filename)
'subtract the .DWG Extension
mylen = mylen - 4
'retrieve the drawing name
filename1 = Left(filename, mylen)
'write the DWF file name link
Print #nFile, "<a href=" & dirname & filename1 & ".DWF" & ">" & _
dirname & filename1 & ".DWF" & "</a>" & "<p>"
'set reference to the viewports
Set pViewport = acadDoc.ActiveViewport
'zoom to extents
pViewport.ZoomExtents
'create the DWF file
'commands shown are for the default DWFOUT settings
'you may need to replace to suit your requirements
acadDoc.SendCommand "DWFOUT" & vbCr & vbCr & vbCr & vbCr & _
vbCr & vbCr
'save the drawing
acadDoc.Save
End If
'get the next entry
filename = Dir
'carry on looping
Loop
'write the footer
Print #nFile, "</body></html>"
'close the file
Close #nFile
'reset SDI
acadDoc.SetVariable "SDI", MMode
'Close Autocad
acadApp.Quit
're-display the dialog
Me.Show
'inform the user
Label5.Caption = "Process Complete......" & vbCr & _
"Select another Directory or Cancel"
End Sub
'-------------------------------
Private Sub Dir1_Change()
'retrieves the drive and directory name
File1.Path = Dir1.Path
'displays it in the dialog
Label4.Caption = Dir1.Path
End Sub
'--------------------------------
AutoCAD and HTML - Page IV
http://www.afralisp.com/lisp/html4.htm (4 of 5) [23/03/2005 05:46:11 p.m.]
Private Sub Drive1_Change()
'retrieves the drive name
Dir1.Path = Drive1.Drive
End Sub
'---------------------------------
Private Sub Form_Load()
'Populate the labels
Label1.Caption = "Directory to Process :"
Label2.Caption = "Choose Drive and Directory"
Label3.Caption = "Brought to you by CAD Encoding"
End Sub
Save your Project as "DwfBatcher." When you run this program, a dialog will appear as shown above.
Choose the drive and directory containing the drawings you would like to process, then select "Go for
it." If AutoCAD is not already open, it will be opened and each drawing will be plotted as a DWF file. On
completion, an HTML file will be created in the same directory as the drawings.
To download the source coding for all four of these routines, put the index finger of your left hand in
your right nostril, stick your tongue out, and then click here.
Home Page I Page II Page III

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and HTML - Page IV
http://www.afralisp.com/lisp/html4.htm (5 of 5) [23/03/2005 05:46:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Publishing Coding
Okay, you've written your coding, it works great, your boss and your workmates think you're brilliant,
but now you would like to share your coding with the whole wide world.
So, off you go and organise yourself some web space, start your first page, put some witty comments
at the top, and then plonk in your coding.
Then this is what happens :
(defun c:al-move ( / util BP PT2) (vl-load-com) ;get a reference to the Utilities Object : (setq util (vla-get-utility
(vla-get-activedocument (vlax-get-acad-object)))) ;select the object (vla-getentity util 'theobj 'ip "\nSelect Object:
") ;get the base point (setq BP (vla-getpoint util nil "\nSpecify base point or displacement: ")) ;get the
displacement (setq PT2 (vla-getpoint util BP "\nSpecify second point of displacement: ")) ;move the object
(vla-move theobj BP PT2) (princ) );defun (princ)
All your beautifully formatted coding has become a jumbled mess because all the white space and line breaks have
been removed.
The solution though, is an easy one to explain.
Simply wrap your coding using the <pre> tags :
<pre>
Your coding goes here
</pre>
Your coding will now look like this :
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
Publishing Coding
http://www.afralisp.com/html/publishing_coding_I.htm (1 of 4) [23/03/2005 05:46:12 p.m.]
An even better way, is to place your coding within the <pre> tags, AND within a table :
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
Much easier to read and quite nice to look at if I may say so myself.
Here's the HTML coding for the table :
<table border="3" cellpadding="3" cellspacing="0" width="500" bgcolor="#00FFFF">
<tr>
<td>
<pre>
Your coding goes here
</pre>
</td>
</tr>
</table>
Now let's get really clever and place our coding into an Inline Frame :
[Netscape users should click here to see what they are missing]
Hey Kenny, now you're really cooking!!
The HTML coding for an Inline Frame looks like this :
<IFRAME
frameBorder=1 height=200 width=550 marginHeight=0 marginWidth=1 src="code.htm">[Netscape users should
click <a href="code.htm">here</a>
to see what they are missing]
</IFRAME>
Publishing Coding
http://www.afralisp.com/html/publishing_coding_I.htm (2 of 4) [23/03/2005 05:46:12 p.m.]
You will find the HTML coding for the frame page "code.htm" here.
But, the ultimate is to make use of Randall Rath's Language Formatter which will result in something like this :
[Netscape users should click here to see what they are missing]
The Language Formatter will convert your AutoLisp/VBA Coding into HTML, colour code it, and even add line
numbers if you so wish.
If you would like a standalone application that colour codes AutoLisp coding, have a look at "wLsp2html" written
by Mark Duenas.
Oh, just one more thing before I pop off to the fridge for another beer, would you like to strip all the white space out
of your AutoLisp coding?
Open a new file in Notepad and add these lines :
<HTML>
<HEAD>
<TITLE>Strip White Space</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
Now add you code between the <BODY> and </BODY> tags :
<HTML>
<HEAD>
<TITLE>Strip White Space</TITLE>
</HEAD>
<BODY>
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
</BODY>
</HTML>
Save this file as "STRIP.HTML".
Now open this file in your browser.
Copy the text that appears in your browser and paste it into Notepad.
All the white space has been stripped from your coding.
Publishing Coding
http://www.afralisp.com/html/publishing_coding_I.htm (3 of 4) [23/03/2005 05:46:12 p.m.]
The above AutoLisp coding will now look like this :
(defun c:al-move ( / util BP PT2) (vl-load-com) ;get a reference to the Utilities Object : (setq util (vla-get-utility
(vla-get-activedocument (vlax-get-acad-object)))) ;select the object (vla-getentity util 'theobj 'ip "\nSelect Object: ") ;get
the base point (setq BP (vla-getpoint util nil "\nSpecify base point or displacement: ")) ;get the displacement (setq PT2
(vla-getpoint util BP "\nSpecify second point of displacement: ")) ;move the object (vla-move theobj BP PT2) (princ)
);defun (princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Publishing Coding
http://www.afralisp.com/html/publishing_coding_I.htm (4 of 4) [23/03/2005 05:46:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
Coding
http://www.afralisp.com/html/code.htm (1 of 2) [23/03/2005 05:46:13 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Coding
http://www.afralisp.com/html/code.htm (2 of 2) [23/03/2005 05:46:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
code2.htm
http://www.afralisp.com/html/code2.htm (1 of 2) [23/03/2005 05:46:14 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
code2.htm
http://www.afralisp.com/html/code2.htm (2 of 2) [23/03/2005 05:46:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Lisp to HTML
Download wLsp2html.zip (201 kB)
Here's a handy little program that will convert an AutoLisp file into HTML and create the web page. It
was written by a gentleman named Mark Duenas.
While you're here, pop along here and have a look at Mark's Guitar site :
http://www.cableone.net/mdeunas/guitar/default.htm
wLsphtml.exe is a windows version of Lsphtml.exe! (an upgrade of sorts) AutoLISP to HTML converter.
To use this program double click on wlsphtml.exe to run the dialog G
Next click on the button next to the input file edit box to choose a single or multiple .LSP files to
convert to HTML.
G
Next click on the button next to the output file edit box to choose an output directory. G
[optional] Next click on the button next to the Background Graphics File edit box to choose a
background image for the html file(s). This is optional so if you dont have a background to
include you may ignore this field.
G
[optional] The Include Visual Lisp Functions check box includes the keywords for Visual Lisp
(over 1500 of them) in the conversion. So if you dont use them and you have many files to
convert it would be faster not to check this check box.
G
[optional] The Exit after convert just exits the program after converting the file or files. G
Questions, Comments, Bugs:
Please let me know how this program could better serve your needs. Thanks!
Mark Duenas
2698 N. Robie Ave.
Meridian, ID 83642
markduenas@cableone.net
Here's an example of wLsp2html in action :
Lisp to HTML
http://www.afralisp.com/lisp/lsp2htlm.htm (1 of 5) [23/03/2005 05:46:17 p.m.]
(defun c:batchpurge ( / CNTR DPATH DWGPATH FILE1 FLAG FLEN FNAME
FNAME1 LEN1 MESSAGE NFILES NFILES1 SCRFILE
UFILES)
;;;Firstly we need to check if DOSLib is loaded.
(cond
((= (atoi (substr (getvar "acadver") 1 2)) 13)
(if (not (member "doslib13.arx" (arx)))
(arxload (findfile "doslib13.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 14)
(if (not (member "doslib14.arx" (arx)))
(arxload (findfile "doslib14.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 15)
(if (not (member "doslib2k.arx" (arx)))
(arxload (findfile "doslib2k.arx"))))
);cond
;;;This, first checks the version of AutoCAD in use.
;;;It then checks to see if that version of Doslib is loaded.
;;;If it is not, it searches the AutoCAD search path for the
;;;relevant version, and then loads it.
;;;Now, we need to retrieve the names of the files that we would
;;;like to make slides from.
(setq dwgpath (getvar "dwgprefix"))
;get the path to the current directory
(setq ufiles (dos_getfilem "Select Drawings"
dwgpath "Drawing Files (*.DWG)|*.DWG"))
;display the file dialogue box
(if (not ufiles)
;if no files selected or Cancel

(exit)
;exit the application
);
;;;The first item in the list "ufiles" is the directory path
;;;The remaining items are the file names.
;;;First, let's retrieve the directory path.
(setq dpath (nth 0 ufiles))
;retrieve the directory path - the first item.
;;;Next, let's get the number of items in the list,
;;;and make sure that the user wants to continue.
(setq nfiles (length ufiles))
;get the length of the list
(setq nfiles1 (itoa (- nfiles 1)))
;count only the file names and convert to a string
(setq message (strcat "You have choosen " nfiles1 " files.
Lisp to HTML
http://www.afralisp.com/lisp/lsp2htlm.htm (2 of 5) [23/03/2005 05:46:17 p.m.]
\nDo you want to continue?"))
;set up the message
(setq flag (dos_msgbox message "AfraLisp Batch Purge" 4 4))
;display the message box
(if (= flag 6)
;if Yes selected
(progn
;do the following
;;;We'll now open an external file to write our script to.
(setq scrfile (strcat dpath "batdir.scr"))
;add the path to the script file name
(setq file1 (open scrfile "w"))
;open the file to write
(setq cntr 1)
;set the counter
;;;We'll now start the loop, format the file names, and add
;;;the commands to the script file.
(repeat (- nfiles 1)
;start the loop
(setq fname (nth cntr ufiles))
;get the file name
(setq fname (strcat dpath fname))
;add the path to the file name.
;"fname" will be used to open each
;drawing.
;(setq flen (strlen fname))
;get the length of file name
;(setq len1 (- flen 4))
;take away the last 4 characters (.DWG)
;(setq fname1 (substr fname 1 len1))
;get just the filename without the extension.
;"fname1" will be used as our slide file name.
;;;write the commands to the script file
(write-line (strcat "open " fname) file1)
;open the drawing
;write it to the script file
(write-line (strcat "filedia" " 0") file1)
;switch off dialogues
;write it to the script file
(write-line (strcat "purge") file1)
Lisp to HTML
http://www.afralisp.com/lisp/lsp2htlm.htm (3 of 5) [23/03/2005 05:46:17 p.m.]
;purge the drawing
;write it to the script file
(write-line (strcat "A") file1)
;purge ALL
;write it to the script file
(write-line (strcat "*") file1)
;purge EVERYTHING
;write it to the script file
(write-line (strcat "N") file1)
;NO
;write it to the script file
(write-line (strcat "filedia" " 1") file1)
;switch on dialogues
;write it to the script file
(write-line "qsave" file1)
;save the drawing
;write it to the script file

(setq cntr (1+ cntr))
;increment the counter
);repeat
;;;now that we've finished writing the commands to the script
;;;file, we must remember to close it.
(close file1)
;close the script file
(command "script" scrfile)
;run the script file and sit back and have a beer.
);progn
);if
(princ)
);defun
(princ)

Lisp to HTML
http://www.afralisp.com/lisp/lsp2htlm.htm (4 of 5) [23/03/2005 05:46:17 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Lisp to HTML
http://www.afralisp.com/lisp/lsp2htlm.htm (5 of 5) [23/03/2005 05:46:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Creating a Toolbar DLL (14Kb)
Are you sick and tired of having all those Toolbar Bitmap Files floating around?
And, what a pain it is having to remember to attach the bitmaps along with the
Toolbar menu file every time you send it to someone, or install the menu on another workstation.
(Smiley Faces here we come..)
The solution to this, is to store the Bitmaps in an ActiveX DLL file. (The same as
AutoCAD do with their Toolbar Bitmaps.) Here's the steps to construct your own,
customized Toolbar DLL.
Unfortunately, you will require the Visual Basic Resource Editor which is only
included with VB6. (I do believe though, that the Resource Editor is available as a plug-in for VB5.)
Firstly, you need to build your Toolbar along with all relevant Bitmaps and test it within AutoCAD. Here is
the menu file for the VBA Toolbar which is in the downloadable sample file :
***MENUGROUP=VBA
***TOOLBARS
ID_VBA_0 [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
ID_VBA_1 [_Button("VBA Load", "vbaload.bmp", "vbaload32.bmp")]^C^C_vbaload
ID_VBA_2 [_Button("VBA Macro", "vbamacro.bmp", "vbamacro32.bmp")]^C^C_vbarun
ID_VBA_3 [_Button("VBA Editor", "vbaide.bmp", "vbaide32.bmp")]^C^C_vbaide
ID_VBA_4 [_Button("VBA Manager", "vbaman.bmp", "vbaman32.bmp")]^C^Cvbaman
***HELPSTRINGS
ID_VBA_1 [Load VBA Project]
ID_VBA_2 [Run VBA Macro]
ID_VBA_3 [Load VBA Editor]
ID_VBA_4 [Load VBA Manager]
Your Toolbar should look like this :
Now, do yourself a favour and store the Menu file and all Bitmaps into their own sub-directory. If you don't,
you will find it a problem later on when editing the DLL file to locate all the VB support files.
Now fire up VB6 and start a new ActiveX DLL project. Next, open the VB6 Resource Editor. If it is not
loaded, go to the Add-In Manager and load it.
Creating a Toolbar DLL
http://www.afralisp.com/vbaa/vba15.htm (1 of 3) [23/03/2005 05:46:20 p.m.]
Once in the Resource Editor, load each of your Bitmap Files, renaming each Bitmap to match that of the
relevant name in the menu. (Right-Click on each name and select Properties.) Now save your project. (Save it
using the same name as your Menu and to the same sub-directory.)
Finally, choose "File" - "Make YourMenuName.DLL", again saving it to the same directory. (It is important
that the DLL file has the same name as the Menu.)
You can now exit VB6. (saving any files if prompted.)
One final step. (Well, a couple!!) Open up your Menu file and remove the .BMP extension from the Bitmap
file names. It should look like this :
***MENUGROUP=VBA
***TOOLBARS
ID_VBA_0 [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
ID_VBA_1 [_Button("VBA Load", "vbaload", "vbaload32")]^C^C_vbaload
ID_VBA_2 [_Button("VBA Macro", "vbamacro", "vbamacro32")]^C^C_vbarun
ID_VBA_3 [_Button("VBA Editor", "vbaide", "vbaide32")]^C^C_vbaide
ID_VBA_4 [_Button("VBA Manager", "vbaman", "vbaman32")]^C^Cvbaman
***HELPSTRINGS
ID_VBA_1 [Load VBA Project]
ID_VBA_2 [Run VBA Macro]
ID_VBA_3 [Load VBA Editor]
ID_VBA_4 [Load VBA Manager]
Then copy your Menu file and the DLL file to any of your AutoCAD support path
directories. You now need to re-compile your Menu file. To do this, first delete all MNS, MNC and MNR files
with the same name as your menu. Then fire up AutoCAD and load your menu. Hopefully, no smiley
faces......
From now on, all you need to do to distribute your menu is to include the DLL file
along with the Menu file. Bye, Bye Bitmaps.....

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Creating a Toolbar DLL
http://www.afralisp.com/vbaa/vba15.htm (2 of 3) [23/03/2005 05:46:20 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating a Toolbar DLL
http://www.afralisp.com/vbaa/vba15.htm (3 of 3) [23/03/2005 05:46:20 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Creating a Toolbar DLL Re-Visited
A big problem for AutoCAD uses when creating or custumising toolbars is ensuring that all the
bitmap files used by the toolbar are available and within the AutoCAD search path. In my tutorial
"Creating a Toolbar DLL" I explained how to create a DLL file to store all your toolbar bitmaps
using the Visual Basic Resource Editor. Now this is great if you're lucky enough to have VB6, but
what if you haven't? Well, I was introduced to a great little FREE application the other day that
will allow you to create and edit DLL files without having VB6 installed. This application, called
"Resource Hacker," was written by Angus Johnson and you can find it at :
http://www.users.on.net/johnson/resourcehacker/
AutoCAD Usage :
Before you start, please unload the relevant menu file from AutoCAD and then delete the MNC,
MNS and MNR files belonging to the menu. You should be left with just your MNU file. This is to
prevent AutoCAD from getting confused.
First you must install "Resource Hacker."
Secondly have all your toolbar bitmap files ready and in one directory.
As far as I know, you cannot create a new DLL file using the "Resource Hacker," so I have
supplied an empty DLL file called "AfraLisp.dll." I would suggest you place this file in the same
directory as your bitmap files.
I have supplied some sample bitmaps and a sample AutoCAD Toolbar menu to use as an example.
O.K. away we go. Fire up the "Resource Hacker."
From the pulldown menu select "File" -> "Open" and select "AfraLisp.dll."
Next, select "Action" -> "Add a new Resource."
Creating a Toolbar DLL Re-Visited
http://www.afralisp.com/vbaa/vbadll.htm (1 of 5) [23/03/2005 05:46:29 p.m.]
The "Add a New Resource" dialogue will appear:
Click the "Open file with new resource" button, and select your first bitmap file.
In the "Resource Name" text box, enter the name of your bitmap, excluding the file extension:
Next, click on the "Add Resource" button:
Creating a Toolbar DLL Re-Visited
http://www.afralisp.com/vbaa/vbadll.htm (2 of 5) [23/03/2005 05:46:29 p.m.]
Under the resource list your bitmap file will appear.
Repeat this process for all additional bitmap files.
When you have finished, the resource list should look like this:

Now, choose "File" -> "Save As" and save the file as "vbatoolbar.dll."
Now this is extremely important. The DLL file must have EXACTLY the same name as your menu
name and MUST be in the same directory. Copy the DLL file to the same directory as your MNU
file.
O.K. we've now created out Menu DLL file, but we still have to make some changes to our menu
file.
Open the menu file "vbatoolbar.mnu." It should look like this :
***MENUGROUP=VBA
***TOOLBARS
ID_VBA_0 [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
Creating a Toolbar DLL Re-Visited
http://www.afralisp.com/vbaa/vbadll.htm (3 of 5) [23/03/2005 05:46:29 p.m.]
ID_VBA_1 [_Button("VBA Load", "vbaload.bmp", "vbaload32.bmp")]^C^C_vbaload
ID_VBA_2 [_Button("VBA Macro", "vbamacro.bmp", "vbamacro32.bmp")]^C^C_vbarun
ID_VBA_3 [_Button("VBA Editor", "vbaide.bmp", "vbaide32.bmp")]^C^C_vbaide
ID_VBA_4 [_Button("VBA Manager", "vbaman.bmp", "vbaman32.bmp")]^C^Cvbaman
***HELPSTRINGS
ID_VBA_1 [Load VBA Project]
ID_VBA_2 [Run VBA Macro]
ID_VBA_3 [Load VBA Editor]
ID_VBA_4 [Load VBA Manager]
You now need to remove the file extension from all of the bitmap references. Your menu file should
now look like this :
***MENUGROUP=VBA
***TOOLBARS
ID_VBA_0 [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
ID_VBA_1 [_Button("VBA Load", "vbaload", "vbaload32")]^C^C_vbaload
ID_VBA_2 [_Button("VBA Macro", "vbamacro", "vbamacro32")]^C^C_vbarun
ID_VBA_3 [_Button("VBA Editor", "vbaide", "vbaide32")]^C^C_vbaide
ID_VBA_4 [_Button("VBA Manager", "vbaman", "vbaman32")]^C^Cvbaman
***HELPSTRINGS
ID_VBA_1 [Load VBA Project]
ID_VBA_2 [Run VBA Macro]
ID_VBA_3 [Load VBA Editor]
ID_VBA_4 [Load VBA Manager]
You are now ready to try out your menu. Load and run it. Your toolbar should appear and look
like this :
That's it, no more "smiley faces." Simple hey?
You can now remove all your bitmap files. Do yourself a favour though, keep them somewhere safe
so that if you have to re-compile your DLL files, you still have your source bitmaps.
To download the source files for this tutorial including the empty DLL file,
just click here - Download VbaDll.Zip (8kB)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Creating a Toolbar DLL Re-Visited
http://www.afralisp.com/vbaa/vbadll.htm (4 of 5) [23/03/2005 05:46:29 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating a Toolbar DLL Re-Visited
http://www.afralisp.com/vbaa/vbadll.htm (5 of 5) [23/03/2005 05:46:29 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ResourceTool.exe
Ed Jobe 2003
ResourceTool is a tool for use with VB to help with compiling resource dll's for a menu.
Normally, if you use the Resource Editor add-in and you load a
bmp, the editor assings a sequential number as the resource ID.
This means that if you want to continue referring to icons in your
menu by a name, you have to rename all the ID's in the RES file.
This tool avoids that using the rc.exe tool that comes with Visual
Studio. This utility can compile a C++ resource file (*.rc) into a
VB resource file (*.RES).
This program requires you to act in a specific sequence.
Specify a source folder where the bmp's reside. I suggest creating
a folder for your menu where you keep all the resources (the
bmp's, rc, res, vbp and dll). When finished, copy the dll to the
menu folder.
G
Specify an *.rc filename. Be sure to include the extension. G
Click on the "Create *.rc file" button. The program then scans the folder for all the bmp's and builds an *.RC file in
the folder specified in step 1, opening it in Notepad.
You can check it for accuracy or delete a line, etc.
G
Click on the "Compile RES file" button. The program compiles this file from the RC file. G
All you have to do then is, add the RES file to your dll project and compile the dll. G
Download ResourceTool.exe
AfraLisp - Resource Manager
http://www.afralisp.com/lispb/resourced.htm (1 of 2) [23/03/2005 05:46:31 p.m.]
For step-by-step instructions on getting the dll to work with your menu, see :
Create a Toolbar DLL. G
Create a Toobar DLL Re-Visited G

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp - Resource Manager
http://www.afralisp.com/lispb/resourced.htm (2 of 2) [23/03/2005 05:46:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Batch Purge 2002
Batch Purge 2002 will batch purge ALL from a selected list of drawings.
You will need to have AutoCAD installed on your system, but will run without AutoCAD being open.
Updated for R2002 but should run fine on R2000 and R2000i.
Written in Visual Basic 6. Click here to download all VB6 source files.
Usage :
There are three ways of selecting files to purge. You can use the "Select All" button to select all
the drawing files in the current directory, you can double click on individual files, or you can
select a file and use the "Add Files" button. All files selected will be added to the Purge File List
Box.
G
You can select files from multiple directories. G
You can remove files from the Purge File List box by choosing "Remove All", double-clicking on a
file, or choosing a file and clicking the "Remove File" button.
G
Once you are happy with the your file selection, select the "Purge" button to start the Batch Purge
Process. AutoCAD does not have to be open for the process to proceed.
G
You can also selected the "Delete BAK Files" check box to have these files automatically deleted. G

Batch Purge 2002


http://www.afralisp.com/vba/bp2002.htm (1 of 2) [23/03/2005 05:46:35 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Batch Purge 2002
http://www.afralisp.com/vba/bp2002.htm (2 of 2) [23/03/2005 05:46:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Batch Purge 2004
Batch Purge 2004 will batch purge ALL from a selected list of drawings.
You will need to have AutoCAD 2004 installed on your system, but will run without AutoCAD being
open. Updated for R2004.
Written in Visual Basic 6. Click here to download all VB6 source files.
Usage :
There are three ways of selecting files to purge. You can use the "Select All" button to select all
the drawing files in the current directory, you can double click on individual files, or you can
select a file and use the "Add Files" button. All files selected will be added to the Purge File List
Box.
G
You can select files from multiple directories. G
You can remove files from the Purge File List box by choosing "Remove All", double-clicking on a
file, or choosing a file and clicking the "Remove File" button.
G
Once you are happy with the your file selection, select the "Purge" button to start the Batch Purge
Process. AutoCAD does not have to be open for the process to proceed.
G
You can also selected the "Delete BAK Files" check box to have these files automatically deleted. G

Batch Purge 2004


http://www.afralisp.com/vba/bp2004.htm (1 of 2) [23/03/2005 05:46:39 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Batch Purge 2004
http://www.afralisp.com/vba/bp2004.htm (2 of 2) [23/03/2005 05:46:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
RC-Batcher (67Kb)
This application was sent to me by Ramn Castro.
It basically allows you to run any AutoLISP routine against a selected set of drawings.
Usage

Open the application. G


Choose the files to be processed.
(You can choose files from multiple directories.)
G
Select "Browse". G
A new dialogue will open. G
Select the lisp file to use. G
Select O.K. G
RC-Batcher
http://www.afralisp.com/vbaa/vba14.htm (1 of 2) [23/03/2005 05:46:43 p.m.]
Select "Run". G
In the downloadable Zip file, I have included a sample lisp file (Slidem.lsp) that will create slides
from a selection of drawings.
This application is written in Visual Basic 6, so you may require MSVBVM60.DLL to run. Contact
Ramn or myself if you require it.
Ramn Castro is a Survey CADD Technician for City of Fort Lauderdale Engineering.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
RC-Batcher
http://www.afralisp.com/vbaa/vba14.htm (2 of 2) [23/03/2005 05:46:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Drawing Export (9 Kb)
AcadExport.Exe is a stand alone application written in Visual Basic for AutoCAD Release 14.
This routine will Export a selected directory of drawings.
Formats available for export are WMF, DXF, EPS and BMP.
If AutoCAD is not open when you run the application, it will automatically open AutoCAD. You
can also run it from within Autocad.
Usage :
Open the application by double clicking on AcadExport.Exe.
A dialogue box will appear. Select the directory where the drawings you wish to Export reside.
Select the format you wish to export the file as from the radio buttons and then Select "OK".
If you wish to run it from within AutoCAD type the following at the command prompt :
(startapp "....directory path..../acadexport.exe")
Please note that you cannot Export Drawings to Drive A:.
The VBA Code
The following must be placed under the event procedure of the Drive List Box:
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
'retrieves the drive name
End Sub
Next, place this coding under the event procedure of the Directory List Box:
Private Sub Dir1_Change()
Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (1 of 6) [23/03/2005 05:46:46 p.m.]
File1.Path = Dir1.Path
'retrieves the drive and directory name
End Sub
The main routine of the function is within the event procedure of the "Export" button:
Private Sub btnExport_Click()
Dim acadApp As Object
Dim acadDoc As Object
Dim filename As String
Dim dirname As String
Dim sset As Object
Dim pViewport As Object
'declare variables

If Right(File1.Path, 1) <> "\" Then
'test for root directory
dirname = File1.Path & "\"
'if not root add \
Else
dirname = File1.Path
'if root directory do nothing
End If
If UCase(dirname) = "A:\" Then
'check if A:Drive has been choosen
Me.Hide
'Hide the dialogue box

MsgBox ("Insufficient Space to Export Drawings on Drive A:"),_
16, "Drawing Export"
'inform the user

End
'end the application

End If


On Error Resume Next
'if error carry on with next line
Set acadApp = GetObject(, "AutoCAD.Application")
'setq reference to AutoCAD Application
If Err Then
'if there is an error (AutoCAD not open)
Err.Clear
'clear the error
Set acadApp = CreateObject("Autocad.Application")
'open AutoCAD
Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (2 of 6) [23/03/2005 05:46:46 p.m.]
Set acadApp = GetObject(, "AutoCAD.Application")
'setq reference to AutoCAD Application
If Err Then
'if there is another error
MsgBox Err.Description
'inform user
Exit Sub
'exit application
End If
End If
acadApp.Visible = True
'Make Autocad Visible
Set acadDoc = acadApp.ActiveDocument
'set reference to active document
Me.Hide
'Hide the dialogue box

filename = Dir(dirname, vbNormal)
'retrieve the first entry
Do While filename <> ""
'start the loop
If UCase(Right$(filename, 4)) = ".DWG" Then
'ignore files that do not end with .DWG
If (GetAttr(dirname & filename) And vbNormal) = vbNormal Then
'use bitwise comparison to make sure filename is not a directory
If Not acadDoc.Saved Then
'if drawing not saved
If MsgBox("OK to Save Drawing?", 52, "Drawing Export") = vbNo Then
'give user choice to save drawing and continue, or exit application
End
'end if user selects No
Else
'or else
acadDoc.Save
'if Yes, save drawing
End If
Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (3 of 6) [23/03/2005 05:46:46 p.m.]
End If
acadDoc.Open dirname & filename
'open drawing to purge
mylen = Len(filename)
'get the length of the filename
mylen = mylen - 4
'subtract the .DWG Extension
filename1 = Left(filename, mylen)
'retrieve the drawing name
Set pViewport = acadDoc.ActiveViewport
'set reference to the viewports
pViewport.ZoomExtents
'zoom to extents
Set sset = acadDoc.SelectionSets.Add("NEWSS")
'set reference to election set
sset.Select acSelectionSetAll
'select the whole drawing
If Option1.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "WMF", sset
'export the drawing
End If
If Option2.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "DXF", sset
'export the drawing
End If
If Option3.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "DWF", sset
'export the drawing
End If
If Option4.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "SAT", sset
'export the drawing
End If
Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (4 of 6) [23/03/2005 05:46:46 p.m.]
If Option5.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "EPS", sset
'export the drawing
End If
If Option6.Value = True Then
'if radio button selected
acadDoc.Export dirname & filename1, "BMP", sset
'export the drawing
End If
acadDoc.Save
'save the drawing
End If
End If
filename = Dir
'get the next entry
Loop
'carry on looping
acadApp.Quit
'Close Autocad
MsgBox ("Drawing Export Complete"), , "Drawing Export"
'inform user that we have finished
End
'Close VBA Application
End Sub
Finally, this coding goes under the event procedure of the "Cancel" button:
Private Sub btnCancel_Click()
End
'end the routine
End Sub

Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (5 of 6) [23/03/2005 05:46:46 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Export
http://www.afralisp.com/vbaa/vba3.htm (6 of 6) [23/03/2005 05:46:46 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Batch Purge (7 Kb)
BatchPurge.Exe is a stand alone application written in Visual Basic for AutoCAD Release 14.
This routine will Batch Purge (Purge All) a selected directory of drawings.
If AutoCAD is not open when you run the application, it will automatically open AutoCAD. You
can also run it from within Autocad.
Usage :
Open the application by double clicking on BatchPurge.Exe.
A dialogue box will appear. Select the directory where the drawings you wish to Purge reside. Select
"OK".
If you wish to run it from within AutoCAD type the following at the command prompt :
(startapp "....directory path..../batchpurge.exe")
The VBA Code
The following must be placed under the event procedure of the Drive List Box:
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
'retrieves the drive name
End Sub
Next, place this coding under the event procedure of the Directory List Box:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
'retrieves the drive and directory name
End Sub
Batch Purge
http://www.afralisp.com/vbaa/vba2.htm (1 of 4) [23/03/2005 05:46:48 p.m.]
The main routine of the function is within the event procedure of the "Start Purge" button :
Private Sub Command1_Click()
Dim acadApp As Object
Dim acadDoc As Object
Dim filename As String
Dim dirname As String
'declare variables

If Right(File1.Path, 1) <> "\" Then
'test for root directory
dirname = File1.Path & "\"
'if not root add \
Else
dirname = File1.Path
'if root directory do nothing
End If
If UCase(dirname) = "A:\" Then
'check if A:Drive has been choosen
Me.Hide
'Hide the dialogue box

MsgBox ("Insufficient Space to Batch Purge Drawings on Drive A:"),_
16, "Batch Purge"
'inform the user

End
'end the application

End If


On Error Resume Next
'if error carry on with next line
Set acadApp = GetObject(, "AutoCAD.Application")
'setq reference to AutoCAD Application
If Err Then
'if there is an error (AutoCAD not open)
Err.Clear
'clear the error
Set acadApp = CreateObject("Autocad.Application")
'open AutoCAD
Set acadApp = GetObject(, "AutoCAD.Application")
'setq reference to AutoCAD Application
If Err Then
Batch Purge
http://www.afralisp.com/vbaa/vba2.htm (2 of 4) [23/03/2005 05:46:48 p.m.]
'if there is another error
MsgBox Err.Description
'inform user
Exit Sub
'exit application
End If
End If
acadApp.Visible = True
'Make Autocad Visible
Set acadDoc = acadApp.ActiveDocument
'set reference to active document
Me.Hide
'Hide the dialogue box

filename = Dir(dirname, vbNormal)
'retrieve the first entry
Do While filename <> ""
'start the loop
If UCase(Right$(filename, 4)) = ".DWG" Then
'ignore files that do not end with .DWG
If (GetAttr(dirname & filename) And vbNormal) = vbNormal Then
'use bitwise comparison to make sure filename is not a directory
If Not acadDoc.Saved Then
'if drawing not saved
If MsgBox("OK to Save Drawing?", 52, "Batch Purge") = vbNo Then
'give user choice to save drawing and continue, or exit application
End
'end if user selects No
Else
'or else
acadDoc.Save
'if Yes, save drawing
End If
End If
acadDoc.Open dirname & filename
'open drawing to purge
acadDoc.PurgeAll
'purge the drawing
Batch Purge
http://www.afralisp.com/vbaa/vba2.htm (3 of 4) [23/03/2005 05:46:48 p.m.]
acadDoc.Save
'save the drawing
End If
End If
filename = Dir
'get the next entry
Loop
'carry on looping
acadApp.Quit
'Close Autocad
MsgBox ("Batch Purge Complete"), , "Purge All"
'inform user that we have finished
End
'Close VBA Application
End Sub
Finally, this coding goes under the event procedure of the "Cancel" button :
Private Sub btnCancel_Click()
End
'end the routine
End Sub

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Batch Purge
http://www.afralisp.com/vbaa/vba2.htm (4 of 4) [23/03/2005 05:46:48 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp Drawing Backup
Do you need to transfer drawing files from one directory or drive to another?
Do you work on your local drives then transfer them to a network drive at the end of the
day? Or do you not trust your I.T. department and prefer to make your own backup of
critical files?
Then the AfraLisp Drawing Backup is for you. What does it do? Have a sneak preview :
Choose the directories you would like to back up from the Drive/Directory list boxes on the right,
clicking on "Add Folders >>" to add them to the "Folders Selected" list box. Highlight a directory
in the "Folders Selected" list box and select the "<< Clear Items" button to remove, or select "<<
Clear List" to remove all directories.
Next, select the "Browse" button to the right of the "Target" text box :
AfraLisp Drawing Backup
http://www.afralisp.com/vbaa/afraback.htm (1 of 3) [23/03/2005 05:46:55 p.m.]
Select the target directory you would like your drawings to be backed up to and then select "OK."
You will return to the main screen.
Now select "Start Backup" to process your selection. The text box at the bottom will give you a
running status of progress.
When the backup is complete the Report Dialogue will appear listing the backup results :
Click on the "View Log File" to open the Backup Log File, or select "Continue" to process
additional backups.
AfraLisp Drawing Backup
http://www.afralisp.com/vbaa/afraback.htm (2 of 3) [23/03/2005 05:46:55 p.m.]
Select the "Backup All Files" check box on the main screen if you want to backup all files
including drawing files.
You can also view the Log File from recent Backups by selecting the "View Log File" from the
main screen.
Download "AfraBack.zip" (173kb)
"AfraLisp Drawing Backup" was written using Visual Basic 6.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Drawing Backup
http://www.afralisp.com/vbaa/afraback.htm (3 of 3) [23/03/2005 05:46:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
How To Write Unmaintainable Code
Originally published at http://mindprod.com/unmain.html. Reprinted by special permission from the
author. Further reprints, without the express permission of the author are prohibited. Last updated
Thursday, 05-Apr-2001 03:41:36 PDT by Roedy Green 1997-2001 Canadian Mind Products.
Introduction
Never ascribe to malice, that which can be explained by incompetence.
Napoleon
In the interests of creating employment opportunities in the Java programming field, I am passing on
these tips from the masters on how to write code that is so difficult to maintain, that the people who
come after you will take years to make even the simplest changes. Further, if you follow all these rules
religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope
in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn't
be able to maintain the code!
You don't want to overdo this. Your code should not look hopelessly unmaintainable, just be that way.
Otherwise it stands the risk of being rewritten or refactored.
General Principles
Quidquid latine dictum sit, altum videtur.
Whatever is said in Latin sounds profound.
To foil the maintenance programmer, you have to understand how he thinks. He has your giant
program. He has no time to read it all, much less understand it. He wants to rapidly find the place to
make his change, make it and get out and have no unexpected side effects from the change.
He views your code through a tube taken from the centre of a roll of toilet paper. He can only see a tiny
piece of your program at a time. You want to make sure he can never get at the big picture from doing
that. You want to make it as hard as possible for him to find the code he is looking for. But even more
important, you want to make it as awkward as possible for him to safely ignore anything.
Programmers are lulled into complacency by conventions. By every once in a while subtly violating
convention you force him to read every line of your code with a magnifying glass.
You might get the idea that every language feature makes code unmaintainable -- not so, only if properly
misused.
Naming
"When I use a word," Humpty Dumpty said, in a rather scornful tone, "it means just what I
choose it to mean - neither more nor less."
Lewis Carroll -- Through the Looking Glass, Chapter 6
Much of the skill in writing unmaintainable code is the art of naming variables and methods. They don't
matter at all to the computer. That gives you huge latitude to use them to befuddle the maintenance
programmer.

New Uses For Names For Baby 1.


How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (1 of 19) [23/03/2005 05:47:00 p.m.]
20,001 Names For Baby
0-380-78047-X
Carol McD. Wallace
Buy a copy of a baby naming book and you'll never be at a loss for variable names. Fred is a
wonderful name, and easy to type. If you're looking for easy to type variable names, try adsf.

Single Letter Variable Names


If you call your variables a, b, c, then it will be impossible to search for instances of them using a
simple text editor. Further, nobody will be able to guess what they are for. If anyone even hints at
breaking the tradition honoured since FRTRAN of using i, j, and k for indexing variables,
replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics.
2.
Creative Missspelling
If you must use descriptive variable and function names, misspell them. By misspelling in some
function and variable names, and spelling it correctly in others (such as SetPintleOpening
SetPintalClosing) we effectively negate the use of grep or CodeWright search techniques. It works
amazingly well. Add an international flavor by spelling theater and theatre in different situations.
3.
Be Abstract
In naming functions and variables, make heavy use of abstract words like it, everything, data,
handle, stuff, do, routine, perform and the digits e.g. routineX48, PerformDataFunction, DoIt,
HandleStuff and do_args_method.
4.
A.C.R.O.N.Y.M.S.
Use acronyms to keep the code terse. Real men never define acronyms; they understand them
genetically.
5.
Thesaurus Surrogatisation
To break the boredom, use a thesaurus to look up as much alternate vocabulary as possible to
refer to the same action, e.g. display, show, present. Vaguely hint there is some subtle difference,
where none exists. However, if there are two similar functions that have a crucial difference,
always use the same word in describing both functions (e.g. print to mean write to a file, and to a
print on a laser, and to display on the screen). Under no circumstances, succumb to demands to
write a glossary with the special purpose project vocabulary unambiguously defined. Doing so
would be unprofessional breach of the structured design principle of information hiding.
6.
Use Plural Forms From Other Languages
A contributor was the proud author of a VMS script that kept track of the "statii" returned from
various "Vaxen". Esperanto, Klingon and Hobbitese qualify as languages for these purposes. For
pseudo-Esperanto pluraloj, add oj. You will be doing your part toward world peace.
7.
CapiTaliSaTion
If you use intercapitalization for function names (capitalize the first letter of each word), randomly
capitalize the first letter of a syllable in the middle of a word. For example:
ComputeRasterHistoGram().
8.
Recycle Classnames as Member Names 9.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (2 of 19) [23/03/2005 05:47:00 p.m.]
In C/C++: Make sure to create parameters and local variables that have the same name as member
variables of the class whose method they appear in. For extra points, create nested local
variables inside {} blocks that have the same name as these local variables. The goal is for careful
examination of scope to be the only way to tell which context is actually being used.
ccented Letters
Use accented characters on variable names. E.g.

typedef struct { int i; } nt;


where the second int's i is actually iacute. Since these are structures the three int's are not
interchangeable, but with an 8-bit aware editor it's nearly impossible to distinguish the slant of
the accent mark. Insist the new "ints " are for some specific, but very obscure, situation where a
standard int won't suffice. It helps to toss extra stuff into the structure before making that claim!
10.
Exploit Compiler Name Length Limits
If the compiler will only distinguish the first, say, 8 characters of names, then always use more
characters, but vary the endings e.g. var_unit_update() in one case and var_unit_setup() in
another.
11.
Underscore, a Friend Indeed
Use _ or __ as an identifier.

12.
Mix English and Bahasa Indonesia
If English is your second language, use English for variable names, functions, messages
appearing on-screen, and comments. However randomly intersperse them with words chosen
from your native language. If your boss insists you use English tell him you can organize your
thoughts better in your own language, or allege racial discrimination and threaten to sue your
employers for a vast sum of money. Now that your boss does not understand your code you can
use obscuration techniques that you would never get away with otherwise and will foil a future
maintenance programmer even if she is also a native speaker or is equipped with a bilingual
dictionary.
13.
Extended ASCII
Extended ASCII characters are perfectly valid as variable names, including , , and characters.
They are quite impossible to type without copying/pasting.
14.
Deutch, Franais, Esperanto
If you cannot find the right English word to convey the meaning of a temporary variable (and you
ignore the other suggestions about not giving meaningful names to variables), you may use a
foreign language word as the name of the variable. For example, instead of using variable "p" for
a "point", you may use "punkt", which is the German word for it. Maintenance coders without
your firm grasp of German will enjoy the multicultural experience of deciphering the meaning. It
breaks the tedium of an otherwise tiring and thankless job.
15.
Consider equals As A Variable Name
Choose variable names that are English versions of operators, to get statements like:

openParen = (slash + asterix) / equals;


16.
Bedazzling Variable Names
Choose all variable names to be words that have no association whatsoever with the actual
function of the program but which have strong inherent meaning as words. For example, you
could end up with statements like:

17.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (3 of 19) [23/03/2005 05:47:00 p.m.]
marypoppins = (julieAndrews + starship) / mailbox;
This confuses the reader because they have difficulty disassociating the concepts of the words
from the logic they're trying to think about. (Combine this with the above method and it's basically
impossible to recover, because search and replace becomes impossible.)
Rename and Reuse
This trick works especially well in Ada, a language immune to many of the standard obfuscation
techniques. The people who originally named all the objects and packages you use were morons.
Rather than try to convince them to change, just use renames and subtypes to rename everything
to names of your own devising. Make sure to leave a few references to the old names in, as a trap
for the unwary.
18.
Reuse Names
Java lets you create methods that have the same name as the class, but that are not constructors.
Exploit this to sow confusion.
19.
When To Use i
Never use i for the innermost loop variable. Use anything but. Use i liberally for any other purpose
especially for non-int variables. Similarly use n as a loop index.
20.
Conventions Schemtions
Ignore the conventions in Java for where to use upper case in variable and class names i.e.
Classes start with upper case, variables with lower case, constants are all upper case, with
internal words capitalised. After all, Sun does (e.g. instanceof vs isInstanceOf, Hashtable). Not to
worry, the compiler won't even issue a warning to give you away. If your boss forces you to use
the conventions, when there is any doubt about whether an internal word should be capitalised,
avoid capitalising or make a random choice, e.g. use both inputFileName and outputfilename. You
can of course drive your team members insane by inventing your own insanely complex naming
conventions then berate others for not following them. The ultimate technique is to create as
many variable names as possible that differ subtlely from each other only in case.
21.
Lower Case l Looks A Lot Like Digit 1
Use lower case l to indicate long constants. e.g. 10l is more likely to be mistaken for 101 that 10L
is.
22.
Reuse of Global Names as Private
Declare a global array in module A, and a private one of the same name in the header file for
module B, so that it appears that it's the global array you are using in module B, but it isn't. Make
no reference in the comments to this duplication.
23.
Recycling Revisited
Use scoping as confusingly as possible by recycling variable names in contradictory ways. For
example, suppose you have global variables A and B, and functions foo and bar. If you know that
variable A will be regularly passed to foo and B to bar, make sure to define the functions as
function foo(B) and function bar(A) so that inside the functions A will always be referred to as B
and vice versa. With more functions and globals, you can create vast confusing webs of mutually
contradictory uses of the same names.
24.
Recycle Your Variables
Wherever scope rules permit, reuse existing unrelated variable names. Similarly, use the same
temporary variable for two unrelated purposes (purporting to save stack slots). For a fiendish
variant, morph the variable, for example, assign a value to a variable at the top of a very long
method, and then somewhere in the middle, change the meaning of the variable in a subtle way,
such as converting it from a 0-based coordinate to a 1-based coordinate. Be certain not to
document this change in meaning.
25.
Cd wrttn wtht vwls s mch trsr
When using abbreviations inside variable or method names, break the boredom with several
26.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (4 of 19) [23/03/2005 05:47:00 p.m.]
variants for the same word, and even spell it out longhand once in while. This helps defeat those
lazy bums who use text search to understand only some aspect of your program. Consider
variant spellings as a variant on the ploy, e.g. mixing International colour, with American color
and dude-speak kulerz. If you spell out names in full, there is only one possible way to spell each
name. These are too easy for the maintenance programmer to remember. Because there are so
many different ways to abbreviate a word, with abbreviations, you can have several different
variables that all have the same apparent purpose. As an added bonus, the maintenance
programmer might not even notice they are separate variables.
Misleading names
Make sure that every method does a little bit more (or less) than its name suggests. As a simple
example, a method named isValid(x) should as a side effect convert x to binary and store the
result in a database.
27.
m_
a naming convention from the world of C++ is the use of "m_" in front of members. This is
supposed to help you tell them apart from methods, so long as you forget that "method" also
starts with the letter "m".
28.
o_apple obj_apple
Use an "o" or "obj" prefix for each instance of the class to show that you're thinking of the big,
polymorphic picture.
29.
Hungarian Notation
Hungarian Notation is the tactical nuclear weapon of source code obfuscation techniques; use it!
Due to the sheer volume of source code contaminated by this idiom nothing can kill a
maintenance engineer faster than a well planned Hungarian Notation attack. The following tips
will help you corrupt the original intent of Hungarian Notation:

30.
Insist on using "c" for const in C++ and other languages that directly enforce the
const-ness of a variable.
Seek out and use Hungarian warts that have meaning in languages other than your current
language. For example insist on the PowerBuilder "l_" and "a_ " {local and argument}
scoping prefixes and always use the VB-esque style of having a Hungarian wart for every
control type when coding to C++. Try to stay ignorant of the fact that megs of plainly visible
MFC source code does not use Hungarian warts for control types.
Always violate the Hungarian principle that the most commonly used variables should
carry the least extra information around with them. Achieve this end through the
techniques outlined above and by insisting that each class type have a custom wart prefix.
Never allow anyone to remind you that no wart tells you that something is a class. The
importance of this rule cannot be overstated: if you fail to adhere to its principles the
source code may become flooded with shorter variable names that have a higher
vowel/consonant ratio. In the worst case scenario this can lead to a full collapse of
obfuscation and the spontaneous reappearance of English Notation in code!
Flagrantly violate the Hungarian-esque concept that function parameters and other high
visibility symbols must be given meaningful names, but that Hungarian type warts all by
themselves make excellent temporary variable names.
Insist on carrying outright orthogonal information in your Hungarian warts. Consider this
real world example: "a_crszkvc30LastNameCol". It took a team of maintenance engineers
nearly 3 days to figure out that this whopper variable name described a const, reference,
function argument that was holding information from a database column of type
Varchar[30] named "LastName" which was part of the table's primary key. When properly
combined with the principle that "all variables should be public" this technique has the
power to render thousands of lines of source code obsolete instantly!
Use to your advantage the principle that the human brain can only hold 7 pieces of
information concurrently. For example code written to the above standard has the following
properties:

A single assignment statement carries 14 pieces of type and name information.


How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (5 of 19) [23/03/2005 05:47:00 p.m.]
A single function call that passes three parameters and assigns a result carries 29 pieces
of type and name information.
Seek to improve this excellent, but far too concise, standard. Impress management and
coworkers by recommending a 5 letter day of the week prefix to help isolate code written
on 'Monam' and 'FriPM'.
It is easy to overwhelm the short term memory with even a moderately complex nesting
structure, especially when the maintenance programmer can't see the start and end of each
block on screen simultaneously.

Hungarian Notation Revisited


One follow on trick in the Hungarian notation is "change the type of a variable but leave the
variable name unchanged". This is almost invariably done in windows apps with the migration
from Win16 :- WndProc(HWND hW, WORD wMsg, WORD wParam, LONG lParam) to Win32
WndProc(HWND hW, UINT wMsg, WPARAM wParam, LPARAM lParam) where the w values hint
that they are words, but they really refer to longs. The real value of this approach comes clear
with the Win64 migration, when the parameters will be 64 bits wide, but the old "w" and "l"
prefixes will remain forever.
1.
Obscure film references
Use constant names like LancelotsFavouriteColour instead of blue and assign it hex value of
$0204FB. The color looks identical to pure blue on the screen, and a maintenance programmer
would have to work out 0204FB (or use some graphic tool) to know what it looks like. Only
someone intimately familiar with Monty Python and the Holy Grail would know that Lancelot's
favorite color was blue. If a maintenance programmer can't quote entire Monty Python movies
from memory, he or she has no business being a programmer.
2.
Camouflage
The longer it takes for a bug to surface, the harder it is to find.
Roedy
Much of the skill in writing unmaintainable code is the art of camouflage, hiding things, or making
things appear to be what they are not. Many depend on the fact the compiler is more capable at making
fine distinctions than either the human eye or the text editor. Here are some of the best camouflaging
techniques.

Code That Masquerades As Comments and Vice Versa


Include sections of code that is commented out but at first glance does not appear to be.

for(j=0; j<array_len; j+ =8)


{
total += array[j+0 ];
total += array[j+1 ];
total += array[j+2 ]; /* Main body of
total += array[j+3]; * loop is unrolled
total += array[j+4]; * for greater speed.
total += array[j+5]; */
total += array[j+6 ];
total += array[j+7 ];
}
Without the colour coding would you notice that three lines of code are commented out?
1.
Arbitrary Names That Masquerade as Keywords
When documenting, and you need an arbitrary name to represent a filename use "file ". Never use
an obviously arbitrary name like "Charlie.dat" or "Frodo.txt". In general, in your examples, use
arbitrary names that sound as much like reserved keywords as possible. For example, good
names for parameters or variables would be: "bank", "blank", "class", "const ", "constant",
"input", "key", "keyword", "kind", "output", "parameter" "parm", "system", "type", "value", "var"
2.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (6 of 19) [23/03/2005 05:47:00 p.m.]
and "variable ". If you use actual reserved words for your arbitrary names, which would be
rejected by your command processor or compiler, so much the better. If you do this well, the
users will be hopelessly confused between reserved keywords and arbitrary names in your
example, but you can look innocent, claiming you did it to help them associate the appropriate
purpose with each variable.
Code Names Must Not Match Screen Names
Choose your variable names to have absolutely no relation to the labels used when such
variables are displayed on the screen. E.g. on the screen label the field "Postal Code" but in the
code call the associated variable "zip".
3.
How to Hide Forbidden Globals
Since global variables are "evil", define a structure to hold all the things you'd put in globals. Call
it something clever like EverythingYoullEverNeed. Make all functions take a pointer to this
structure (call it handle to confuse things more). This gives the impression that you're not using
global variables, you're accessing everything through a "handle". Then declare one statically so
that all the code is using the same copy anyway.
4.
Long Similar Variable Names
Use very long variable names or class names that differ from each other by only one character, or
only in upper/lower case. An ideal variable name pair is swimmer and swimner. Exploit the failure
of most fonts to clearly discriminate between ilI1| or oO08 with identifier pairs like parselnt and
parseInt or D0Calc and DOCalc. l is an exceptionally fine choice for a variable name since it will,
to the casual glance, masquerade as the constant 1. In many fonts rn looks like an m. So how
about a variable swirnrner. Create variable names that differ from each other only in case e.g.
HashTable and Hashtable.
5.
Similar-Sounding Similar-Looking Variable Names
Although we have one variable named xy_z, there's certainly no reason not to have many other
variables with similar names, such as xy_Z, xy__z, _xy_z, _xyz, XY_Z, xY_z, and Xy_z.
Variables that resemble others except for capitalization and underlines have the advantage of
confounding those who like remembering names by sound or letter-spelling, rather than by exact
representations.
6.
Documentation
Any fool can tell the truth, but it requires a man of some sense to know how to lie well.
Samuel Butler (1835 - 1902)

Incorrect documentation is often worse than no documentation.


Bertrand Meyer
Since the computer ignores comments and documentation, you can lie outrageously and do everything
in your power to befuddle the poor maintenance programmer.
Lie in the comments
You don't have to actively lie, just fail to keep comments as up to date with the code.

1.
Document the obvious
Pepper the code with comments like /* add 1 to i */ however, never document wooly stuff like the
overall purpose of the package or method.

2.
Avoid Documenting the "Obvious"
If, for example, you were writing an airline reservation system, make sure there are at least 25
places in the code that need to be modified if you were to add another airline. Never document
where they are. People who come after you have no business modifying your code without
thoroughly understanding every line of it.

3.
On the Proper Use Of Documentation Templates
Consider function documentation prototypes used to allow automated documentation of the
code. These prototypes should be copied from one function (or method or class) to another, but
4.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (7 of 19) [23/03/2005 05:47:00 p.m.]
never fill in the fields. If for some reason you are forced to fill in the fields make sure that all
parameters are named the same for all functions, and all cautions are the same but of course not
related to the current function at all.

On the Proper Use of Design Documents


When implementing a very complicated algorithm, use the classic software engineering principles
of doing a sound design before beginning coding. Write an extremely detailed design document
that describes each step in a very complicated algorithm. The more detailed this document is, the
better.
In fact, the design doc should break the algorithm down into a hierarchy of structured steps,
described in a hierarchy of auto-numbered individual paragraphs in the document. Use headings
at least 5 deep. Make sure that when you are done, you have broken the structure down so
completely that there are over 500 such auto-numbered paragraphs. For example, one paragraph
might be: (this is a real example)
1.2.4.6.3.13 - Display all impacts for activity where selected mitigations can apply (short
pseudocode omitted).
then... (and this is the kicker) when you write the code, for each of these paragraphs you write a
corresponding global function named:

Act1_2_4_6_3_13()
Do not document these functions. After all, that's what the design document is for!
Since the design doc is auto-numbered, it will be extremely difficult to keep it up to date with
changes in the code (because the function names, of course, are static, not auto-numbered.) This
isn't a problem for you because you will not try to keep the document up to date. In fact, do
everything you can to destroy all traces of the document.
Those who come after you should only be able to find one or two contradictory, early drafts of the
design document hidden on some dusty shelving in the back room near the dead 286 computers.

5.
Gotchas
Never document gotchas in the code. If you suspect there may be a bug in a class, keep it to
yourself. If you have ideas about how the code should be reorganised or rewritten, for heaven's
sake, do not write them down. Remember the words of Thumper in the movie Bambi "If you can't
say anything nice, don't say anything at all". What if the programmer who wrote that code saw
your comments? What if the owner of the company saw them? What if a customer did? You could
get yourself fired. An anonymous comment that says "This needs to be fixed!" can do wonders,
especially if it's not clear what the comment refers to. Keep it vague, and nobody will feel
personally criticized.

6.
Documenting Variables
Neverput a comment on a variable. Facts about how the variable is used, its bounds, its legal
values, its implied/displayed number of decimal points, its units of measure, its display format, its
data entry rules (e.g. total fill, must enter), when its value can be trusted etc. should be gleaned
from the procedural code. If your boss forces you to write comments, lard method bodies with
them, but never comment a variable, not even a temporary!

7.
Disparage In the Comments
Discourage any attempt to use external maintenance contractors by peppering your code with
insulting references to other leading software companies, especial anyone who might be
contracted to do the work. e.g.:

/* The optimised inner loop.


This stuff is too clever for the dullard at Software Services Inc., who would
probably use 50 times as memory & time using the dumb routines in .
8.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (8 of 19) [23/03/2005 05:47:00 p.m.]
*/
class clever_SSInc

{
.. .
}

If possible, put insulting stuff in syntactically significant parts of the code, as well as just the
comments so that management will probably break the code if they try to sanitize it before
sending it out for maintenance.

COMMENT AS IF IT WERE CBL ON PUNCH CARDS


Always refuse to accept advances in the development environment arena. Disbelieve rumors that
all functions and variables are never more than one click away and always assume that code
developed in Visual Studio 6.0 will be maintained by someone using edlin or vi. To this end insist
on Draconian commenting rules that bury the source code.

9.
Monty Python Comments
On a method called makeSnafucatedinsert only the comment /* make snafucated */. Never define
what snafucatedmeans anywhere. Only a fool does not already know, with complete certainty,
what snafucated means. For classic examples of this technque, consult the Sun AWT JavaDOC.
10.

Program Design
The cardinal rule of writing unmaintainable code is to specify each fact in as many places
as possible and in as many ways as possible.
Roedy

The key to writing maintainable code is to specify each fact about the application in only one
place. To change your mind, you need change it in only one place, and you are guaranteed the
entire program will still work. Therefore, the key to writing unmaintainable code is to specify a
fact over and over, in as many places as possible, in as many variant ways as possible. Happily,
languages like Java go out of their way to make writing this sort of unmaintainable code easy. For
example, it is almost impossible to change the type of a widely used variable because all the
casts and conversion functions will no longer work, and the types of the associated temporary
variables will no longer be appropriate. Further, if the variable is displayed on the screen, all the
associated display and data entry code has to be tracked down and manually modified. The Algol
family of languages which include C and Java treat storing data in an array, Hashtable, flat file
and database with totally different syntax. In languages like Abundance, and to some extent
Smalltalk, the syntax is identical; just the declaration changes. Take advantage of Java's
ineptitude. Put data you know will grow too large for RAM, for now into an array. That way the
maintenance programmer will have a horrendous task converting from array to file access later.
Similarly place tiny files in databases so the maintenance programmer can have the fun of
converting them to array access when it comes time to performance tune.

1.
Never Validate
Never check input data for any kind of correctness or discrepancies. It will demonstrate that you
absolutely trust the company's equipment as well as that you are a perfect team player who trusts
all project partners and system operators. Always return reasonable values even when data
inputs are questionable or erroneous.

2.
Be polite, Never Assert
Avoid the assert() mechanism, because it could turn a three-day debug fest into a ten minute one.
3.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (9 of 19) [23/03/2005 05:47:00 p.m.]

Avoid Encapsulation
In the interests of efficiency, avoid encapsulation. Callers of a method need all the external clues
they can get to remind them how the method works inside.

4.
Clone & Modify
In the name of efficiency, use cut/paste/clone/modify. This works much faster than using many
small reusable modules. This is especially useful in shops that measure your progress by the
lines of code you've written.

5.
Use Static Arrays
If a module in a library needs an array to hold an image, just define a static array. Nobody will
ever have an image bigger than 512 x 512, so a fixed-size array is OK. For best precision, make it
an array of doubles. Bonus effect for hiding a 2 Meg static array which causes the program to
exceed the memory of the client's machine and thrash like crazy even if they never use your
routine.

6.
Dummy Interfaces
Write an empty interface called something like "WrittenByMe", and make all of your classes
implement it. Then, write wrapper classes for any of Java's built-in classes that you use. The idea
is to make sure that every single object in your program implements this interface. Finally, write
all methods so that both their arguments and return types are WrittenByMe. This makes it nearly
impossible to figure out what some methods do, and introduces all sorts of entertaining casting
requirements. For a further extension, have each team member have his/her own personal
interface (e.g., WrittenByJoe); any class worked on by a programmer gets to implement his/her
interface. You can then arbitrary refer to objects by any one of a large number of meaningless
interfaces!

7.
Use Three Dimensional Arrays
Lots of them. Move data between the arrays in convoluted ways, say, filling the columns in arrayB
with the rows from arrayA. Doing it with an offset of 1, for no apparent reason, is a nice touch.
Makes the maintenance programmer nervous.

8.
Wrap, wrap, wrap
Whenever you have to use methods in code you did not write, insulate your code from that other
dirty code by at least one layer of wrapper. After all, the other author might some time in the
future recklessly rename every method. Then where would you be? You could of course, if he did
such a thing, insulate your code from the changes by writing a wrapper or you could let VAJ
handle the global rename. However, this is the perfect excuse to preemptively cut him off at the
pass with a wrapper layer of indirection, before he does anything idiotic. One of Java's main
faults is that there is no way to solve many simple problems without dummy wrapper methods
that do nothing but call another method of the same name, or a closely related name. This means
it is possible to write wrappers four-levels deep that do absolutely nothing, and almost no one will
notice. To maximise the obscuration, at each level, rename the methods, selecting random
synonyms from a thesaurus. This gives the illusion something of note is happening. Further, the
renaming helps ensure the lack of consistent project terminology. To ensure no one attempts to
prune your levels back to a reasonable number, invoke some of your code at the application level
via each of the levels.

9.
Wrap Wrap Wrap Some More
Make sure all API functions are wrapped at least 6-8 times, with function definitions in separate
source files.

10.
No Secrets!
Declare every method and variable public. After all, somebody, sometime might want to use it.
11.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (10 of 19) [23/03/2005 05:47:00 p.m.]
Once a method has been declared public, it can't very well be retracted, now can it? This makes it
very difficult to later change the way anything works under the covers. It also has the delightful
side effect of obscuring what a class is for. If the boss asks if you are out of your mind, tell him
you are following the classic principles of transparent interfaces.

The Kama Sutra


This technique has the added advantage of driving any users or documenters of the package to
distraction as well as the maintenance programmers. Create a dozen overloaded variants of the
same method that differ in only the most minute detail. I think it was Oscar Wilde who observed
that positions 47 and 115 of the Kama Sutra were the same except in 115 the woman had her
fingers crossed. Users of the package then have to carefully peruse the long list of methods to
figure out just which variant to use. The technique also balloons the documentation and thus
ensures it will more likely be out of date. If the boss asks why you are doing this, explain it is
solely for the convenience of the users. Again for the full effect, clone any common logic and sit
back and wait for it the copies to gradually get out of sync.

12.
Permute and Baffle
Reverse the parameters on a method called drawRectangle(height, width) to
drawRectangle(width, height) without making any change whatsoever to the name of the method.
Then a few releases later, reverse it back again. The maintenance programmers can't tell by
quickly looking at any call if it has been adjusted yet. Generalisations are left as an exercise for
the reader.

13.
Theme and Variations
Instead of using a parameter to a single method, create as many separate methods as you can.
For example instead of setAlignment(int alignment) where alignment is an enumerated constant,
for left, right, center, create three methods: setLeftAlignment, setRightAlignment, and
setCenterAlignment. Of course, for the full effect, you must clone the common logic to make it
hard to keep in sync.

14.
Cargill's Quandry
Take advantage of Cargill's quandary (I think this was his): "any design problem can be solved by
adding an additional level of indirection, except for too many levels of indirection." Decompose
OO programs until it becomes nearly impossible to find a method which actually updates
program state. Better yet, arrange all such occurrences to be activated as callbacks from by
traversing pointer forests which are known to contain every function pointer used within the
entire system. Arrange for the forest traversals to be activated as side-effects from releasing
reference counted objects previously created via deep copies which aren't really all that deep.

15.
Packratting
Keep all of your unused and outdated methods and variables around in your code. After all - if
you needed to use it once in 1976, who knows if you will want to use it again sometime? Sure the
program's changed since then, but it might just as easily change back, you "don't want to have to
reinvent the wheel" (supervisors love talk like that). If you have left the comments on those
methods and variables untouched, and sufficiently cryptic, anyone maintaining the code will be
too scared to touch them.

16.
The Magic Of Global Variables
The use of global variables is so obvious that no one thought to mention it until this point.
Instead of using exceptions to handle error processing, have your error message routine set a
global variable. Then make sure that every long-running loop in the system checks this global
flag and terminates if an error occurs. Add another global variable to signal when a user presses
the 'reset' button. Of course all the major loops in the system also have to check this second flag.
Hide a few loops that don't terminate on demand.

17.
Globals, We Can't Stress These Enough! 18.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (11 of 19) [23/03/2005 05:47:00 p.m.]
If God didn't want us to use global variables, he wouldn't have invented them. Rather than
disappoint God, use and set as many global variables as possible. Each function should use and
set at least two of them, even if there's no reason to do this. After all, any good maintenance
programmer will soon figure out this is an exercise in detective work, and she'll be happy for the
exercise that separates real maintenance programmers from the dabblers.

Globals, One More Time, Boys


Global variables save you from having to specify arguments in functions. Take full advantage of
this. Elect one or more of these global variables to specify what kinds of processes to do on the
others. Maintenance programmers foolishly assume that C functions will not have side effects.
Make sure they squirrel results and internal state information away in global variables.

19.
Local Variables
Never use local variables. Whenever you feel the temptation to use one, make it into an instance
or static variable instead to unselfishly share it with all the other methods of the class. This will
save you work later when other methods need similar declarations. C++ programmers can go a
step further by making all variables global.

20.
Bloated classes
To ensure your classes are bounded in the most obtuse way possible, make sure you include
peripheral, obscure methods and attributes in every class. For example, a class that defines
astrophysical orbit geometry really should have a method that computes ocean tide schedules
and attributes that comprise a Crane weather model. Not only does this over-define the class, it
makes finding these methods in the general system code like looking for a guitar pick in a landfill.

21.
Testing
I don't need to test my programs. I have an error-correcting modem.
Om I. Baud
Leaving bugs in your programs gives the maintenance programmer who comes along later something
interesting to do. A well done bug should leave absolutely no clue as to when it was introduced or
where. The laziest way to accomplish this is simply never to test your code.
Never Test
Never test any code that handles the error cases, machine crashes, or OS glitches. Never check
return codes from the OS. That code never gets executed anyway and slows down your test
times. Besides, how can you possibly test your code to handle disk errors, file read errors, OS
crashes, and all those sorts of events? Why, you would have to either an incredibly unreliable
computer or a test scaffold that mimicked such a thing. Modern hardware never fails, and who
wants to write code just for testing purposes? It isn't any fun. If users complain, just blame the
OS or hardware. They'll never know.

1.
Never, Ever Do Any Performance Testing
Hey, if it isn't fast enough, just tell the customer to buy a faster machine. If you did do
performance testing, you might find a bottleneck, which might lead to algorithm changes, which
might lead to a complete redesign of your product. Who wants that? Besides, performance
problems that crop up at the customer site mean a free trip for you to some exotic location. Just
keep your shots up-to-date and your passport handy.

2.
Never Write Any Test Cases
Never perform code coverage or path coverage testing. Automated testing is for wimps. Figure
out which features account for 90% of the uses of your routines, and allocate 90% of the tests to
those paths. After all, this technique probably tests only about 60% of your source code, and you
have just saved yourself 40% of the test effort. This can help you make up the schedule on the
back-end of the project. You'll be long gone by the time anyone notices that all those nice
"marketing features" don't work. The big, famous software companies test code this way; so
should you. And if for some reason, you are still around, see the next item.
3.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (12 of 19) [23/03/2005 05:47:00 p.m.]

Testing is for cowards


A brave coder will bypass that step. Too many programmers are afraid of their boss, afraid of
losing their job, afraid of customer hate mail and afraid of being sued. This fear paralyzes action,
and reduces productivity. Studies have shown that eliminating the test phase means that
managers can set ship dates well in advance, an obvious aid in the planning process. With fear
gone, innovation and experimentation can blossom. The role of the programmer is to produce
code, and debugging can be done by a cooperative effort on the part of the help desk and the
legacy maintenance group.
If we have full confidence in our coding ability, then testing will be unnecessary. If we look at this
logically, then any fool can recognize that testing does not even attempt to solve a technical
problem, rather, this is a problem of emotional confidence. A more efficient solution to this lack of
confidence issue is to eliminate testing completely and send our programmers to self-esteem
courses. After all, if we choose to do testing, then we have to test every program change, but we
only need to send the programmers to one course on building self-esteem. The cost benefit is as
amazing as it is obvious.

4.
Ensuring It Only Works In Debug Mode
If you've defined TESTING as 1

#define TESTING 1
this gives you the wonderful opportunity to have separate code sections, such as

#if TESTING==1
#endif
which can contain such indispensable tidbits as

x = rt_val;
so that if anyone resets TESTING to 0, the program won't work. And with the tiniest bit of
imaginative work, it will not only befuddle the logic, but confound the compiler as well.
5.
Choice Of Language
Philosophy is a battle against the bewitchment of our intelligence by means of language.
Ludwig Wittgenstein
Computer languages are gradually evolving to become more fool proof. Using state of the art languages
is unmanly. Insist on using the oldest language you can get away with, octal machine language if you
can (Like Hans und Frans, I am no girlie man; I am so virile I used to code by plugging gold tipped wires
into a plugboard of IBM unit record equipment (punch cards), or by poking holes in paper tape with a
hand punch), failing that assembler, failing that FORTRAN or COBOL, failing that C, and BASIC, failing
that C++.
FRTRAN
Write all your code in FORTRAN. If your boss ask why, you can reply that there are lots of very
useful libraries that you can use thus saving time. However the chances of writing maintainable
code in FORTRAN are zero, and therefore following the unmaintainable coding guidelines is a lot
easier.

1.
Avoid Ada
About 20% of these techniques can't be used in Ada. Refuse to use Ada. If your manager presses
you, insist that no-one else uses it, and point out that it doesn't work with your large suite of tools
like lint and plummer that work around C's failings.

2.
Use ASM 3.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (13 of 19) [23/03/2005 05:47:00 p.m.]
Convert all common utility functions into asm.

Use QBASIC
Leave all important library functions written in QBASIC, then just write an asm wrapper to handle
the large->medium memory model mapping.

4.
Inline Assembler
Sprinkle your code with bits of inline assembler just for fun. Almost no one understands
assembler anymore. Even a few lines of it can stop a maintenance programmer cold.

5.
MASM call C
If you have assembler modules which are called from C, try to call C back from the assembler as
often as possible, even if it's only for a trivial purpose and make sure you make full use of the
goto, bcc and other charming obfuscations of assembler.
6.
Dealing With Others
Hell is other people.
Jean-Paul Sartre -- No Exit 1934
There are many hints sprinkled thoroughout the tips above on how to rattle maintenance programmers
though frustration, and how to foil your boss's attempts to stop you from writing unmaintainable code,
or even how to foment an RWAR that involves everyone on the topic of how code should be formatted
in the repository.
Your Boss Knows Best
If your boss thinks that his or her 20 year old FORTRAN experience is an excellent guide to
contemporary programming, rigidly follow all his or her recommendations. As a result, the boss
will trust you. That may help you in your career. You will learn many new methods to obfuscate
program code.

1.
Subvert The Help Desk
One way to help ensure the code is full of bugs is to ensure the maintenance programmers never
hear about them. This requires subverting the help desk. Never answer the phone. Use an
automated voice that says "thank you for calling the helpline. To reach a real person press "1" or
leave a voice mail wait for the tone". Email help requests should be ignored other than to assign
them a tracking number. The standard response to any problem is " I think your account is locked
out. The person able to authorise reinstatement is not available just now."

2.
Keep Your Mouth Shut
Be never vigilant of the next Y2K. If you ever spot something that could sneak up on a fixed
deadline and destroy all life in the western hemisphere then do not openly discuss it until we are
under the critical 4 year till event window of panic and opportunity. Do not tell friends, coworkers,
or other competent people of your discovery. Under no circumstances attempt to publish
anything that might hint at this new and tremendously profitable threat. Do send one normal
priority, jargon encrypted, memo to upper management to cover-your-a$$. If at all possible attach
the jargon encrypted information as a rider on an otherwise unrelated plain-text memo pertaining
to a more immediately pressing business concern. Rest assured that we all see the threat too.
Sleep sound at night knowing that long after you've been forced into early retirement you will be
begged to come back at a logarithmically increased hourly rate!

3.
Baffle 'Em With Bullshit
Subtlety is a wonderful thing, although sometimes a sledge-hammer is more subtle than other
tools. So, a refinement on misleading comments: create classes with names like FooFactory
containing comments with references to the GoF creational patterns (ideally with http links to
bogus UML design documents) that have nothing to do with object creation. Play off the
maintainer's delusions of competence. More subtly, create Java classes with protected
4.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (14 of 19) [23/03/2005 05:47:00 p.m.]
constructors and methods like Foo f = Foo.newInstance()that return actual new instances, rather
than the expected singleton. The opportunities for side-effects are endless.

Book Of The Month Club


Join a computer book of the month club. Select authors who appear to be too busy writing books
to have had any time to actually write any code themselves. Browse the local bookstore for titles
with lots of cloud diagrams in them and no coding examples. Skim these books to learn obscure
pedantic words you can use to intimidate the whippersnappers that come after you. Your code
should impress. If people can't understand your vocabulary, they must assume that you are very
intelligent and that your algorithms are very deep. Avoid any sort of homely analogies in your
algorithm explanations.
5.
Tricks In Offbeat Languages
Programming in Basic causes brain damage.
Edsger Wybe Dijkstra
SQL Aliasing
Alias table names to one or two letters. Better still alias them to the names of other unrelated
existing tables.

G
SQL Outer Join
Mix the various flavours of outer join syntax just to keep everyone on their toes.

G
JavaScript Scope
"Optimise" JavaScript code taking advantage of the fact a function can access all local variables
in the scope of the caller.

G
Visual Basic Declarations
Instead of:

dim Count_num as string


dim Color_var as string
dim counter as integer
use:

Dim Count_num$, Color_var$, counter%

G
Visual Basic Madness
If reading from a text file, read 15 characters more than you need to then embed the actual text
string like so:

ReadChars = .ReadChars (29,0)


ReadChar = trim(left(mid(ReadChar,len(ReadChar)-15,len(ReadChar)-5),7))
If ReadChars = "alongsentancewithoutanyspaces"
Mid,14,24 = "withoutanys"
and left,5 = "without"

G
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (15 of 19) [23/03/2005 05:47:00 p.m.]
Miscellaneous Techniques
If you give someone a program, you will frustrate them for a day; if you teach them
how to program, you will frustrate them for a lifetime.
Anonymous

Don't Recompile
Let's start off with probably the most fiendish technique ever devised: Compile the code to
an executable. If it works, then just make one or two small little changes in the source
code...in each module. But don't bother recompiling these. You can do that later when you
have more time, and when there's time for debugging. When the hapless maintenance
programmer years later makes a change and the code no longer works, she will
erroneously assume it must be something she recently changed. You will send her off on a
wild goose chase that will keep her busy for weeks.

CANI
Constant And Never-ending Improvement. Make "improvements" to your code often, and
force users to upgrade often - after all, no one wants to be running an outdated version.
Just because they think they're happy with the program as it is, just think how much
happier they will be after you've "fixed" it! Don't tell anyone what the differences between
versions are unless you are forced to - after all, why tell someone about bugs in the old
version they might never have noticed otherwise?

1.
About Box
The About Box should contain only the name of the program, the names of the coders and
a copyright notice written in legalese. Ideally it should link to several megs of code that
produce an entertaining animated display. However, it should never contain a description
of what the program is for, its minor version number, or the date of the most recent code
revision, or the website where to get the updates, or the author's email address. This way
all the users will soon all be running on different versions, and will attempt to install
version N+2 before installing version N+1.

2.
Ch ch ch Changes
The more changes you can make between versions the better, you don't want users to
become bored with the same old API or user interface year after year. Finally, if you can
make this change without the users noticing, this is better still - it will keep them on their
toes, and keep them from becoming complacent.

3.
No Skill Required
You don't need great skill to write unmaintainable code. Just leap in and start coding. Keep
in mind that management still measures productivity in lines of code even if you have to
delete most of it later.

4.
Carry Only One Hammer
Stick with what you know and travel light; if you only carry a hammer then all problems are
nails.

5.
Standards Schmandards
Whenever possible ignore the coding standards currently in use by thousands of
developers in your project's target language and environment. For example insist on STL
style coding standards when writing an MFC based application.

6.
Third Party Libraries 7.
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (16 of 19) [23/03/2005 05:47:00 p.m.]
Include powerful third party libraries in your project and then don't use them. With practice
you can remain completely ignorant of good tools and add the unused tools to your resume
in your "Other Tools" section.

Avoid Libraries
Feign ignorance of libraries that are directly included with your development tool. If coding
in Visual C++ ignore the presence of MFC or the STL and code all character strings and
arrays by hand; this helps keep your pointer skills sharp and it automatically foils any
attempts to extend the code.

8.
Collect Coding Standards
Find all the tips you can on writing maintainable code such as these ones the Square Box
Suggestions and flagrantly violate them.

9.
Combine Bug Fixes With Upgrades
Never put out a "bug fix only" release. Be sure to combine bug fixes with database format
changes, complex user interface changes, and complete rewrites of the administration
interfaces. That way, it will be so hard to upgrade that people will get used to the bugs and
start calling them features. And the people that really want these "features" to work
differently will have an incentive to upgrade to the new versions. This will save you
maintenance work in the long run, and get you more revenue from your customers.

10.
Change File Formats With Each Release Of Your Product
Yeah, your customers will demand upwards compatibility, so go ahead and do that. But
make sure that there is no backwards compatibility. That will prevent customers from
backing out the newer release, and coupled with a sensible bug fix policy (see above), will
guarantee that once on a newer release, they will stay there. Extra bonus points: Figure out
how to get the old version to not even recognize files created by the newer versions. That
way, they not only can't read them, they will deny that they are even created by the same
application! Hint: PC word processors provide a useful example of this sophisticated
behaviour.

11.
Compensate For Bugs
Don't worry about finding the root cause of bugs in the code. Simply put in compensating
code in the higher-level routines. This is a great intellectual exercise, akin to 3D chess, and
will keep future code maintainers entertained for hours as they try to figure out whether the
problem is in the low-level routines that generate the data or in the high-level routines that
change various cases all around. This technique is great for compilers, which are
inherently multi-pass programs. You can completely avoid fixing problems in the early
passes by simply making the later passes more complicated. With luck, you will never have
to speak to the little snot who supposedly maintains the front-end of the compiler. Extra
bonus points: make sure the back-end breaks if the front-end ever generates the correct
data.

12.
It's The Size That Counts
It almost goes without saying that the larger a function is, the better it is. And the more
jumps and GOTOs the better. That way, any change must be analysed through many
scenarios. It snarls the maintenance programmer in the spaghettiness of it all. And if the
function is truly gargantuan, it becomes the Godzilla of the maintenance programmers,
stomping them mercilessly to the ground before they have an idea of what's happened.

13.
A Picture is a 1000 Words; A Function is 1000 Lines
Make the body of every method as long as possible - hopefully you never write any
methods or functions with fewer than a thousand lines of code, deeply nested, of course.
14.
Philosophy
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (17 of 19) [23/03/2005 05:47:00 p.m.]
The people who design languages are the people who write the compilers and system classes.
Quite naturally they design to make their work easy and mathematically elegant. However, there
are 10,000 maintenance programmers to every compiler writer. The grunt maintenance
programmers have absolutely no say in the design of languages. Yet the total amount of code
they write dwarfs the code in the compilers.
An example of the result of this sort of elitist thinking is the JDBC interface. It makes life easy for
the JDBC implementor, but a nightmare for the maintenance programmer. It is far clumsier than
the FORTRAN interface that came out with SQL three decades ago.
Maintenance programmers, if somebody ever consulted them, would demand ways to hide the
housekeeping details so they could see the forest for the trees. They would demand all sorts of
shortcuts so they would not have to type so much and so they could see more of the program at
once on the screen. They would complain loudly about the myriad petty time-wasting tasks the
compilers demand of them.
There are some efforts in this direction: NetRexx, Bali, and visual editors (e.g. IBM's Visual Age is
a start) that can collapse detail irrelevant to the current purpose.

The Shoemaker Has No Shoes


Imagine having an accountant as a client who insisted on maintaining his general ledgers using a
word processor. You would do you best to persuade him that his data should be structured. He
needs validation with cross field checks. You would persuade him he could do so much more
with that data when stored in a database, including controlled simultaneous update.
Imagine taking on a software developer as a client. He insists on maintaining all his data with a
text editor. He is not yet even exploiting the word processor's colour, type size or fonts.
Think of what might happen if we started storing source code as structured data. We could view
the same source code in many alternate ways, e.g. as Java, as NextRex, as a decision table, as a
flow chart, as a loop structure skeleton (with the detail stripped off), as Java with various levels of
detail or comments removed, as Java with highlights on the variables and method invocations of
current interest, or as Java with generated comments about argument names and/or types. We
could display complex arithmetic expressions in 2D, the way TeX and mathematicians do. You
could see code with additional or fewer parentheses, (depending on how comfortable you feel
with the precedence rules ). Parenthesis nests could use varying size and colour to help matching
by eye. With changes as transparent overlay sets that you can optionally remove or apply, you
could watch in real time as other programmers on your team, working in a different country,
modified code in classes that you were working on too.
You could use the full colour abilities of the modern screen to give subliminal clues, e.g. by
automatically assigning a portion of the spectrum to each package/class using a pastel shades as
the backgrounds to any references to methods or variables of that class. You could bold face the
definition of any identifier to make it stand out.
You could ask what methods/constructors will produce an object of type X? What methods will
accept an object of type X as a parameter? What variables are accessible in this point in the
code? By clicking on a method invocation or variable reference, you could see its definition,
helping sort out which version of a given method will actually be invoked. You could ask to
globally visit all references to a given method or variable, and tick them off once each was dealt
with. You could do quite a bit of code writing by point and click.
Some of these ideas would not pan out. But the best way to find out which would be valuable in
practice is to try them. Once we had the basic tool, we could experiment with hundreds of similar
ideas to make life easier for the maintenance programmer.

How To Write Unmaintainable Code


http://www.afralisp.com/vbaa/unmain.htm (18 of 19) [23/03/2005 05:47:00 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
How To Write Unmaintainable Code
http://www.afralisp.com/vbaa/unmain.htm (19 of 19) [23/03/2005 05:47:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Shadow Control
Would you like to place shadows on your controls?
Would you like to give your forms a 3D appearance?
The here we go......

'coding starts here


Option Explicit
Public Sub Shadow(f As Form, c As Control, clr As Long)
'This SubRoutine draws a shadow below and to the
'the right of a control. It's quite a simple example
'of drawing in form !
'Example : Shadow Me,Text1,vbBlack
Const shWidth = 3 'Width of the shadow
Dim oldWidth As Integer 'Save old DrawWidth
Dim oldScale As Integer 'Save old ScaleMode
f.AutoRedraw = True 'optional, but otherwise
'shadow won't remain when form is repainted
'or call from the Form_Paint() sub
oldWidth = f.DrawWidth 'Remember current DrawWidth
oldScale = f.ScaleMode 'Remember current ScaleMode
f.ScaleMode = 3 'Set to pixel scaling
f.DrawWidth = 1 '1 pixel width lines
'Draws the shadow by drawing a box behind the control
f.Line (c.Left + shWidth, c.Top + shWidth)- _
Step(c.Width - 1, c.Height - 1), clr, BF
f.DrawWidth = oldWidth 'Restore old DrawWidth
Shadow Control
http://www.afralisp.com/vba/shadow.htm (1 of 2) [23/03/2005 05:47:02 p.m.]
f.ScaleMode = oldScale 'Restore old ScaleMode
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Shadow Me, Label1, vbBlack
Shadow Me, Text1, vbBlack
Shadow Me, Command1, vbBlack
Shadow Me, Command2, vbBlack
End Sub
'coding ends here
Download source coding here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Shadow Control
http://www.afralisp.com/vba/shadow.htm (2 of 2) [23/03/2005 05:47:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Application Setup
You've written your AutoLisp and VBA routines, you've set up your Block Libraries and your Custom
Partial Menu is now complete. Everything has been tested but now you hit another snag. You'd like to
distribute your custom application to other drawing officers, or maybe you have 50 machines in your
office that you would like to install it on but you have one big problem. Having to set up each individual
machine is a real pain. There are directories to be created, support paths to be added, menu's to be
loaded, etc, etc. And if you are distributing it outside the office, you now have to try and put your setup
into words that can be clearly understood by the poor guy on the other end.
In this tutorial we are going to have a look at automating the whole process. We are going to make use
of two remarkable software applications that will make this a breeze, namely "Inno Setup" and "Acad
Install".
"Inno Setup" will be used to install our required support files, and "Acad Install" will do the job of
configuring AutoCAD for us, all with a lovely user interface.
Firstly though, we have a bit of forward planning to do before we start compiling our Custom
Application Setup.
Step 1
All your programs, menu's, etc. must be fully tested and free of errors. Test them on as many operating
systems and AutoCAD versions as possible to ensure they are bug free.
Step 2
Create a dedicated folder, with sub-folders for your application. The example we will be using here looks
like this :
This is a very simple directory structure with only three sub-folders. You can though, create as many as
you wish to suit your needs. Oh, before I forget, all your files need to be placed within these folders
AND, now this is important, if you want to install a partial menu, this MUST reside in the root folder. eg.
afralisp2004_install.
Step 3
Now we need to download some software. Pop along to both of these sites and download the latest
version of "Inno Setup" and "Acad Install".
Inno Setup
Jordan Russell's Software - http://www.jrsoftware.org
Acad Install
Custom Application Setup
http://www.afralisp.com/lisp/install1.htm (1 of 4) [23/03/2005 05:47:06 p.m.]
CADWERX - http://www.cadwerx.net/
Don't worry, they are both absolutely FREE.
Once you've download both applications install "Inno Setup" first.
Then install "Acad Install" to any directory of your choosing OTHER THAN your Application folder. Now,
from this directory, copy "ACADINST.EXE" and "ACADINST.INI" to the root folder of your Application
eg. afralisp2004_install. Do not copy "ACADINST.CHM" as we do not want to include this in our
compiled setup file.
In fact, now is maybe a good time to have a wee read of the "Inno Setup" and the "Acad Install" help
files to familiarise yourself with the software and give yourself a basic understanding of what we are
doing.
Step 4
As you have probably noticed when installing other software, during installation certain pages such as
a License notice or a ReadMe notice appear. Well now we need to create 3 files to go along with our
installation application - A License Notice, a Warning Notice and a Config Notice. You can use plain old
Notepad for this task, saving them as straight forward TXT files. This is what our example files look like.
License Notice :
AfraLisp AutoCAD 2004 Custom Menu
==================================
Except where otherwise noted, all of the documentation
and software included in the AfraLisp AutoCAD 2004 Custom
Menu package is copyrighted by AfraLisp.
Copyright (C) 2003 AfraLisp. All rights reserved.
Be it hereby known that all the functions, programs and
applications contained in this here menu system, together
with but not excluding all those other parts and utterances
thereunto, shall not be warranted against all defects,
failures and malfunctions as shall occur between now and
Thursday afternoon shortly before 2:00 am, during which
time AfraLisp will maybe, at no charge to you or the other
person who complained before you, send the culprit application
to our Programmers, who will emerge from their caves and engage
in rituals designed to cleanse the menu system of evil spirits.
This warranty does not cover attractive blonde females (not male)
who may happen to use this menu system or whatever you would like
to call it.
Please respect the intellectual rights of others, or we will hunt
you down and do nasty things to you!!!
=========================
AfraLisp
afralisp@mweb.com.na
http://www.afralisp.com
=========================
Warning Notice :
Custom Application Setup
http://www.afralisp.com/lisp/install1.htm (2 of 4) [23/03/2005 05:47:06 p.m.]
WARNING!
==========
Please close all Windows applications, ESPECIALLY any Autodesk
software applications (AUTOCAD, MECHANICAL DESKTOP, etc.)
before proceeding with installation.
---------------
If you have these applications open during the installation
process, the software will not install or function properly.
And our Config Notice :
AfraLisp AutoCAD 2004 Custom Menu
==================================
AutoCAD has automatically been configured for the AfraLisp
2004 Custom Menu. The installer has performed the following
configuration tasks :
1) Added the required folders to your AutoCAD Support Path.
2) Added the AfraLisp AutoCAD 2004 Custom Menu to your menu bar,
and installed any applicable Toolbars.
3) Created a new AfraLisp Profile and made it current.
4) Created an icon on your desktop which will start AutoCAD
with the appropriate profile.
Okay, that seems to be everything ready. Let's just have a quick look at what our root folder looks like
and the files therein :
Notice my Afralisp.mnu, AfraLisp.dll and AcadDoc.lsp are within this folder!!
Okay, now let's create our Setup Script. See you on the next page........
Page I Page II Page III Page IV Page V

Custom Application Setup


http://www.afralisp.com/lisp/install1.htm (3 of 4) [23/03/2005 05:47:06 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Application Setup
http://www.afralisp.com/lisp/install1.htm (4 of 4) [23/03/2005 05:47:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Application Setup II
Welcome back everyone. So are you ready to create your Setup Script?
You are!! Okay fire up "Inno Setup". This dialog should appear :
For the sake of simplicity, and 'cos it's less work, select the "Create a new script file using the Script
Wizard" option button and then select "OK".
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (1 of 6) [23/03/2005 05:47:22 p.m.]
The Wizard will then appear. Say hello, ask how Harry Potter is and then select "Next".
Fill in each edit box replacing the contents with your own details if you so wish.
Select "Next".
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (2 of 6) [23/03/2005 05:47:22 p.m.]
We would like our Application to be installed in the Program Files directory and we are happy with the
Application Directory name. You can uncheck the "Allow user to change the application directory" if
you wish. Click on "Next" again.
Okay, this is the important part. Firstly you need to select AcadInst.exe as the "Application main
executable file". This is the file that will run after the installation is complete. You then need to select
ALL files AND directories that you want to include within the installation. DO NOT forget the AcadInst.ini
file.
Once finished with your selections, press "Next".
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (3 of 6) [23/03/2005 05:47:22 p.m.]
Now we need to set up our icons. We would like to "Create an Internet shortcut in the Start Menu
folder", and we would like to "Create an Uninstall icon in the Start Menu folder". We DO NOT want to
"Allow user to create a desktop icon". "Acad Install" will take care of that for us. Select "Next" yet again.
This is where we include our License, Warning and Config text files.
Yep, you've guessed, press "Next" again.
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (4 of 6) [23/03/2005 05:47:22 p.m.]
Right, that's us about done. Now just for a change, select the "Finish" button.
No, we do not want to compile our script as of yet as we have a few tweeks to take care of. Select "No".
Looks nice hey. Have a look at these lines under the [Files] section :
Source: "C:\afralisp2004_Install\Lib2004\*.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lisp2004\*.*"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Templates\*.*"; DestDir: "{app}"; Flags: ignoreversion
For some inexplicable reason, the Wizard does not add the sub-folder paths to the DestDir (Destination
Directory). This means that we need to add them by hand. This is what needs to be added to your script.
Source: "C:\afralisp2004_Install\Lib2004\*.*"; DestDir: "{app}\Lib2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lisp2004\*.*"; DestDir: "{app}\Lisp2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Templates\*.*"; DestDir: "{app}\Templates"; Flags: ignoreversion
As we do not want "Acad Install" to run at this time, you now need to comment out the following
section. You comment it out by placing a semi-colon ( ; ) at the beginning of the line.
;[Run]
;Filename: "{app}\AcadInst.exe"; Description: "Launch AfraLisp 2004 Custom Menu"; Flags: nowait postinstall
skipifsilent
Your script will look something like this. (I've added the comments by the way).
Now save your script as "AfraLisp.iss" into the root folder of your application.
Okey Doke, it's now time to test our script. Let's do that on the next page.
Exciting hey??
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (5 of 6) [23/03/2005 05:47:22 p.m.]
Page I Page II Page III Page IV Page V

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Application Setup II
http://www.afralisp.com/lisp/install2.htm (6 of 6) [23/03/2005 05:47:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
AppName=AfraLisp 2004 Custom Menu
;the name of the application
AppVerName=AfraLisp 2004 Custom Menu Version 1.5
;the version of the application
AppPublisher=AfraLisp
;the publisher
AppPublisherURL=http://www.afralisp.com
;the publishes web address
AppSupportURL=http://www.afralisp.com
;the publishes support address
AppUpdatesURL=http://www.afralisp.com
;the publishes update address
DefaultDirName={pf}\AfraLisp 2004 Custom Menu
;the default installation folder
;(pf) denotes "Program Files"
DefaultGroupName=AfraLisp 2004 Custom Menu
;the group name
DisableProgramGroupPage=yes
;we do not want a group page
LicenseFile=C:\afralisp2004_Install\license.txt
;path to the License file
InfoBeforeFile=C:\afralisp2004_Install\warning.txt
;path to the Warning file
InfoAfterFile=C:\afralisp2004_Install\config.txt
;path to the Config file
[Files]
;Path to source files/folders and Destination folders.
;(app) denotes The application directory, which the user
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno.htm (1 of 3) [23/03/2005 05:47:23 p.m.]
;selects on the Select Destination Directory.
Source: "C:\afralisp2004_Install\AcadInst.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AcadInst.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\acaddoc.lsp"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AfraLisp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AfraLisp.mnu"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lib2004\*.*"; DestDir: "{app}\Lib2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lisp2004\*.*"; DestDir: "{app}\Lisp2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Templates\*.*"; DestDir: "{app}\Templates"; Flags: ignoreversion
[INI]
Filename: "{app}\AcadInst.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.afralisp.com"
[Icons]
;shortcut icons
Name: "{group}\AfraLisp 2004 Custom Menu"; Filename: "{app}\AcadInst.exe"
Name: "{group}\AfraLisp 2004 Custom Menu on the Web"; Filename: "{app}\AcadInst.url"
Name: "{group}\Uninstall AfraLisp 2004 Custom Menu"; Filename: "{uninstallexe}"
;[Run]
; NOTE: The following entry contains an English phrase ("Launch"). You are free to translate it into another
language if required.
;Filename: "{app}\AcadInst.exe"; Description: "Launch AfraLisp 2004 Custom Menu"; Flags: nowait postinstall
skipifsilent
[UninstallDelete]
;delete these files on uninstall
Type: files; Name: "{app}\AcadInst.url"
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno.htm (2 of 3) [23/03/2005 05:47:23 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno.htm (3 of 3) [23/03/2005 05:47:23 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Application Setup III
To test our set up script, we first need to compile the script. Re-open "AfraLisp.iss" and choose "File" "Compile"
from the pull down menu. Bells will ring and buzzes will buzz and at the end of it your script will be compiled. Have
a look at your application folder structure now :
You should have a new sub-folder entitled "Output". Within this folder you will find a file named "Setup.exe".
Double click on it. This should appear :
After you've had a wee read click on "Next".
Custom Application Setup III
http://www.afralisp.com/lisp/install3.htm (1 of 6) [23/03/2005 05:47:37 p.m.]
Ha, ha!! Our License!! Select "I accept the agreement" and then "Next".
And next our "Warning". Select "Next" again.
Custom Application Setup III
http://www.afralisp.com/lisp/install3.htm (2 of 6) [23/03/2005 05:47:37 p.m.]
Just default through this unless you really want to change the Destination Directory.
Select "Next" again. Phew!!
Happy with everything? Select "Install".
A progress bar will appear as your files are installed. Once complete, this will appear :
Custom Application Setup III
http://www.afralisp.com/lisp/install3.htm (3 of 6) [23/03/2005 05:47:37 p.m.]
Just some instructions to let the user know what has happened in regards to the AutoCAD configuration. Nothing
has happened though, because we disabled the "Acad Install" section of the script. Click on the "Next" button.
Select the "Finish" button to complete the installation.
Let's pop along to "Program Files" and see what we can find.
Custom Application Setup III
http://www.afralisp.com/lisp/install3.htm (4 of 6) [23/03/2005 05:47:37 p.m.]
Hey, all our Folders, sub-folders and files have been installed.
This is magic!!!
Now look under "Start" "Programs" for "AfraLisp 2004 Custom Menu".
Select "Uninstall AfraLisp 2004 Custom Menu".
Before we go any further, we need to tweek our setup script just a wee bit more to integrate with "Acad Install".
Under the [Run] section of AfraLisp.iss you will find this line :
;[Run]
;the program to run
;Filename: "{app}\AcadInst.exe"; Description: "Launch AfraLisp 2004 Custom Menu"; Flags: nowait postinstall
skipifsilent
Remove the semi-colons from the beginning of the lines and make these changes :
Filename: "{app}\AcadInst.exe"; Description: "Configure AutoCAD"; Parameters: {app}; Flags: waituntilidle
Now add this to the bottom of the script :
[UninstallRun]
;run this program on uninstall
Filename: "{app}\AcadInst.exe"; Parameters: -U
Your script file should now look like this.
Okay, that's our script file complete. Now save it.
We now need to configure "Acad Install" to integrate with our setup application.
This we will do on the next page.
Page I Page II Page III Page IV Page V

Custom Application Setup III


http://www.afralisp.com/lisp/install3.htm (5 of 6) [23/03/2005 05:47:37 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Application Setup III
http://www.afralisp.com/lisp/install3.htm (6 of 6) [23/03/2005 05:47:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
AppName=AfraLisp 2004 Custom Menu
;the name of the application
AppVerName=AfraLisp 2004 Custom Menu Version 1.5
;the version of the application
AppPublisher=AfraLisp
;the publisher
AppPublisherURL=http://www.afralisp.com
;the publishes web address
AppSupportURL=http://www.afralisp.com
;the publishes support address
AppUpdatesURL=http://www.afralisp.com
;the publishes update address
DefaultDirName={pf}\AfraLisp 2004 Custom Menu
;the default installation folder
;(pf) denotes "Program Files"
DefaultGroupName=AfraLisp 2004 Custom Menu
;the group name
DisableProgramGroupPage=yes
;we do not want a group page
LicenseFile=C:\afralisp2004_Install\license.txt
;path to the License file
InfoBeforeFile=C:\afralisp2004_Install\warning.txt
;path to the Warning file
InfoAfterFile=C:\afralisp2004_Install\config.txt
;path to the Config file
[Files]
;Path to source files/folders and Destination folders.
;(app) denotes The application directory, which the user
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno2.htm (1 of 3) [23/03/2005 05:47:38 p.m.]
;selects on the Select Destination Directory.
Source: "C:\afralisp2004_Install\AcadInst.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AcadInst.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\acaddoc.lsp"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AfraLisp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\AfraLisp.mnu"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lib2004\*.*"; DestDir: "{app}\Lib2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Lisp2004\*.*"; DestDir: "{app}\Lisp2004"; Flags: ignoreversion
Source: "C:\afralisp2004_Install\Templates\*.*"; DestDir: "{app}\Templates"; Flags: ignoreversion
[INI]
Filename: "{app}\AcadInst.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.afralisp.com"
[Icons]
;shortcut icons
Name: "{group}\AfraLisp 2004 Custom Menu"; Filename: "{app}\AcadInst.exe"
Name: "{group}\AfraLisp 2004 Custom Menu on the Web"; Filename: "{app}\AcadInst.url"
Name: "{group}\Uninstall AfraLisp 2004 Custom Menu"; Filename: "{uninstallexe}"
[Run]
the program to run after install
Filename: "{app}\AcadInst.exe"; Description: "Configure AutoCAD"; Parameters: {app}; Flags: waituntilidle
[UninstallDelete]
;delete these files on uninstall
Type: files; Name: "{app}\AcadInst.url"
[UninstallRun]
;run this program on uninstall
Filename: "{app}\AcadInst.exe"; Parameters: -U
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno2.htm (2 of 3) [23/03/2005 05:47:38 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Inno Setup Script
http://www.afralisp.com/lisp/install2-inno2.htm (3 of 3) [23/03/2005 05:47:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Application Setup IV
Let's review what we've done so far.
We've set up our folders and sub-folders for our custom application. G
We've used the "Inno Setup" Wizard to create our setup script. G
We've tweeked the setup script to integrate with "Acad Install". G
Now we need to configure our "AcadInst.ini" file. G
Lets have a look at the "AcadInst.ini" file which should be in your application root folder :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Usage Notes: ;
; See AcadInst.chm help file for instructions on sections and values ;
[PRODUCT]
Name=MyAcadApp
RegPath=MyCompany\MyAcadApp\MyAppVersion
License=
Silent=
[AUTOCAD]
Versions=R15.0,R16.0
Products=
SerialNumbers=
AddPath=|1
Silent=
[AUTOCAD LT]
Versions=R2000
Products=
SerialNumbers=
AddPath=
Silent=
[ARX]
Install=CdWxMyAppArx
Uninstall=
Description=My app's arx description
LoadCtrls=13
Loader=MyAppArx
Groups=GROUP1:GROUP1
Commands=COMMAND1:COMMAND1,COMMAND2:COMMAND2
[ARX2]
Custom Application Setup IV
http://www.afralisp.com/lisp/install4.htm (1 of 4) [23/03/2005 05:47:38 p.m.]
Install=CdWxMyAppArx2
Uninstall=
Description=My app's other arx description
LoadCtrls=13
Loader=MyAppArx2
Groups=GROUP1:GROUP1
Commands=COMMAND3:COMMAND3,COMMAND4:COMMAND4
[MENU]
MenuGroups=MyMainMenu:MyMenuFile:1:3,MyOtherMenu:MyMenuFile
Toolbars=MyMainMenu.TB_MAIN
[APPLOAD]
StartupSuite=\MyAppVlx.vlx
History=\MyAppVlx.vlx
[ACADDOC]
Line1=(alert "Pie is good!")
Line2=(princ "\nThe path to my app is ")
[STARTAPP]
[NEWPROFILE]
Name=MyProfile
Description=My profile for my AutoCAD application.
CopyFrom=
MakeDefault=T
DesktopShortcut=T
QuickLaunchButton=T
[General]
;Blipmode=1
;TemplatePath=\Templates
First, let's strip out what we won't need or will not be using. Your AcadInst.ini file should now look like
this :
[PRODUCT]
Name=MyAcadApp
RegPath=MyCompany\MyAcadApp\MyAppVersion
[AUTOCAD]
Versions=R15.0,R16.0
AddPath=|1
[MENU]
MenuGroups=MyMainMenu:MyMenuFile:1:3,MyOtherMenu:MyMenuFile
Toolbars=MyMainMenu.TB_MAIN
[NEWPROFILE]
Name=MyProfile
Custom Application Setup IV
http://www.afralisp.com/lisp/install4.htm (2 of 4) [23/03/2005 05:47:38 p.m.]
Description=My profile for my AutoCAD application.
CopyFrom=
MakeDefault=T
DesktopShortcut=T
QuickLaunchButton=T
[General]
TemplatePath=\Templates
Now make these changes as shown in red. I've added comments to each change to explain what is going
on :
[PRODUCT]
Name=AfraLisp2004 Custom Menu
;the name of our application.
[AUTOCAD]
Versions=R15.0,R16.0
;the AutoCAD version/s to be configured
AddPath=<InstallPath>|1;<InstallPath>\Lib2004|2;<InstallPath>\Lisp2004|3
;the support paths to be added and their positions
[MENU]
MenuGroups=AFRALISP:AFRALISP:1:50
;the pull down menu to be added
Toolbars=AFRALISP.LAYMAN
;the toolbar to be added
[NEWPROFILE]
Name=AfraLisp
;the name of the profile to be added
Description=AfraLisp 2004 Menu Profile.
;the description of the profile
CopyFrom=<CURRENT>
;copy the profile from the current profile
MakeDefault=T
;make it the default profile;make it the default profile
DesktopShortcut=T
;yes we want a desktop shortcut
ShortcutName=AfraLisp Profile
;name of the shortcut
ShortcutComment=AfraLisp Custom Menu Profile
;the tooltip
ShortcutArgs=/p "AfraLisp"
;the arguments on startup
ShortcutWorkingDir=C:\drawings
;the working directory
[<PROFILE>General]
TemplatePath=<STRING><InstallPath>\Templates
;the template file path
Custom Application Setup IV
http://www.afralisp.com/lisp/install4.htm (3 of 4) [23/03/2005 05:47:38 p.m.]
Let's have a look at our setup application in action. See you on the next page.
Page I Page II Page III Page IV Page V

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Application Setup IV
http://www.afralisp.com/lisp/install4.htm (4 of 4) [23/03/2005 05:47:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Application Setup V
To try out our full installation, we first need to re-compile our "setup.exe".
Re-open your "Acadlisp.iss" file and again choose "Files" - "Compile".
Again, open the "Output" folder and double click "setup.exe".
The installation will proceed as before until you reach this point and this dialog appears :
Select the profile that you would like to install your custom installation to, and then select "Okay" The
Config page and the "Finish" page will then appear.
That's it, your custom installation is complete. Let's check. First have a look on your desktop. You
should have a new shortcut icon entitled "AfraLisp Profile".
Right click on the icon and choose "Properties".
Custom Application Setup V
http://www.afralisp.com/lisp/install5.htm (1 of 4) [23/03/2005 05:47:45 p.m.]
Note that the arguments for the "Target:" have been inserted and the "Start in:" directory has been
configured.
Now open AutoCAD using your new icon.
A new toolbar should appear that looks like this :
Now choose "Tools" - "Options" from the pull down menu and select the "Files" tab:
Our new support file path has been inserted.
Let's check the "Template File" path :
Custom Application Setup V
http://www.afralisp.com/lisp/install5.htm (2 of 4) [23/03/2005 05:47:45 p.m.]
Yep, it's there. Let's have a look at our Profiles.
Select the "Profiles" tab :
Hey, a new profile all to myself!!
Close the Options dialog and have a look at your menu bar.
You should have a new pull down menu named "AfraLisp Menu".
Well that's it. Mission accomplished.
Of course, this is in no ways a full explanation of what "Inno Tools" or "Acad Install" are capable of.
They are both full of functions and capabilities that I haven't even touched on in this tutorial. Read the
help files, play around with them, have a wee bit of fun.
(Have a look here if you would like a more detailed look at "Acad Install".)
Sorry, coming soon!!
If you would like to download the all installation files for this tutorial, please feel free to click here.
Although "ACAD Install" was primarily written to work in conjunction with "Inno Setup" it can also be
used as a stand alone application. I find it particularly useful for configuring AutoCAD for a Network
environment.
In a Network environment there is no need for a full blown installation application, as all of the support
files, menu's, lisp files, etc. are already on the Network and are shared by each user. All we really
require is a method of configuring AutoCAD to suit our Network paths. This is where "Acad Install"
comes into play.
Read more about "Standing Alone with Acad Install".
Page I Page II Page III Page IV Page V

Custom Application Setup V


http://www.afralisp.com/lisp/install5.htm (3 of 4) [23/03/2005 05:47:45 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Application Setup V
http://www.afralisp.com/lisp/install5.htm (4 of 4) [23/03/2005 05:47:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD Command Line Switches
What are Command Line Switches Kenny?
Command Line Switches are parameters that you add to the acad.exe command line which enable
AutoCAD to perform additional operations when it starts. For example, AutoCAD can start with an
alternative configuration, run a script, load a template drawing and even open a drawing with a saved
view.
Personally, I feel that Command Line Switches are often neglected by the AutoCAD programmer/system
manager. Why? I don't know as they can drastically cut down on setting up workstations and help a hell
of a lot in enforcing drawing office standards.
Before we have a look at the Command Line Switches, let's have a look at how AutoCAD deals with
them :
If you use a Command Line Switch to specify an environment setting, the Command Line Switch
overrides the settings specified in either the Options dialog box or the environment value.
G
If a Command Line Switch is not set, the corresponding value set in the Options dialog box is
used.
G
If neither a Command Line Switch nor an Options value is set, the environment variable value is
used
G
Note : Command Line Switches and environment variables override Options values for the current
session only. They do not alter the system registry.
Okay dokey, now let's have a look at how we go about changing a Command Line Switch :
Make a backup copy of your AutoCAD 2002 icon. Right-click on the icon and then Copy and Paste it to a safe
location.
G
Again, Right-Click on the AutoCAD 2002 icon on your Desktop. G
Choose Properties G
In the AutoCAD 2002 Properties dialog, select the Shortcut tab. G
This is what it should look like :
AutoCAD Command Line Switches
http://www.afralisp.com/lisp/Switches.htm (1 of 3) [23/03/2005 05:47:48 p.m.]
The section that we are interested in is the "Target" edit box, which in this example contains "C:\AutoCAD
2002\acad.exe"
A word of warning though, when making changes to the Target box, make sure you don't accidentally remove any
section of the application path or filename itself, Make sure that there is a single space after the path and file
argument and before you switch. Also, ensure there is a space between each argument and your switch statements.
If your path or file names have spaces in them, you will have to surround the path or name with double quotes. In
fact, to be on the safe side, I surround all my paths and file names with double quotes.
Right, let's have a look at the switches :
Switch Syntax and Example Description
/b
path ["drawing file"] /b "script"
"C:\AutoCAD 2002\acad.exe" /b "C:\scripts\MyScript"
Open a drawing and runs a
Script. Drawing name is
optional.
/c
path /c "Configuration File"
"C:\AutoCAD 2002\acad.exe" /c "C:\myconfigs\MyConfig"
Specifies the hardware
configuration file to use.
/nologo
path /nologo
"C:\AutoCAD 2002\acad.exe" /nologo
Starts AutoCAD without the
splash screen.
/p
path /b profile
"C:\AutoCAD 2002\acad.exe" /p "C:\profiles\MyProfile"
Starts AutoCAD with the
specified Profile name. If the
Profile does not exist,
AutoCAD uses the current
Profile.
/r
path /r
"C:\AutoCAD 2002\acad.exe" /r
Resets all AutoCAD default
settings, printers and system
pointing device.
/s
path /s "Support Paths"
"C:\AutoCAD 2002\acad.exe" /s "C:\Blocks;C:\Lisp;C:\VBA"
Designates additional Support
Paths.
AutoCAD Command Line Switches
http://www.afralisp.com/lisp/Switches.htm (2 of 3) [23/03/2005 05:47:48 p.m.]
/t
path ["drawing file"] /t "Template File"
"C:\AutoCAD 2002\acad.exe" /t "C:\MyTemplates\MyTemplate"
Creates a new drawing based
on a Template or Prototype
drawing. Drawing name is
optional.
/v
path ["drawing file"] /v "View Name"
"C:\AutoCAD 2002\acad.exe" "MyDrawing" /v "MyView"
Opens a drawing with a
predefined view.
You can of course string the Command Line Switches together. For example, to open AutoCAD with no
splash screen using a user defined profile and template drawing, you would use the following syntax :
"C:\AutoCAD 2002\acad.exe" /nologo /p "C:\profiles\MyProfile" /t "C:\MyTemplates\MyTemplate"
Would you like AutoCAD to open in a specific directory every time?
You would? Good!!!
Then just place your directory path in the "Start In" edit box. Easy hey?

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD Command Line Switches
http://www.afralisp.com/lisp/Switches.htm (3 of 3) [23/03/2005 05:47:48 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Standing Alone with Acad Install
Although "ACAD Install" was primarily written to work in conjunction with "Inno Setup" - see "Custom
Application Setups" - it can also be used as a stand alone application. I find it particularly useful for
configuring AutoCAD for a Network environment.
In a Network environment there is no need for a full blown installation application, as all of the support files,
menu's, lisp files, etc. are already on the Network and are shared by each user. All we really require is a
method of configuring AutoCAD to suit our Network paths. This is where "Acad Install" comes into play. So,
let's have a look at setting up "Acad Install" to configure AutoCAD.
This is what our Network directory structure looks like :
Pretty straight forward hey? "Network_Install" is the directory folder containing all our support folders and
files. You must remember that "AcadInst.exe" and "AcadInst.ini" must reside in the root folder of your
Network directory structure. The files in this folder will look something like this :
As you can see from the file listing above, "AcadInst"can now be renamed so that multiple installers can
coexist in same directory. The .ini file name should match .exe name
(AcadInst_1.exe/AcadInst_1.ini/AcadInst_2.exe/AcadInst_2.ini,...)
Any partial Menu must also reside in this folder as I haven't yet discovered a way to refer to a menu residing
in a sub-folder.
Okay, time to have a look at the "AcadIns.ini" file :
[PRODUCT]
Name=AfraLisp 2004 Custom Menu
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (1 of 7) [23/03/2005 05:47:59 p.m.]
;This is the applications name. This value is required and AcadInst.exe
; will display an error message if it is not included.
[AUTOCAD]
Versions=R16.0
;Comma-delimited string representing the versions of AutoCAD
; for which the application can/will* be installed.
;Valid strings are any key found under
;HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD in the registry.
;When left empty all profiles that match the other criteria are included.
;To avoid all versions enter NONE.
;Examples for AutoCAD are R14.0 for R14, R15.0 for 2000,
;2000i, & 2002, and R16.0 for 2004
;Examples for LT are R5.0 for LT98, R2000 for LT 2000,
;R7 for LT 2000i, and R8 for LT2002
AddPath=< InstallPath >\Admin|1;< InstallPath >\Lib2004|2;
< InstallPath >\Lisp2004|3;< InstallPath >\Sym2004|4
;Semi-colon delimited list of PATH|POSITION to add to the
;AutoCAD search path. To insert the path at the beginning use a
;POSITION of 1. If the POSITION is not specified, the path will be
;appended to the end.
;If the path is already part of the search path it will not be added again.
;You can use < InstallPath > to indicate the path the user installed to.
;Using this you can also add paths relative to the path where the user
;installed, for example
;< InstallPath >\Symbols:2 would add a sub-folder of the installed path
;named Symbols as the second entry ;in the support paths list.
[MENU]
MenuGroups=AFRALISP:AFRALISP:1:50
;Comma-delimited string of MENUGROUP:MENUFILE:POP:POSITION
;(without extensions) to be added to the Menu key for the profiles.
;The registry is searched and the first available Group number is used.
;If POSITION ;is greater than the number of installed pop menus,
;then it will be added to the end. To insert at the beginning
;use 1. To insert at the end use some large number like 50.
;If the POP and POSITION numbers are not included
;then no drop-down menu is installed for that menu.
;Example:
;MenuGroups=MyMainMenu:MyMenuFile:1:3,MyOtherMenu:MyMenuFile

;will setup MyMainMenu and MyOtherMenu from MyMenuFile to be
;loaded when AutoCAD starts up.
;POP1 menu from MyMainMenu will be placed as the third AutoCAD
;menu and MyOtherMenu will not be ;placed as a POP menu.
Toolbars=AFRALISP.LAYMAN
;Comma-delimited string of MENUGROUP.TOOLBAR pairs to be
;added to the AutoCAD GUI. If the user has previously closed one
;of the toolbars it will be forced to show itself again after
;running installer.
[APPLOAD]
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (2 of 7) [23/03/2005 05:47:59 p.m.]
StartupSuite=< InstallPath >\Lisp2004\doslib2004.arx,
< InstallPath >\Lisp2004\cerror.vlx
;A comma-delimited string of files (with ext) to be added to
;AutoCAD's Startup Suite.
;Only valid for post-R14, non-LT installations.
History=< InstallPath >\Lisp2004\doslib2004.arx,
< InstallPath >\Lisp2004\cerror.vlx
;A comma-delimited string of files (with ext) to be added to
;the Appload dialog's History list.
;Only valid for post-R14, non-LT installations.
;For both of these keys you must use < InstallPath > to insert the user
;specified path when appropriate.
;See the AddPath= key for more information.
[NEWPROFILE]
Name=AfraLisp
;Name for the new profile. If it already exists,
;the rest of the keys are skipped.
;A profile will be created for all AutoCAD apps specified in the
;[AUTOCAD] and [AUTOCAD LT] sections.
Description=AfraLisp 2004 Menu Profile.
;Description of New Profile
CopyFrom=< CURRENT >
;Copy from the current profile to retain existing configurations
MakeDefault=T
;Make it the default Profile
DesktopShortcut=T
;Add a shortcut to the desktop
ShortcutName=AfraLisp 2004 Menu Profile
;Shortcut Name
ShortcutComment=AfraLisp 2004 Menu Profile
;Tooltip
ShortcutArgs=/p "AfraLisp"
;the arguments on startup
ShortcutWorkingDir=< InstallPath >\Admin
;the working directory
[<PROFILE>General]
TemplatePath=< STRING >< InstallPath >\Tplts
;Template File Path
Do you notice how we make use of <InstallPath> to indicate the path the user installed to. Using this you can
also add paths relative to the path where the user installed, for example <InstallPath>\Symbols|2 would add a
sub-folder of the installed path named Symbols as the second entry in the support paths list.
Right, that's everything set up and ready. Double click on "AcadInst-admin.ini" and see what happens :
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (3 of 7) [23/03/2005 05:47:59 p.m.]
Would we like to install our custom menu. Of course we would!! Press "Yes."
Now it's asking us what Profile would we like to base our new Profile on, and which of our Installed AutoCAD
versions would we like to install too. Pick a Profile, any will do and then select "OK."
Mmmm, nothing really seemed to happen??
Don't worry, plenty did it's just that it all happened so fast.
Have a look at your desktop :
Ha, ha, we have a new desktop icon. Right-click on the icon and select "Properties" and then the "Shortcut"
tab :
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (4 of 7) [23/03/2005 05:47:59 p.m.]
Mmm, interesting!! Our "Target" arguments have been set, and our "Start In" directory has been configured.
Okay, now fire up AutoCAD.
A new Toolbar should appear looking like this :
This is getting more and more interesting. Now choose "Tools" - "Options" -"Files" and have a look at your
support path :
Good, our Support Paths have been added.
And the Template File Path? Well let's have a look:
Yep, there it is. Now choose the "Profiles" tab :
Yippee, it's there. Now where has our menu gone? Check out your menu bar :
Great, our pull down menu has also been loaded.
But didn't we ask for some files to be loaded in the Startup Suite? Let's have a wee look :
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (5 of 7) [23/03/2005 05:47:59 p.m.]
Yep, there are bet are they in our History List ?
Okay, that's our installation complete, but what happens when we want to uninstall?
To uninstall you can run it from the command line (Start->Run) passing -U as the single parameter :
Or you can do something like the following in a .bat file to uninstall :
ECHO OFF
CLS
ECHO Uninstalling from AutoCAD
PAUSE
AcadInst.exe -U
ECHO Files Uninstalled!
PAUSE
If you would like to download all the files involved in this tutorial then please feel free to click on this spot
here.

Standing Alone with Acad-Install


http://www.afralisp.com/lisp/acadinst1.htm (6 of 7) [23/03/2005 05:47:59 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Standing Alone with Acad-Install
http://www.afralisp.com/lisp/acadinst1.htm (7 of 7) [23/03/2005 05:47:59 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp's Tips 'n Tricks II
Page I Page III
Onsnap Menu
Here is a little trick that I did to my osnap cursor menu.I come across a lot of users who are not aware of this
function, 'Cal - Mee.
I used to use a 12 button puck & tablet and had this programmed on button #4. Now, in the modern world of the
InteliMouse, I have given up my beloved tablet, so here is what I have done to my AutoCad menu.
[&Object Snap Cursor Menu]
ID_Tracking [Temporary trac&k point]_tt
ID_From [&From]_from
ID_MnPointFi [->Poin&t Filters]
ID_PointFilx [.X].X
ID_PointFily [.Y].Y
ID_PointFilz [.Z].Z
[--]
ID_PointFixy [.XY].XY
ID_PointFixz [.XZ].XZ
ID_PointFiyz [<-.YZ].YZ
[--]
ID_OsnapEndp [&Endpoint]_endp
ID_OsnapMidp [&Midpoint]_mid
ID_OsnapInte [&Intersection]_int
ID_OsnapAppa [&Apparent Intersect]_appint
ID_OsnapExte [E&xtension]_ext
[--]
ID_OsnapCent [&Center]_cen
ID_OsnapQuad [&Quadrant]_qua
ID_OsnapTang [Tan&gent]_tan
[--]
ID_OsnapPerp [&Perpendicular]_per
ID_OsnapPara [Para&llel]_par
ID_OsnapNode [No&de]_nod
ID_OsnapInse [In&sert]_ins
ID_OsnapNear [Nea&rest]_nea
ID_OsnapNone [&None]_non
[--]
ID_Osnap [&Osnap Settings...]'_+dsettings 2
[--]
[Cal-Mee Expression]'cal;mee;
John Lauer
Command Line Problem
Q. Every time I open AutoCad Im down to one line of text in the command line. My profile specifies 4
lines. When I open Options/display 4 lines is specified. I can change the display to 4 lines, or whatever,
by stretching it with the mouse, but when I close AutoCad and open up again its back to one stingy
line.
A. If you use "Acad.lsp" or "Acaddoc.lsp" or similar at startup you could put the following piece of code
in one of these files; it will ensure that you get the number of command lines you want.
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (1 of 7) [23/03/2005 05:48:02 p.m.]
(setenv "CmdVisLines" "2")
;Sets the number of lines in the AutoCAD command line window
"CmdVisLines" must be written as is ie Upper & Lower case
"2" number of command lines you require ie 1, 2, 3.... etc
Random Number Generator.
Random number generation function - based on the linear congruential method as presented in Doug
Cooper's book Condensed Pascal, pp. 116-117.
Returns a random number between 0 and 1.
(defun randnum (/ modulus multiplier increment random)
(if (not seed)
(setq seed (getvar "DATE"))
)
(setq modulus 65536
multiplier 25173
increment 13849
seed (rem (+ (* multiplier seed) increment) modulus)
random (/ seed modulus)
)
)
Applying Points.
I received this from Roger Farley:
I was browsing your tips and tricks area and thought I would contribute a gem:
These four lines will give you the extreme four values in a points list:
where PointList is a list of 2D or 3D points (like a list of pline vertex points),
(setq X1 (apply 'min (mapcar 'car PointList)))
; The smallest 'X' value
(setq Y1 (apply 'min (mapcar 'cadr PointList)))
; The smallest 'Y' value
(setq X2 (apply 'max (mapcar 'car PointList)))
; The largest 'X' value
(setq Y2 (apply 'max (mapcar 'cadr PointList)))
; The largest 'Y' value
Then assemble like:
(setq LowerLeft (List X1 Y1))
(setq LowerRight (List X2 Y1))
(setq UpperRight (List X2 Y2))
(setq UpperLeft (List X1 Y2))
or
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (2 of 7) [23/03/2005 05:48:02 p.m.]
(setq CPWin (list (List X1 Y1) (list X2 Y1)
(list X2 Y2) (list X1 Y2)))
;A list of 4 points, can be passed to a 'ssget' function
I use the trick in finding an extents boundary around the objects
I am working with, or performing a zoom window around the work area.
Roger Farley
Saving and Restoring System Variables.
It is good practice (and manners) when writing Lisp routines to restore the system environment to the
state that your program found it in on completion of your application. Most AutoLisp routines start and
end like this :
(defun c:example ()
(setq oldhigh (getvar "Highlight")
oldsnap (getvar "Osmode")
oldblip (getvar "BlipMode")
oldecho (getvar "Cmdecho")
);setq
(setvar "Highlight" 0)
(setvar "Osmode" 517)
(setvar "Blipmode" 0)
(setvar "Cmdecho" 0)
Programme statements.............
.................................
(setvar "Highlight" oldhigh)
(setvar "Osmode" oldsnap)
(setvar "Blipmode "oldblip)
(setvar "Cmdecho" oldecho)
(princ)
);defun
;******************************************************
I must have written statements like this a thousand times in my Lisp routines.
The following example is designed to act as a global routine that first stores, then changes specific
system variables. On completion of the routine, the function is then called again and all system
variables are returned to their previous settings.
(defun varget ()
(setq lis '("HIGHLIGHT" "BLIPMODE" "CMDECHO"
"BLIPMODE" "OSMODE"))
;store names of system variables
(setq var (mapcar 'getvar lis))
;get the value of the system variables and
;store them as a list
(setq var1 '(0 0 0 0 517))
;store the new values of the system variables
(setq no 0)
;set counter to zero
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (3 of 7) [23/03/2005 05:48:02 p.m.]
(repeat (length lis)
;get the number of variables in the list
;to use as the counter control number
(setvar (nth no lis) (nth no var1))
;set the variables to their new values
(setq no (1+ no))
;move up one in the list
);repeat
(princ);finish quietly
);defun
;***************************************************************
(defun varset ()
(setq no 0)
;set counter to zero
(repeat (length lis)
;get the number of variables in the list
(setvar (nth no lis) (nth no var))
;reset the variables to their original values
(setq no (1+ no))
;move up one in the list
);repeat
(princ);finish quietly
);defun
;***************************************************************
(princ);load quietly
Our Autolisp routine could now look like this :
(defun c:example ()
(varget)
;store system variables and then reset them
Programme statements.............
.................................
(varset)
;restore system variables
(princ)
);defun
;******************************************************
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (4 of 7) [23/03/2005 05:48:02 p.m.]
As you can see, we have reduced the size of our routine by a lot and saved ourselves quite a bit of
typing. These two routines could both be loaded from our Acad.Lsp file so that they would be available
to all of your routines.
(getfiled) and (startapp).
Here is a handy little routine that displays a dialogue box that defaults to a user defined directory and
allows you to choose a Lisp file to edit. It then opens the file in Window's Notepad. When you have
finished editing, it automatically loads the relevant Lisp file.
It uses the (getfiled) function to locate and open the Lisp file, and the (startapp) function to run
Notepad.exe. You can change both path specifications to suit your setup.
(defun c:test ( / fl)
(setq fl
(getfiled "Select a Lisp File"
"d:/cadken/cadlisp14/NewLisp/"
"lsp" 0)
);setq
(startapp "c:/windows/notepad.exe" fl)
(load fl)
(alert (strcat "\n " fl " Loaded"))
(princ)
);defun
(princ)
Creating Defaults.
In many AutoCAD commands, AutoCAD remembers the last entry and puts that entry between angle
brackets (<>).
Then all you have to do is press Enter, and that value is used. You should use that technique whenever
you're creating your own defaults in AutoLISP.
First make sure that you haven't declared as local the variable that will hold the value. Then follow a
three-step process :
Require input from the user and assign that input to a second variable.
Test to see if the input is nil, and if it is nil, assign a global variable
to the real variable.
G
Finally, assign the real variable to the global variable. G
You're then ready for the next sequence. G
Here's an example :
(defun c:prog1 (/ a)
(if (= gv nil)
(setq gv 1.0)
);end if
(princ "\nEnter Distance <")
(princ gv)
(princ "> ")
(setq a (getdist))
(if (= a nil)
(setq a gv)
);end if
(setq gv a)
(princ "\nThe Distance is ")
(princ a)
(princ)
);defun
gv is the global variable.
No matter how often you run this routine while in the same drawing, it will maintain the last entry as the
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (5 of 7) [23/03/2005 05:48:02 p.m.]
default. The first time through the routine, gv is tested to see if it has a value. If it doesn't, the routine
assigns 1.0 as the default value.
Converting Strings to Uppercase.
There are many occasions when you'll need to convert a string variable to uppercase, especially when
you've requested a response and need to test it. It's much easier to test it against all-uppercase than to
try to test for every combination of uppercase and lowercase. The command for the conversion is
(strcase) :
(setq uc (strcase t))
This converts the value of the string variable t to uppercase and assigns
the new value to the variable uc.
Break @ Circle.
Have you ever tried breaking a Circle into 2 separate parts using the Break command? It doesn't work
does it? This routine allows you to separate a circle into two arcs by picking
two points on the circle.
(defun c:bcirc (/ os pt1 pt2 a pt3)
(setq os (getvar "osmode"))
(setvar "osmode" 512)
(setq pt1 (getpoint "\nFirst Break in Circle : "))
(setq pt2 (getpoint "\nSecond Break in Cricle : "))
(setq a (entget (ssname (ssget pt1) 0)))
(setq pt3 (cdr (assoc 10 a)))
(command "break" pt1 pt2)
(command "arc" pt1 "e" pt2 pt3)
(setvar "osmode" os)
(princ)
)
(princ)
Pick any 2 points on the a Circle.
The circle will look the same, but it will be broken into two arcs.
Restoring 2 Arcs to a Circle.
This routine will join 2 arcs back into a circle.
It will also complete a circle from an Arc.
(defun c:rcirc (/ os pt2 a pt1 ra pt3)
(setq os (getvar "osmode"))
(setvar "osmode" 512)
(setq pt2 (getpoint "\nPick one of the Arcs : "))
(setq a (entget (ssname (ssget pt2) 0)))
(setq pt1 (cdr (assoc 10 a)))
(setq ra (cdr (assoc 40 a)))
(command "erase" pt2 "")
(setq pt3 (getpoint "\nPick other Arc : "))
(setvar "osmode" os)
(command "erase" pt3 "")
(command "circle" pt1 ra)
(princ)
)
(princ)
Begin this routine with one or two arcs.
Pick either arc. That arc will disappear.
Pick the remaining arc if you started with two.
If you started with only one arc, pick any blank space on the screen or press Enter. Now the circle will
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (6 of 7) [23/03/2005 05:48:02 p.m.]
be restored or the single arc is turned into a complete circle.
Page I Page III

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Tips and Tricks - Page II
http://www.afralisp.com/tips2.htm (7 of 7) [23/03/2005 05:48:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp's Tips 'n Tricks III
Page I Page II
Loading Partial Menu's
In AutoCAD R14 you have no problems in loading Partial Menu's.
AutoCAD Release 13, though is a different story!
Every time you re-start AutoCad you have to manually re-load the partial menu.
If you load it from your Acad.Lsp using the menuload command that works fine the first time you enter AutoCad. But
as soon as you open another drawing you get an error in your Acad.lsp file with Autocad telling you that the partial
menu is already loaded.
The following is an extract from the AutoCAD Custumization Manual :
To determine if a menu file is currently partially loaded, you can use the following syntax with any POP menu item (it
works with only a POP menu item) :
(menucmd "Gmenugroup.nametag=?")
If the menu file is currently loaded, this will return a nonnil value
otherwise it will return nil.
Example : Use the following code in your Acad.lsp file.
You must have a partial menu named TEST.MNU and a POP menu item called AMENUITEM. (You can, of course, use
your own Menu and POP names).
;;*-------------------------------------------------------------------
(defun S::STARTUP ()
;define Startup function
(setq temp (menucmd "GTEST.AMENUITEM=?"))
;is the POP item loaded?
(if (= temp nil)
;test it
(progn
;if it is not loaded
(setvar "filedia" 0)
;suppress dialog boxes
(command "menuload" "TEST")
;load Menu
(menucmd "P8=+TEST.POP1")
;load POP1
(menucmd "P9=+TEST.POP2")
;load POP2
(setvar "filedia" 1)
;restore dialogs
More Tips and Tricks - Page III
http://www.afralisp.com/tips3.htm (1 of 4) [23/03/2005 05:48:03 p.m.]
);progn
);if

(prompt "\nPartial Menu Loaded....\n")
;prompt user
(princ)
);defun
;*---------------------------------------------------------------------
Existing S::STARTUP
Because an S::STARTUP function can be defined in many places (an acad.lsp file, a .mnl file, or any other AutoLISP
file loaded from either of these), it's possible to overwrite a previously defined S::STARTUP function. The following
example shows one method of ensuring that
your start-up function works with other functions.
(defun MYSTARTUP ()
....Your Start Up Function....
)
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
The previous code appends your start up function to that of an existing S::STARTUP funtion, and then redefines the
S::STARTUP function to include you startup code. This works properly regardless of the prior existence of an
S::STARTUP function.
Mapcar
Have you ever wondered where you would use the MAPCAR function?
Here is a perfect example :
Say you have a list of data stored in variable arglist
(setq arglist '(12.0 145.8 67.2 "M20"))
You want to place each item in the list in it's own variable to use in your routine. One way to do it would be as follows
:
(setq a (nth 0 arglist))
(setq b (nth 1 arglist))
(setq c (nth 2 arglist))
(setq d (nth 3 arglist))
This works, but is an extremely slow way of processing the data as each variable requires a program statement.
A much more efficient way is to use the MAPCAR technique.
(mapcar 'set '(a b c d) arglist)
This routine maps the SET function to each element of the first list and it's corresponding element of the second list.
SET is used instead of SETQ to evaluate each quoted element of the first list. With the currently set arglist it sets a to
12.0, b to 145.8, c to 67.2 and d to "M20".
*Error* Trap Routine
Once you have written your AutoLisp routine you will find a need for an error trap routine. There is nothing worse
than your program crashing or just being cancelled and finding that some of your system variables have been
modified and no longer work as they should.
The following routine basically takes your settings and stores them.
If the routine runs correctly it simply resets these settings.
(This also saves you having to duplicate the same code over and over just to reset your system variables.)
If your program does crash or is cancelled it restores your settings back to where they were before the routine
started.
The following is an example routine with the error trap incorporated.
(Hint : You could also make the error trap routine a stand alone program, load it from your Acad Lisp file and call it
from multiple programs.
This way it would act as a Global Error Routine.)
More Tips and Tricks - Page III
http://www.afralisp.com/tips3.htm (2 of 4) [23/03/2005 05:48:03 p.m.]
(defun c:lsc ( / a1 a2)
(initerr)
(setq a1 (getvar "ltscale"))
(setq a1 (rtos a1))
(setq a2
(strcat "THE LTSCALE OF THIS DRAWING IS " a1))
(alert a2)
(reset)
(princ)
)
;;;*==========================================================
(defun initerr ()
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
(setq oldpick (getvar "pickbox"))
(setq temperr *error*)
(setq *error* trap)
(princ)
)
;;;*===========================================================
(defun trap (errmsg)
(command nil nil nil)
(if (not
(member errmsg
'("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg))
)
(setvar "clayer" oldlayer)
(setvar "blipmode" 1)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ "\nError Resetting Enviroment ")
(terpri)
(setq *error* temperr)
(princ)
)
;;;*===========================================================
(defun reset ()
(setq *error* temperr)
(setvar "clayer" oldlayer)
(setvar "blipmode" 1)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ)
)
;;;*======================================================
(princ)

More Tips and Tricks - Page III


http://www.afralisp.com/tips3.htm (3 of 4) [23/03/2005 05:48:03 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
More Tips and Tricks - Page III
http://www.afralisp.com/tips3.htm (4 of 4) [23/03/2005 05:48:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
"Utter Rubbish"
Page III
TO: All employees
FROM: The boss
DATE: October 4th, 2002
RE: Foul Language
It has been brought to management's attention that some individuals
throughout the company have been using foul language during the
course of normal conversation with their coworkers. Due to complaints
received from some employees who are easily offended, this type of
language will be no longer tolerated. We do, however, realize the
critical importance of being able to accurately express your feelings
when communicating with coworkers. Therefore, a list of new phrases
has been provided so
that proper exchange of ideas and information can continue in an
effective manner without risk of offending our more sensitive
employees.
TRY SAYING: Perhaps I can work late.
INSTEAD OF: When the f*ck do you expect me to do this?
TRY SAYING: I'm certain that is not feasible.
INSTEAD OF: No f*cking way!
TRY SAYING: Really?
INSTEAD OF: You've got to be sh*tting me.
TRY SAYING: Perhaps you should check with . . .
INSTEAD OF: Tell someone who gives a sh*t.
TRY SAYING: Of course I'm concerned.
INSTEAD OF: Ask me if I give a sh*t.
TRY SAYING: I wasn't involved in the project.
INSTEAD OF: It's not my f*cking problem.
TRY SAYING: That's interesting.
INSTEAD OF: What the f*ck?
TRY SAYING: I'm not sure I can implement this.
INSTEAD OF: F*ck it, it won't work.
TRY SAYING: I'll try to schedule that.
INSTEAD OF: Why the hell didn't you tell me sooner?
TRY SAYING: Are you sure this is a problem?
INSTEAD OF: Who the f*ck cares?
TRY SAYING: He's not familiar with the problem.
INSTEAD OF: He's got his head up his ass.
TRY SAYING: So you weren't happy with it?
INSTEAD OF: Kiss my ass.
TRY SAYING: I'm a bit overloaded at this moment.
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (1 of 15) [23/03/2005 05:48:07 p.m.]
INSTEAD OF: F*ck it, I'm on salary.
TRY SAYING: I don't think you understand.
INSTEAD OF: Shove it up your ass.
TRY SAYING: I love a challenge.
INSTEAD OF: This job sucks.
TRY SAYING: You want me to take care of that?
INSTEAD OF: Who the hell died and made you boss?
TRY SAYING: I see.
INSTEAD OF: Bite me.
TRY SAYING: Yes, we really should discuss it.
INSTEAD OF: Another f*cking meeting?
TRY SAYING: I don't think this will be a problem.
INSTEAD OF: I really don't give a sh*t.
TRY SAYING: He's somewhat insensitive.
INSTEAD OF: He's a f*cking prick.
TRY SAYING: She's an aggressive go-getter.
INSTEAD OF: She's a ball-busting bitch.
TRY SAYING: I think you could use more training.
INSTEAD OF: What the f*ck are you doing?
=====================
Two Irish men walk into a pet shop. Right away they go over to the bird section.
Gerry says to Paddy, "Dat's dem!"
The clerk comes over and asks if he can help them.
"Yeah, we'll take four of dem dere birds in dat cage dere," says Gerry, "Put dem in a peeper bag."
The clerk does and the two guys pay for the birds and leave the shop.
They get into Gerry's van and drive until they are high up in the hills and stop at the top of a cliff with a
500-foot drop.
"Dis looks like a grand place, eh?" says Gerry.
"Oh, yeh, dis looks good," replies Paddy.
They flip a coin and Gerry wins the toss.
"I guess I git to go first, eh Paddy?" says Gerry.
He then takes two birds out of the bag, places them on his shoulders and jumps off the cliff.
Paddy watches as his mate drops off the edge and goes straight down for a few seconds followed by a
'SPLAT'.
As Paddy looks over the edge of the cliff he shakes his head and says,
"Fock dat, dis budgie jumpin' is too fockin' dangerous for me"
======= PART TWO ======
A minute later, Seamus arrives. He too has been to the pet shop and he, walks up carrying the familiar
peeper bag.
He pulls a parrot out of the bag, and then Paddy notices that, in his other hand, Seamus is carrying a
gun.
"Hi, Paddy. Watch this," Seamus says and launches himself over the edge of the cliff.
Paddy watches as half way down, Seamus takes the gun and blows the parrot's head off.
Seamus continues to plummet until there is a SPLAT!, as he joins Gerry's remains at the bottom.
Paddy shakes his head and says, "An' oim never troyin' dat parrotshooting nider"
======= PART THREE ======
A few minutes after Seamus splats himself Sean strolls up. He too has been to the pet shop and he
walks up carrying the familiar
'peeper bag'. Instead of a parrot he pulls a chicken out of the bag, and launches himself off the cliff with
the usual result.
Once more Paddy shakes his head -
"Fock me Sean, first der was Gerry with his budgie jumping, den Seamus parrotshooting and now you
fockin' hengliding!"
===============
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (2 of 15) [23/03/2005 05:48:07 p.m.]
Mike goes into an elevator, looks up and sees this great big huge guy standing next to him.
The big guy sees little Mike staring at him, looks down and says, "7 feet tall, 350lbs, 20inch penis,
testicles 3lbs each, Turner Brown."
Mike just faints dead away and falls to the floor.
The big dude kneels down and brings him to by slapping his face and shaking him. He asks, "Are you
OK??"
In a very weak voice Mike says, "Excuse me, but what did you just say to me?"
The big dude says, "When I saw the curious look on your face, I just figured I'd give you the answers to
the questions everyone always asks me. "I'm 7 feet tall, weigh 350lbs, have a 20 inch penis, my testicles
weigh 3lbs each, and my name is Turner Brown."
Mike said, "Oh Thank God!!! .... I thought you said "Turn Around!!"
=============
Bob joins a very exclusive nudist colony. On his first day he takes off his clothes
and starts wandering around. A gorgeous petite blonde walks by him and the man
immediately gets an erection.
The woman notices his erection, comes over to him grinning sweetly and says:
"Sir, did you call for me?"
Bob replies: "No, what do you mean?"
She says: "You must be new here; let me explain. It's a rule here that if I give you an erection,
it implies you called for me." Smiling, she then leads him to the side of a pool, lays down on a
towel, eagerly pulls him to her and happily lets him have his way with her.
Bob continues exploring the facilities. He enters a sauna, sits down, and farts.
Within a few seconds a huge, horribly corpulent, hairy man with a firm erection lumbers out
of the steam towards him. The Huge Man says: "Sir, did you call for me?"
Bob replies: "No, what do you mean?"
The Huge Man: "You must be new here; it is a rule that when you fart, it implies you called for me."
The huge man then easily spins Bob around, bends him over the bench and has his way with him.
Bob rushes back to the colony office. He is greeted by the smiling naked receptionist:
"May I help you?"
Bob says: "Here is your card and key back. You can keep the $500 joining fee."
Receptionist: "But Sir, you've only been here a couple of hours;
you only saw a small fraction of our facilities.....
"Bob replies: "Listen lady, I am 58 years old...
I get a hard-on twice a month, but I fart 15 times a day!
======================
The Kenny Hangover Scale
1-Star Hangover *
No pain. No real feeling of illness. You slept in your own bed and when you woke up there were no
traffic cones in there with you. You are still able to function relatively well on the energy stored up from
all those vodka red bulls. However, you can drink 10 bottles of water and still feel as parched as the
Sahara. Even vegetarians are craving a Cheeseburger and a side of fries.
2-Star Hangover * *
No pain, but something is definitely amiss. You may look okay but you have the attention span and
mental capacity of a stapler. The coffee you hug to try and remain focused is only exacerbating your
rumbling gut, which is craving a full English breakfast. Although you have a nice demeanour about the
office, you are costing your employer valuable money because all you really can handle is some light
filing, followed by aimlessly surfing the net and writing junk e-mails.
3-Star Hangover * * *
Slight headache. Stomach feels crap. You are definitely a space cadet and not so productive. Anytime a
girl or lad walks by you gag because her perfume/aftershave reminds you of the random gin shots you
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (3 of 15) [23/03/2005 05:48:07 p.m.]
did with your alcoholic friends after the bouncer kicked you out at 1:45 a.m. Life would be better right
now if you were in your bed with a dozen doughnuts and a litre of coke watching daytime TV. You've
had 4 cups of coffee, a gallon of water, 2 Sausage Rolls and a litre of diet coke yet you haven't peed
once.
4-Star Hangover * * * *
You have lost the will to live. Your head is throbbing and you can't speak too quickly or else you might
spew. Your boss has already lambasted you for being late and has given you a lecture for reeking of
booze. You wore nice clothes, but you smell of socks, and you can't hide the fact that you either
missed an oh-so crucial spot shaving or it looks like you put your make-up on while riding the dodgems
depending on your gender. Your teeth have their own individual sweaters. Your eyes look like one big
vein and your hairstyle makes you look like a reject from the second-grade class picture circa 1976.
You would give a week's pay for one of the following: _Home time, doughnut and somewhere to be
alone, or a Time machine so you could go back and NOT have gone out the night before. You scare
small children in the street just by walking past them.
5-Star Hangover * * * * *
You have a second heartbeat in your head, which is actually annoying the employee who sits next to
you. Vodka vapour is seeping out of every pore and making you dizzy. You still have toothpaste crust in
the corners of your mouth from brushing your teeth. Your body has lost the ability to generate
saliva, so your tongue is suffocating you. You'd cry but that would take the last of the moisture left in
your body. Death seems pretty good right now.
Your boss doesn't even get mad at you and your co-workers think that your dog just died because you
look so pathetic. You should have called in sick because, let's face it, all you can manage to do is
breathe...very gently.
6-Star Hangover * * * * * *
You arrive home and climb into bed. Sleep comes instantly; as you were fighting it all the way home in
the taxi. You get about 2 hours sleep until the noises inside your head wake you up. You notice that
your bed has been cleared for take off and is flying relentlessly around the room. No matter
what you do you now, you're going to chuck. You stumble out of bed and now find that your room is in a
yacht under full sail. After walking along the skirting boards on alternating walls knocking off all the
pictures, you find the toilet. If you are lucky you will remember to lift the lid before you
spontaneously explode and wake the whole house up with your impersonation of walrus mating calls.
You sit there on the floor in your undies, Cuddling the only friend in the world you have left (the toilet),
randomly continuing to make the walrus noises, spitting, and farting. Help usually comes at this
stage, even if it is short lived. Tears stream down your face and your abdomen hurts. Help now turns
into abuse and he/she usually goes back to bed leaving you there in the dark. With your stomach totally
empty, your spontaneous eruptions have died back to 15-minute intervals, but your body won't relent.
You are convinced that you are starting to turn yourself inside out and swear that you saw your tonsils
projectile out your mouth on the last occasion. It is now dawn and you pass your disgusted partner
getting up for the day as you try to climb into bed. She/He abuses you again
for trying to get into bed with lumpy bits of dried vomit in your hair. _You reluctantly accept their advice
and have a shower in exchange for them driving you to the hospital. Work is not an option.
===============
Unauthorized Activity
This one is a cracker. It was an actual letter sent to a man named
Ryan DeVries by the Michigan Department of Environmental Quality, State
of Michigan.
Wait till you read this guy's response.......
***************************
Mr. Ryan DeVries
2088 Dagget Pierson, MI 49339
SUBJECT: DEQ File No. 97-59-0023; T11N; R10W, Sec. 20;
Montcalm County
Dear Mr. DeVries:
It has come to the attention of the Department of Environmental
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (4 of 15) [23/03/2005 05:48:07 p.m.]
Quality that there has been recent unauthorized activity on the
above referenced parcel of property. You have been certified as
the legal landowner and/or contractor who did the following
unauthorized activity:
Construction and maintenance of two wood debris dams across the
outlet stream of Spring Pond. A permit must be issued prior to
the start of this type of activity. A review of the Department's
files shows that no permits have been issued. Therefore, the
Department has determined that this activity is in violation of
Part 301, Inland Lakes and Streams, of the Natural Resource and
Environmental Protection Act, Act 451 of the Public Acts of 1994,
being sections 324.30101 to 324.30113 of the Michigan Compiled
Laws, annotated.
The Department has been informed that one or both of the dams
partially failed during a recent rain event, causing debris and
flooding at downstream locations. We find that dams of this
nature are inherently hazardous and cannot be permitted. The
Department therefore orders you to cease and desist all activities
at this location, and to restore the stream to a free-flow
condition by removing all wood and brush forming the dams from the stream channel. All restoration
work shall be completed no later than
January 31, 2002.
Please notify this office when the restoration has been completed
so that a follow-up site inspection may be scheduled by our staff.
Failure to comply with this request or any further unauthorized
activity on the site may result in this case being referred for
elevated enforcement action.
We anticipate and would appreciate your full cooperation in this
matter. Please feel free to contact me at this office if you have
any questions.
Sincerely, David L. Price
District Representative Land and Water Management Division
*******************
This is the actual response sent back........
Dear Mr. Price,
Re: DEQ File No. 97-59-0023; T11N; R10W, Sec. 20;
Montcalm County.
Your certified letter dated 12/17/01 has been handed to
me to respond to.
First of all, Mr. Ryan DeVries is not the legal Landowner and/or
Contractor at 2088 Dagget, Pierson, Michigan. I am the legal
owner and a couple of beavers are in the (State unauthorized)
process of constructing and maintaining two wood "debris" dams
across the outlet stream of my Spring Pond.
While I did not pay for, authorize, nor supervise their dam
project, I think they would be highly offended that you call their
skillful use of natures building materials "debris."
I would like to challenge your department to attempt to emulate
their dam project any time and/or any place you choose. I believe
I can safely state there is no way you could ever match their dam
skills, their dam resourcefulness, their dam ingenuity, their dam
persistence, their dam determination and/or their dam work ethic.
As to your request, I do not think the beavers are aware that they
must first fill out a dam permit prior to the start of this type of
dam activity.
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (5 of 15) [23/03/2005 05:48:07 p.m.]
My first dam question to you is: (1) Are you trying to discriminate
against my Spring Pond Beavers or (2) do you require all beavers
throughout this State to conform to said dam request?
If you are not discriminating against these particular beavers,
through the Freedom of Information Act, I request completed
copies of all those other applicable beaver dam permits that have
been issued. Perhaps we will see if there really is a dam violation
of Part 301, Inland Lakes and Streams, of the Natural Resource
and Environmental Protection Act, Act 451 of the Public Acts of
1994, being sections 324.30101 to 324.30113 of the Michigan
Compiled Laws, annotated.
I have several concerns. My first concern is - aren't the beavers
entitled to legal representation? The Spring Pond Beavers are
financially destitute and are unable to pay for said
representation - so the State will have to provide them with a dam lawyer.
The Department's dam concern that either one or both of the dams
failed during a recent rain event causing flooding is proof that
this is a natural occurrence, which the Department is required
to protect.
In other words, we should leave the Spring Pond Beavers alone
rather than harassing them and calling their dam names. If you
want the stream "restored" to a dam free-flow condition please
contact the beavers - but if you are going to arrest them, they
obviously did not pay any attention to your dam letter, they being
unable to read English.
In my humble opinion, the Spring Pond Beavers have a right to
build their unauthorized dams as long as the sky is blue, the grass
is green and water flows downstream. They have more dam rights
than I do to live and enjoy Spring Pond. If the Department of
Natural Resources and Environmental Protection lives up to its name, it
should protect the natural resources (Beavers) and the environment
(Beavers' Dams.).
So, as far as the beavers and I are concerned, this dam case can
be referred for more elevated enforcement action right now. Why
wait until 1/31/2002? The Spring Pond Beavers may be under the
dam ice then and there will be no way for you or your dam staff to
contact/harass them then.
In conclusion, I would like to bring to your attention to a real
environmental quality (health) problem in the area. It is the
bears!
Bears are actually defecating in our woods. I definitely believe
you should be persecuting the defecating bears and leave the beavers
alone. If you are going to investigate the beaver dam, watch your
step! (The bears are not careful where they dump!)
Being unable to comply with your dam request, and being unable
to contact you on your dam answering machine, I am sending this
response to your dam office.
Sincerely,
Stephen L.Tvedten
===================
One night, a police officer was staking out a particularly rowdy bar for possible violations of the driving
under the influence laws.
At closing time, he saw a fellow stumble out of the bar, trip on the curb, and try his keys on five different
cars before he found his. Then, sat in the front seat fumbling around with his keys for several minutes.
Everyone else then left the bar and drove off.
Finally, the guy sitting in his car started his engine and began to pull away.
The police officer was waiting for him. He stopped the driver, read him his rights and administered the
Breathalyzer test. The results showed a reading of 0.0 % !
The puzzled officer demanded to know how that could be.
The driver replied, "Tonight, I'm the Designated Decoy."
=================
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (6 of 15) [23/03/2005 05:48:07 p.m.]
Extract from the Australian Etiquette Handbook
GENERAL:
1. Never take a beer to a job interview.
2. Always identify people in your yard before shooting them.
3. If you have to vacuum the bed, it's time to change the sheets.
4. Even if you're certain you're included in the will, it's rude to take the trailer to the funeral home.
DINING OUT:
1. When decanting wine from the box, tilt the paper cup and pour slowly so as not to "bruise" the wine.
2. If drinking directly from the bottle, hold it with only one hand.
ENTERTAINING IN YOUR HOME:
1. A centrepiece for the table should never be anything prepared by a taxidermist.
2. Don't allow the dog to eat at the table, no matter how good his manners.
PERSONAL HYGIENE:
1. While ears need to be cleaned regularly, this should be done in private, using one's OWN keys.
2. Even if you live alone, deodorant isn't a waste of money.
3. Use of toiletries can only delay bathing a few days.
4. Dirt and grease under the fingernails is a no-no, as it detracts from a woman's jewelry and alters the
taste of finger foods.
DATING (Outside the Family):
1. Always offer to bait your date's hook, especially on the first date.
2. Be assertive. Let her know you're interested: "I've been wanting to go out with you since I read that
stuff on the crap house door two years ago."
3. Establish with her parents what time she's expected back. Some will say 10:00 PM, others might say
"Monday." If the latter is the answer, it's the man's responsibility to get her to school on time.
THEATRE ETIQUETTE:
1. Crying babies should be taken to the lobby and picked up after the movie ends.
2. Refrain from talking to characters on the screen. Tests have proven they can't hear you.
WEDDINGS:
1. Livestock is a poor choice for a wedding gift.
2. Kissing the bride for more than five seconds may get you shot.
3. For the groom, at least, rent a tux. A track suit with a cummerbund and a clean football jumper can
create a tacky appearance.
4. Though uncomfortable, say "yes" to socks and shoes for the occasion.
DRIVING ETIQUETTE:
1. Dim your headlights for approaching vehicles, even if the gun's loaded and the drivers heads in sight.
2. When approaching a round-about, the vehicle with the largest tyres doesn't always have the right of
way.
3. Never tow another car using panty hose and duct tape.
4. When sending your wife down the road with a petrol can, it's impolite to ask her to bring back beer,
too.
=================
Politics..
Returning from school one day, little Johnny goes to his father and asks:
- Dad, our teacher mentioned during the history class today one word I didn't know...
- Yes son...?
-It's "politics", dad. Could you explain me what it means?
- Well now, Johnny - says his father while frowning - that's a rather complex term.. especially for
someone as young as you; to make it easier, let's put it into your perspective: I am your father. I work
and bring money to this house. I make all of the most important decisions. Therefore let's call me
Capitalism. Your mum, she run's the household - so she's something like a Government around here.
Our maid does most of the toil around the house - so she can be the Working Class. You son, let's call
you The People. And your little baby brother is our youngest family member - hence he's the future.
That's pretty much how politics works, son. Was that good enough for you?
-Well, thank's dad. It was a bit confusing though. I'll have to sleep on it a bit and see whether I can
understand it tomorrow..
Later that night, Johnny suddenly wakes up. He's hungry. On the way to the kitchen, he hears his little
brother screaming from his cot. So he sneaks to his room, takes a good look around, and finds his
sibling in soiled pampers ;-) The stench is unbearable. And since Johnny is only a 9-year old kid, with
no baby-training, he shouts for his parents.
Nothing. He shouts again, only louder. Still nothing. Quite frustrated with the situation at hand, he heads
for his parents' bedroom, where he finds his mother fast asleep, but no trace of the "patter familias".
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (7 of 15) [23/03/2005 05:48:07 p.m.]
Puzzled, he goes to the maid's chambers - and lo! and behold there's his dad, (with the maid, of course),
cheating on his wife! Exasparated, Johnny finally gives up, and goes back to bed.
The next day, Johnny's father (unaware of his son's revelations the previous night)goes to his boy and
asks:
- So..is politics any clearer to you now?
- 'Course it is dad. While Capitalism is screwing the Working Class, Government is fast asleep, People is
being ignored, and our Future is in deep sh*t!
=================
Ever wonder why Middle Eastern Muslim terrorists are so quick to
volunteer for suicide missions?
Let's just take a closer look at their lifestyle...
No premarital sex.
No Booze. None. Never.
No TV. No cable TV. No satellite TV
No Spice channel. No Playboy channel. No ESPN. No Hooters!
No Sports Illustrated Swimsuit Edition.
Sand. F*ckin' sand everywhere!
No organized sports of any kind. That's right No Sports!
Women are to be completely covered and wear veils.
No thongs. No Victoria's Secret.
Very, very few cars.
Camels. Lots of camels. Stinking, filthy camels.
Sand. F*ckin' sand everywhere!
Ever try to fish at an Oasis? No bass boats. No bass. No fish.
Sandstorms. More f*ckin' sand everywhere!
Rags for clothes and dishcloths with fanbelts for hats.
Camel and goat burgers cooked over burning camel dung chips.
Eating with your right hand only because you wipe your butt
with your left.
Toilet tissue is unknown.
Sand. F*ckin' sand everywhere!
No Golf. Just sand traps.
Constant wailing next door...no wait, that's their music.
Praying 5 times a day. For what? More of this life?
Oh, and did I mention the f*ckin' sand?
And when you die it's supposed to get better.
No wonder they volunteer for suicide missions!!
================
An elderly Italian man asked the local priest to hear his confession:
"Father, during World War 2 a beautiful woman knocked on my door and asked me to hide her from the
Germans. I hid her in my attic".
The priest replied, "That was a wonderful thing you did and you have no need to confess."
"It's worse, Father. I was weak and told her she must repay me with sexual favours."
"You were both in great danger and would have suffered terribly if the Germans had found her. God, in
his wisdom and mercy, will balance the good and the evil and judge you kindly. You are forgiven."
"Thank you, Father, That's a great load off my mind. I have one more question."
"And what is that?" asked the priest.
The old man replied, "Should I tell her the war is over?
=================
A magazine recently ran a "Dilbert Quotes" contest. They were looking
for people to submit quotes from their real life Dilbert-type managers.
Here are the finalists:
1. "As of tomorrow, employees will only be able to access the building
using individual security cards. Pictures will be taken next Wednesday
and employees will receive their cards in two weeks". (This was the
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (8 of 15) [23/03/2005 05:48:07 p.m.]
winning quote from Fred Dales at Microsoft Corp. in Redmond,WA.)
2. "What I need is a list of specific unknown problems we will encounter".
(Lykes Lines Shipping)
3. "E-mail is not to be used to pass on information or data. It should
be used only for company business". (Accounting manager,Electric Boat Company)
4. "This project is so important, we can't let things that are more important interfere with it".
(Advertising/Marketing manager, United Parcel Service)
THIS ONE REALLY TAKES THE CAKE
5. "Doing it right is no excuse for not meeting the schedule".
6. "No one will believe you solved this problem in one day! We've been working on it for months. Now,
go act busy for a few weeks and I'll let you know when it's time to tell them". (R&D supervisor,
Minnesota Mining and Manufacturing/3M Corp.)
7. "My Boss spent the entire weekend retyping a 25-page proposal that only needed corrections. She
claims the disk I gave her was damaged and she couldn't edit it. The disk I gave her was
write-protected". (CIO of Dell Computers)
8. Quote from the Boss: "Teamwork is a lot of people doing what I say".(Marketing executive, Citrix
Corporation)
9. My sister passed away and her funeral was scheduled for Monday. When I told my Boss, he said she
died on purpose so that I would have to miss work on the busiest day of the year. He then asked if we
could change her burial to Friday. He said, "That would be better for me". (Shipping executive, FTD
Florists)
10. "We know that communication is a problem, but the company is not going to discuss it with the
employees". (Switching supervisor, AT&T Long Lines Division)
11. We recently received a memo from senior management saying: "This is to inform you that a memo
will be issued today regarding the memo mentioned above". (Microsoft, Legal Affairs Division)
12. One day my Boss asked me to submit a status report to him concerning a project I was working on. I
asked him if tomorrow would be soon enough. He said, "If I wanted it tomorrow, I would have waited
until tomorrow to ask for it!" (New business manager,Hallmark Greeting Cards.)
13. As director of communications, I was asked to prepare a memo reviewing our company's training
programs and materials. In the body of the memo in one of the sentences I mentioned the "pedagogical
approach" used by one of the training annuals. The day after I routed the memo to the executive
committee, I was called into the HR director's office, and told that the executive vice president wanted
me out of the building by lunch. When I asked why, I was told that she wouldn't stand for perverts
(paedophiles?) memo, with her demand that I be fired - and the word "pedagogical" circled in red. The
HR manager was fairly reasonable, and once he looked the word up in his dictionary and made a copy
of the definition to send back to her, he told me not to worry. He would take care of it. Two days later, a
memo to the entire staff came out directing us that no words which could not be found in the local
Sunday newspaper could be used in company memos. A month later, I resigned. In accordance with
company policy, I created my resignation memo by pasting words together from the Sunday
paper.
(Taco Bell Corporation)
================
An old cowboy went to a bar and ordered a drink. As he sat there sipping whiskey, a young lady sat
down next to him.
She turned and asked, "Are you a real cowboy?"
He replied, "Well, I've spent my whole life on the ranch, herding cows, breaking horses, mending fences,
so I guess I am." He then asked her what she was.
She replied, "I'm a lesbian. I spend my whole day thinking about women. As soon as I get up in the
morning I think of women, when I eat, shower, watch TV, everything seems to make me think of
women."
A little while later a couple sat down next to the old cowboy and asked him, "Are you a real cowboy?"
He replied, "I always thought I was, but I just found out I'm a lesbian."
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (9 of 15) [23/03/2005 05:48:07 p.m.]
=================
A little girl walks into a pet shop and asks in the sweetest little
lisp, "Excuthe me, mithter, do you keep wittle wabbits?"
The shopkeeper gets down on his knees, so that he's on her level, and asks,
"Do you want a likkle white wabbit? Or a soft and fuwwy black wabbit? Or maybe one like that cute
likkle brown wabbit over there?"
She in turn puts her hands on her knees, leans forward and says in a quiet voice, "I don't fink my pyfon
weally gives a phuck!"
==================
A man left work one Friday afternoon. But being payday, instead of going home he partied with the boys
and stayed out all weekend, spending his entire paycheck.
When he finally appeared at home on Sunday night, he was confronted by a very angry wife and was
barraged for nearly two hours with a tirade befitting his actions.
Finally his wife stopped the nagging and simply said to him. "How would you like it if you didn't see me
for two or three days?"
To which he replied. "That would be fine with me."
Monday went by and he didn't see his wife. Tuesday and Wednesday came and went with the same
results. Come Thursday, the swelling went down just enough where he could see her a little out of the
corner of his left eye.
================
The Washington Post's Style invitational asked readers to take any word from the dictionary, alter it by
adding, subtracting, or changing one letter, and supply a new definition. Here are some recent winners:
Intaxication: Euphoria at getting a tax refund, which lasts until you realize it was your money to start
with.
Reintarnation: Coming back to life as a hillbilly.
Bozone (n.): The substance surrounding stupid people that stops bright ideas from penetrating. The
bozone layer, unfortunately, shows little sign of breaking down in the near future.
Foreploy: Any misrepresentation about yourself for the purpose of getting laid.
Cashtration (n.): The act of buying a house, which renders the subject financially impotent for an
indefinite period.
Giraffiti: Vandalism spray-painted very, very high.
Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.
Inoculatte: To take coffee intravenously when you are running late.
Hipatitis: Terminal coolness.
Osteopornosis: A degenerate disease. (This one got extra credit.)
Karmageddon: It's like, when everybody is sending off all these really bad vibes, right? And then, like,
the Earth explodes and it's like, a serious bummer.
Decaflon (n.): The gruelling event of getting through the day consuming only things that are good for
you.
Glibido: All talk and no action.
Dopeler effect: The tendency of stupid ideas to seem smarter when they come at you rapidly.
Arachnoleptic fit (n.): The frantic dance performed just after you've accidentally walked through a spider
web.
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (10 of 15) [23/03/2005 05:48:07 p.m.]
Beelzebug (n.): Satan in the form of a mosquito that gets into your bedroom at 3 in the morning and
cannot be cast out.
Caterpallor (n.): The color you turn after finding half a grub in the fruit you're eating.
And the pick of the literature:
Ignoranus: A person who's both stupid AND an asshole.
===================
Helpful Hint #1
If you are choking on an ice cube, don't panic. Simply pour a jug of boiling water down your throat and
presto! The blockage is almost instantly removed.
Helpful Hint #2
Clumsy? Avoid cutting yourself while slicing vegetables by getting someone else to hold them while
you chop away
Helpful Hint #3
Don't buy expensive 'ribbed' condoms, just buy an ordinary one and slip a handful of frozen peas inside
it before you put it on.
Helpful Hint #4
Putting just the right amount of gin in your goldfish bowl makes the fishes' eyes bulge and cause them
to swim in an amusing manner.
Helpful Hint #5
An empty aluminum cigar tube filled with angry wasps makes a wonderful inexpensive vibrator.
Helpful Hint #6
Avoid arguments with the missus about lifting the toilet seat by simply pissing in the sink.
Helpful Hint #7
High blood pressure sufferers: ! simply cut yourself and bleed for a while,thus reducing the pressure in
your veins.
Helpful Hint #8
A mouse trap, placed on top on of your alarm clock, will prevent you from rolling over and going back to
sleep.
Helpful Hint #9
If you have a bad cough, take a large dose of laxatives, then you will be afraid to cough!
====================
President Bush and Colin Powell are sitting in a bar. A guy walks in, spots them and asks the bartender,
"Isn't that Bush and Powell sitting over there?"
The bartender answers, "Yep, that's them."
So the guy walks over and says, "Wow, this is a real honor. What are you guys doing in here?" Bush
says, "We're planning WW III."
"World War III!" the guy exclaims. "Really? What's going to happen?"
Bush says, "Well, we're going to get rid of Saddam Hussein and kill 140 million Iraqis and one blonde
with big breasts."
The guy looks puzzled. "A blonde with big breasts? Why kill a blonde with big breasts?"
Bush turns to Powell, punches him on the shoulder and says, "See. I told you no one would worry about
the 140 million Iraqis!"
=================
Rev Jackson is sat in a bar with Prince Charles when he asks him:
"Hey, Charlie boy, why is Britain called a Kingdom?
Charles answers, "Because it's run by a King."
The Rev replies, "Oh, I suppose that's why they call America a country."
======================
If a small child is choking on an ice cube, don't panic.Simply
pour a jug of boiling water down its throat and hey presto! The blockage
is almost instantly removed.
Manchester United fans. Save money on expensive new kits by simply
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (11 of 15) [23/03/2005 05:48:07 p.m.]
strapping a large fake penis to your forehead. It is now clear to
all, as to your allegiance.
Clumsy? Avoid cutting yourself while slicing vegetables by getting
someone else to hold them while you chop away.
Keep the seat next to you on the train vacant by smiling and
nodding at people as they walk up the aisle.
Weight watchers. Avoid that devilish temptation to nibble at the
chocolate bar in the cupboard or fridge by not buying the f**king
thing in the first place, you fat b*st*rds.
Save on booze by drinking cold tea instead of whisky. The
following morning you can create the effects of a hangover by drinking a
thimble full of washing up liquid and banging your head repeatedly on the
wall.
Make bath times as much fun for kiddies as a visit to the seaside
by pouring a bucket of sand, a bag of salt and a dog turd into the
bath.
Recreate the fun of a visit to a public swimming pool in your own
home by filling the bath with cold water, adding two bottles of bleach,
then urinating into it, before jumping in.
Girls. Too old to go on an 18 to 30 holiday? Simply get pi**ed,
lie in a sand pit in your garden and sh*g every bloke who looks at you over
the fence.
Don't buy expensive 'ribbed' condoms, just buy an ordinary one and
slip a handful of frozen peas inside it before you put it on.
X-Files fans. Create the effect of being abducted by aliens by
drinking two bottles of vodka. You'll invariably wake up in a strange place
the following morning, having had your memory mysteriously 'erased'.
Don't waste money buying expensive binoculars. Simply stand closer
to the object you wish to view.
Putting just the right amount of gin in your goldfish bowl makes
the fishes' eyes bulge and cause them to swim in an amusing manner.
Save time when crossing a one-way street by only looking in the
direction of oncoming traffic.
Thicken up runny low-fat yoghurt by stirring in a spoonful of
lard.
Anorexics. When your knees become fatter than your legs, start
eating cakes again.
A next door neighbour's car aerial, carefully folded, makes an
ideal coat hanger in an emergency.
Hijackers. Avoid a long stressful siege and the risk of arrest,
imprisonment or death by simply making sure you book a flight to
your intended destination in the first place.
An empty aluminium cigar tube filled with angry wasps makes an
inexpensive vibrator.
Olympic athletes. Disguise the fact that you've taken anabolic
steroids by running a bit slower. - B. Johnson, Canada
Avoid arguments with the missus about lifting the loo seat by
simply pi**ing in the sink.
Weedy fellas. Develop a right forearm like Arnold Schwarzeneggar
by buying one of those Cindy Crawford workout videos.
Smokers. Save on matches and lighters, by simply lighting your
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (12 of 15) [23/03/2005 05:48:07 p.m.]
next fag from the butt of your last one.
Vegetarians coming to dinner? Simply serve them a nice bit of
steak or veal. Since they're always going on about how tofu, Quorn, meat
substitute etc 'tastes exactly like the real thing', they won't
know any difference.
Invited by vegetarians for dinner? Point out that since you'd no
doubt be made aware of their special dietary requirements, tell them
about yours, and ask for a nice steak.
Spice up your sex life by trying a bit of 'rodeo sex'. Take your
missus from behind and, holding on tightly to her jugs, call her by the
wrong name. See how long you can 'stay mounted' for.
Before attempting to remove stubborn stains from a garment always
circle the stain in permanent pen so that when you remove the garment
from the washing machine you can easily locate the area of the stain and
check that it has gone.
Give comics that 'Pulp Fiction' feel by reading the last frames of
cartoons first, then reading the rest in a random order.
High blood pressure sufferers. Simply cut yourself and bleed for a
while, thus reducing the pressure in your veins.
Heavy smokers. Don't throw away those filters from the end of your
cigarettes. Save them up and within a few years you'll have enough
to insulate your loft.
Motorists. Enjoy the freedom of cycling by removing your
windscreen, sticking half a melon skin on you head, then jumping red lights
and driving the wrong way up one way streets.
Create instant designer stubble by sucking a magnet and dipping
your chin in a bowl of iron fillings.
Convince neighbours that you have invented a 'SHRINKING' device by
ruffling your hair, wearing a white laboratory coats and parking a
JCB digger outside your house for a few days. Then dim and flicker the
lights in your house during the night and replacethe JCB unseen, with a
Tonka toy of the same description. Watch their faces in the morning!
Have all your dumps at work. Not only will you save money on
toilet paper, but you'll also be getting paid for it.
Nissan Micra drivers. Attach a lighted sparkler to the roof of
your car before starting a long journey. You drive the things like dodgem
cars anyway, so it may as well look like one.
A mouse trap, placed on top on of your alarm clock will prevent
you from rolling over and going back to sleep.
=============================
A salesman drove into a small town where a circus was in process.
A sign read: "Don't Miss The Amazing Scotsman".
The salesman bought a ticket and sat down. There, on centre stage, was a table with three walnuts on it.
Standing next to it was an old Scotsman. Suddenly the old man lifted his kilt, whipped out a huge penis
and smashed all three walnuts with three mightly swings! The crowd erupted in applause as the elderly
Scot was carried off on the shoulders of the crowd.
Then years later the salesman visited the same little town and saw a
faded sign for the same circus and the same sign: "Don't Miss The Amazing Scotsman".
He couldn't believe the old guy was still alive much less still doing his act! He bought a ticket. Again, the
centre ring was illuminated. This time, however, instead of walnuts, three coconuts were placed on the
table.
The Scotsman stood before them, then suddenly lifted his kilt and
smashed the coconuts with three swings of his amazing member. The crowd went wild! Flabbergasted,
the salesman requested a meeting with him after the show.
"You're incredible!" he told the Scotsman. "But I have to know something. You're older now, why switch
from walnuts to coconuts?"
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (13 of 15) [23/03/2005 05:48:07 p.m.]
"Well," said the Scot, "Me eyes are nae whit they used to be."
====================
Tomorrows Weather Forecast
======================
The weather in Iraq tomorrow is expected to be sunny in the morning with increasing mushroom clouds
in the afternoon. The temperature looks to be a moderate 2000 degrees with cool winds upwards of
around 700 miles per hour. It will definitely be a day for the sunblock, and it wouldn't hurt to shake the
dust off the ol' lead suit in the closet. If you're planning on venturing outside in beautiful Iraq tomorrow,
don't forget to drink plenty of fluids such as barium which shows up nicely when blasts of radiation flow
through your body. Most of all, have fun out there in dusty Iraq and enjoy the old country while........
well, while it's still there.
==================
A little rabbit is happily running through the forest when he stumbles upon a giraffe rolling a joint. The
rabbit looks at her and says, "Giraffe my friend, why do you do this? Come with me running through the
forest, you'll see, you'll feel so much better!"
The giraffe looks at him, looks at the joint, tosses it and goes off running with the rabbit.
Then they come across an elephant doing coke, so the rabbit again says, "Elephant my friend, why do
you do this? Think about your health! Come running with us through the pretty forest, you'll see, you'll
feel so good!"
The elephant looks at them, looks at his razor, mirror and all, then tosses them and starts running with
the rabbit and giraffe.
The three animals then come across a lion about to shoot up heroin..."Lion my friend, why do you do
this? Think about your health! Come running with us through the sunny forest, you will feel so good!"
The lion looks at him, puts down his needle, and starts to beat the shit out of the little rabbit.
The giraffe and elephant watch in horror, and ask him "Lion, why did you do this? He was merely trying
to help us all!"
The lion answers, "Every time he's on Ecstasy that little f**ker makes me run around the forest like an
idiot for hours!"
==============
Defence Attorney: What is your age?
Little old Woman: I am 86 years old.
Defence Attorney: Will you tell us, in your own words, what happened?
Little old Woman: There I was, sitting there in my swing on my front porch on a warm spring evening,
when a young man comes creeping up on the porch and sat down beside me.
Defence Attorney: Did you know him?
Little old Woman: No, but he sure was friendly.
Defence Attorney: What happened after he sat down?
Little old Woman: He started to rub my thigh.
Defence Attorney: Did you stop him?
Little old Woman: No, I didn't stop him.
Defence Attorney: Why not?
Little old Woman: It felt good. Nobody had done that since my Abner passed away some 30 years ago.
Defence Attorney: What happened next?
Little old Woman: He began to rub my breasts.
Defence Attorney: Did you stop him then?
Little old Woman: No, I did not stop him.
Defence Attorney: Why not?
Little old Woman: Why, Your Honour, his rubbing made me feel all alive and excited. I haven't felt that
good in years!
Defence Attorney: What happened next?
Little old Woman: Well, I was feeling so spicy that I just layed down and said to him..."Take me ...young
man...Take me!
Defence Attorney: Did he take you?
Little old Woman: Hell, no. He just yelled, "April Fool!" And that's when I shot the little bastard.
==================
An American decided to write a book about famous churches around the world. For his first chapter he
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (14 of 15) [23/03/2005 05:48:07 p.m.]
decided to write about British churches. So he bought a plane ticket and took a trip to London, thinking
that he would work his way across the country from South to North. On his first day he was inside a
church taking photographs when he noticed a golden telephone mounted on the wall with a sign that
read "$10, 000 per call". The writer, being intrigued, asked a priest who was strolling by what the
telephone was used for. The priest replied that it was a direct line to heaven and that for $10, 000 you
could talk to God. The writer thanked the priest and went along his way.
Next stop was in Wales. There, at a very large cathedral, he saw the same golden telephone with the
same sign under it. He wondered if this was the same kind of telephone he saw in London and he asked
a nearby nun what its purpose was. She told him that it was a direct line to heaven and that for $10, 000
he could talk to God. "O.K., thank you," said the writer. He then travelled to Dublin in Ireland. In every
church he saw the same golden telephone with the same "$R10, 000 per call" sign under it.
The American, upon leaving Dublin saw a sign for Glasgow and decided to see if Glaswegians had the
same phone. He arrived in Glasgow, and again, there was the same golden telephone, but this time the
sign under it read "50 cents per call." The writer was surprised so he asked the priest about the sign.
"Father, I've travelled all over Britian and I've seen this same golden telephone in many churches. I'm
told that it is a direct line to Heaven, but in every place the price was $10, 000 per call. Why is it so
cheap here?" The priest smiled and answered, "You're in the Scotland now son, it's a local call".
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Utter Rubbish-Page II
http://www.afralisp.com/utterrubbish2.htm (15 of 15) [23/03/2005 05:48:07 p.m.]
Submit
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
"Utter Rubbish"
Page IV
Mergers
========
In the wake of the Exxon/Mobil deal and the AOL/Netscape deal, here are the next bombshell mergers,
investors should expect:
Hale Business Systems, Mary Kay Cosmetics, Fuller Brush, and W.R. Grace Company merge to become,
Hale Mary Fuller Grace.
Polygram Records, Warner Brothers, and Keebler Crackers merge to become, Polly Warner Cracker.
3M and Goodyear merge to become MMMGood.
Zippo Manufacturing, Audi Motors, Dofasco, and Dakota Mining merge to become,
Zip Audi Do Da.
Federal Express and UPS merge to become FED UP.
Xerox and Wurlitzer will merge and begin manufacturing Reproductive Organs.
Fairchild Electronics and Honeywell Computers will merge and become Fairwell Honeychild
Knott's Berry Farm & National Organization of Women will merge and become, Knott NOW.
----------------------------
Get the picture?
=============
A photographer for a national magazine was assigned to take pictures of a great forest fire. He was
advised that a small plane would be waiting to fly him over the fire.
The photographer arrived at the airstrip just an hour before sundown. Sure enough, a small Cessna
airplane was waiting. He jumped in with his equipment and shouted, "Let's go!" The tense man sitting in
the pilot's seat swung the plane into the wind and soon they were in the air, though flying erratically.
"Fly over the north side of the fire," said the photographer, "and make several low-level passes."
"Why?" asked the nervous pilot. "Because I'm going to take pictures!" yelled the photographer. "I'm a
photographer, and photographers take pictures."
After a long pause, the "pilot" replied: "You mean, you're not my instructor?"
-----------------------
TEACHING MATH THROUGH THE DECADES
==================================
In 1950: A logger sells a truckload of lumber for $100. His cost of production is four-fifths of the price.
What is his profit?
In 1960: A logger sells a truckload of lumber for $100. His cost of production is four-fifths of the price, or
$80. What is his profit?
In 1970 (new math): A logger exchanges a set L of lumber for a set M of money. The cardinality of set M
is 100, and each element is worth $1.00. Make 100 dots representing the elements of the set M. The set C
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (1 of 9) [23/03/2005 05:48:09 p.m.]
of the costs of production contains 20 fewer points than set M. Represent the set C as a subset of M,
and answer the following question: What is the cardinality of the set p of profits?
In 1980: A logger sells a truckload of lumber for $100. His cost of production is $80, and his profit is $20.
Your assignment: underline the number 20.
In 1990: (outcome-based education): By cutting down beautiful forest trees, a logger makes $20. What
do you think of this way of making a living? (Topic for class participation: How did the forest birds and
squirrels feel?)
In 2000: By laying off 40% of its loggers, a company improves its stock price from $80 to $100. How
much capital gain per share does the CEO make by exercising his stock options at $80? Assume capital
gains are no longer taxed, because this encourages investment.
==============
Alfa
Passionate and romantic, you fancy yourself. A bit unreliable, and can
be eccentric too. You hate BMW drivers, but think and act just like
them.
Audi
You would like to believe you are part of the new generation that is
caring, environmentally conscious and family-orientated. Actually, quite
boring, nothing more than a glorified wuss. Will one day probably drive
a Merc, but you still sometimes wonder if you shouldn't have bought that
Bee-Em.
BMW
Self-centred, ambitious, dynamic and assertive. Buppies and kugels
past sell-by date. You think you will be CEO one day. Actually an office
weenie who thinks you are God's gift.
Daewoo
Faceless, subservient and demure (except for Matiz drivers). To you,
a good deal is to work from nine to five, get nothing for it, and still
say thank you. And then you wonder why you don't have money for a good time
after hours.
Ford
You still live in the 70's, trying to cope with the 90's
(don't even mention the millennium). A loyal, diligent worker, but
baffled by office politics and labour policies. Next car will probably
also be a Ford.
Honda
You aspire to drive a BMW. You are an opinionated pain-in-the-butt.
The ultimate suffragette, or the boss's girlfriend (male or female!.
Hyundai
Quite progressive, intelligent and practical. But misguided. The kind
of person who will suggest a sub-committee to find solutions to what the
committee couldn't. You will always maintain that a Korean car is
better than any Japanese model.
Jeep
You would like to believe you are living the American dream and just
love the great outdoors. The closest you get to it is by watching Days
of Our Lives and the Adventure Channel.
Land Rover
You are a designer person with a designer life, who always pays too
much for everything. Designer mud comes free with the badge. If you have
a Freelander, it was probably a break-up gift from your ex.
Mazda
A Ford driver with more money. Mostly staid boring with no image and
less imagination.
Mercedes-Benz
Responsible, immaculate and conservative. Boring CEO clones with too
much money, or the office super-geek who can't remember what it's like
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (2 of 9) [23/03/2005 05:48:09 p.m.]
to have fun. Definitely not dating material.
Nissan
Good, solid, responsible, loyal office-fodder. You like to travel and
maintain that you can sell ice to the Eskimos. Favourite answer:
It's a company car."
Opel
Wannabe Schumachers.
Always in a rush, but never get anything done.
Pajero
Not as label-conscious as your Land Rover counterpart, but still
suckered into believing in the ultimate African adventure. You drive
through puddles to create your own designer mud. You believe you've made the
grade, but everyone else knows you've got a long way to go.
Renault
An eccentric who likes doing things the wrong way around. Usually the
one who asks all the silly questions at staff meetings. You fervently
believe you have flair, but it's less than that of a French cookbook.
Ssangyong
A make-believe fool, because you'd like a Pajero but can't afford it.
VW
You are an exciting and care-free individual. Friends are often
envious of you and your car. Although you are very good-looking
and attractive to the opposite sex, you are very modest and
down-to-earth. Your superior intelligence will get you far in this world.
You were born
to lead.
Toyota
You have an inferiority complex and feel threatened by VW drivers. You
are usually very bad in bed and have difficulty in impressing people of
the opposite sex. You are usually an embarrassment at social functions
and tend to stay alone at home. You find sexual gratification from sleazy
magazines and movies. Often you are found outside adult amusements
stores.
Your desire to own a VW sometimes overwhelms you, and you become nasty and
rude. You should jump into your TOYOTA and drive off a cliff.
====================
REPLACEMENT OF MOUSE BALLS
If a mouse fails to operate or should it perform erratically, it may need a ball replacement. Mouse balls
are now available as FRU (Field Replacement Units). Because of the delicate nature of this procedure,
replacement of
mouse balls should only be attempted by properly trained personnel.
Before proceeding, determine the type of mouse balls by examining the underside of the mouse.
Domestic balls will be larger and harder than foreign balls. Ball removal procedures differ depending
upon the manufacturer of the mouse. Foreign balls can be replaced using the pop-off method. Domestic
balls are replaced by using the twist-off method.
Mouse balls are not usually static-sensitive. However, excessive handling can result in sudden
discharge. Upon completion of ball replacement, the mouse may be used immediately. It is
recommended that each person have a pair of spare balls for maintaining optimum customer
satisfaction.
Any customer missing his balls should contact the local personnel in charge of removing and replacing
these necessary items.
====================
I believe that sex is one of the most beautiful, natural, wholesome
things that money can buy."
~Tom Clancy
"You know "that look" women get when they want sex? Me neither."
~ Steve Martin
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (3 of 9) [23/03/2005 05:48:09 p.m.]
"Having sex is like playing bridge. If you don't have a good partner,
you'd better have a good hand."
~ Woody Allen
"Bisexuality immediately doubles your chances for a date on Saturday
night."
~Rodney Dangerfield
"There are a number of mechanical devices which increase sexual
arousal, particularly in women. Chief among these is the Mercedes-Benz
380SL."
~Lynn Lavner
"Leaving sex to the feminists is like letting your dog vacation at the
taxidermist."
~Matt Barry
"Sex at age 90 is like trying to shoot pool with a rope."
~Camille Paglia
"Sex is one of the nine reasons for reincarnation. The other eight are
unimportant."
~George Burns
==============
A man comes home from an exhausting day at work, plops down on the couch in front of the television,
and tells his wife, "Get me a beer before it starts." The wife sighs and gets him a beer.
Fifteen minutes later, the man says, "Get me another beer before it starts." She looks cross, but fetches
another beer and slams it down next to him.
He finishes that beer and a few minutes later says, "Quick, get me another beer, it's going to start any
minute." The wife is furious. She yells at him, "Is that all you're going to do tonight? Drink beer and sit
in front of that TV? You're nothing but a lazy, drunken, fat slob, and furthermore..."
The man sighs and says, "It's started".
===================
On a tour of Scotland, the Pope took a couple of days off his itinerary to visit the North West coast on
an impromptu sightseeing trip. His 4X4 Pope mobile was driving along the golden sands when there
was an enormous commotion heard just off the headland. They rushed to see what it was and upon
approaching the scene the Pope noticed just outside the surf, a hapless man wearing a English Rugby
jersey, struggling frantically to free himself from the jaws of a twenty-foot shark. At that moment a
speedboat containing three men wearing Scottish rugby tops roared into view from around the point.
Spontaneously, one of the men took aim and fired a harpoon into the shark's ribs, immobilizing it
instantly.
The other two reached out and pulled the Englishman from the water and then, using long clubs, beat
the shark to death. They bundled the bleeding, semi conscious man into the speedboat along with the
dead shark and then prepared for a hasty retreat, when they heard frantic shouting from the shore.
It was of course the Pope, and he summoned them to the beach. Upon them reaching the shore the
Pope went into raptures about the rescue and said, "I give you my blessing for your brave actions. I had
heard that there were some racist xenophobic people trying to divide Scotland and England, but now I
have seen with my own eyes this is not true. I can see that your society is a truly enlightened example of
racial harmony and could serve as a model on which other nations could follow."
He blessed them all and drove off in a cloud of dust. As he departed, the harpoonist asked the others,
"Who was that?"
"That," one answered, "was his Holiness the Pope. He is in direct contact with God and has access to all
God's wisdom."
-- - - - - - - -
"Well," the harpoonist replied, "he knows f--- all about shark hunting. How's that bait holding up or do
we need to get another one?"
======================
The most functional word in the English language is... Shit.
That's right, shit! Consider this:
You can be shit faced, shit out of luck, or have shit for
brains. With a little effort, you can get your shit together,
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (4 of 9) [23/03/2005 05:48:09 p.m.]
find a place for your shit or, decide to shit or get off the
pot.
You can smoke shit, buy shit, sell shit, lose shit, find shit,
forget shit, and tell others to eat shit and die. Some people
know their shit, while others can't tell the difference between
shit and Shinola.
There are lucky shits, dumb shits, crazy shits and sweet shits.
There is bull shit, horse shit and chicken shit. You can throw
shit, sling shit, catch shit, shoot the shit, or duck when shit
hits the fan.
You can give a shit or serve shit on a shingle. You can find
yourself in deep shit or be happier than a pig in shit. Some
days are colder than shit, some days are hotter than shit and
some days are just plain shitty.
Some music sounds like shit, things can look like shit, and
there are times when you feel like shit. You can have too much
shit, not enough shit, the right shit, the wrong shit or a lot
of weird shit.
You can carry shit, have a mountain of shit, or find yourself
up shit creek without a paddle. Sometimes everything you touch
turns to shit and other times you fall in a bucket of shit and
come out smelling like a rose.
When you stop to consider all the facts, it's the basic
building block of life. And remember, once you know your shit,
you don't need to know anything else.
Pass this along---if you give a shit
=========================
A GIRLS PRAYER
Lord,
Before I lay me down to sleep,
I pray for a man, who's not a creep,
One who's handsome, smart and strong,
One who's willy's thick and long.
One who thinks before he speaks,
When promises to call, he won't wait weeks.
I pray that he is gainfully employed,
And when I spend his cash, won't be annoyed.
Pulls out my chair and opens my door,
Massages my back and begs to do more.
Oh! Send me a man who will make love to my mind,
Knows just what to say, when I ask "How big's my behind?"
One who'll make love till my body's a twitchin'
In the hall, the bath tub, the garden and kitchen!
I pray that this man will love me no end,
And never attempt to shag my best friend.
And as I kneel and pray by my bed,
I look at the dickhead you sent me instead.
Amen.
************************************************
A BOYS PRAYER
Lord,
I pray for a girl with nice big tits.
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (5 of 9) [23/03/2005 05:48:09 p.m.]
Amen.
***********************************************
The Pope meets the cardinals to discuss a proposal from Ariel Sharon, the leader of Israel.
"Your Holiness" says one of the cardinals, "Mr Sharon wants to challenge you to a game of golf to show
the friendship and ecumenical spirit shared by the Jewish and Catholic faiths."
The Pope thinks that this is a good idea but he's never held a golf club.
"Isn't there a cardinal that can represent me?" he asked.
"Yes there's a man named Jack Nicklaus, an American golfer who's a devout Catholic. We can offer to
make him a cardinal then ask him to play Ariel Sharon as your personal representative. In addition, to
show our spirit of cooperation, we'll also win the match."
Everyone agrees it's a great idea.
The call is made. Of course Nicklaus is honoured and agrees to play.
The day after the match Nicklaus reports to the Vatican to inform the Pope of the result.
"I don't like to brag but I played the best golf ever. I must have been inspired from above. My drives
were long and true, my irons accurate and my putting was perfect. In fact my play was truly
miraculous."
"So you won then?" the Pope asked.
Nicklaus sighs. " No, your Holiness. I lost to Rabbi Woods by three strokes."
===================
Announcing a new device: Basic Orderly Organised Knowledge (BOOK)
The BOOK is a revolutionary breakthrough in technology: No wires, no electric circuits, no batteries,
nothing to be connected or switched on. It's so easy to use even a child can operate it. Just lift its
cover!
Compact and portable, it can be used anywhere - even sitting in an armchair by the fire - yet it is
powerful enough to hold as much information as a CD-ROM disc. Here's how it works...
Each BOOK is constructed of sequentially numbered sheets of paper (recyclable), each capable of
holding thousands of bits of information. These pages are locked together with a custom-fit device
called a binder which keeps the sheets in their correct sequence. Opaque Paper Technology (OPT)
allows manufacturers to use both sides of the sheet, doubling the information density and cutting costs
in half.
Experts are divided on the prospects for further increases in information density; for now BOOKs with
more information simply use more pages. This makes them thicker and harder to carry, and has drawn
some criticism from the mobile computing crowd.
Each sheet is scanned optically, registering information directly into your brain. A flick of the finger
takes you to the next sheet. The BOOK may be taken up at any time and used by merely opening it. The
BOOK never crashes and never needs rebooting, though like other display devices it can become
unusable if dropped overboard. The "browse" feature allows you to move instantly to any sheet, and
move forward or backward as you wish.
Many come with an "index" feature, which pinpoints the exact location of any selected information for
instant retrieval. An optional "BOOKmark" accessory allows you to open the BOOK to the exact place
you left it in a previous session -even if the BOOK has been closed. BOOKmarks fit universal design
standards; thus, a single BOOKmark can be used in BOOKs by various manufacturers. Conversely,
numerous BOOKmarks can be used in a single BOOK if the user wants to store numerous views at
once. T he number is limited only by the number of pages in the BOOK.
You can also make personal notes next to BOOK text entries with an optional programming tool, the
Portable Erasable Nib Cryptic Intercommunication Language Stylus (PENCILS).
Portable, durable, and affordable, the BOOK is being hailed as the entertainment wave of the future. The
BOOK's appeal seems so certain that thousands of content creators have committed to the platform.
Look for a flood of new titles soon.
"Borrowed" from the O'Byrne Files
==================
A: IF COMPUTER OPERATING SYSTEMS WERE LIKE BEERS...
1: DOS Beer
You need to use your own can opener, and it requires you to read the directions carefully before
opening the can. Originally only came in an 8-oz. can, but now comes in 16-oz. can. However, the can is
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (6 of 9) [23/03/2005 05:48:10 p.m.]
divided into 8 compartments of 2 oz. each, which have to be accessed separately. Soon to be
discontinued, although a lot of people are going to keep drinking it after it's no longer available.
2: Mac Beer
Initially came in only a 16-oz. can, but now comes in a 32-oz. can. Considered by many to be a "light"
beer. All the cans look identical. When you take one from the fridge, it opens itself. The ingredients list
is not on the can. If you call to ask about the ingredients, you are told that "you don't need to know." A
notice on the side reminds you to drag your empties to the trashcan.
3: Windows 3.1 Beer
Used to be the world's most popular. Claims it allows you to drink several DOS Beers simultaneously,
but in reality you can only drink a few of them, very slowly, especially if you are drinking the Windows
Beer at the same time. Sometimes, for apparently no reason, a can of Windows Beer will explode when
you open it.
4: Windows 95 Beer
Looks a lot like Mac Beer's can, but tastes more like Windows 3.1 Beer. It comes in 32-oz. cans, but
when you look inside, the cans only have 16 oz. of beer in them. Most people kept drinking Windows 3.1
Beer until their friends tried Windows 95 Beer and said they liked it. The ingredients list, when you look
at the small print, has some of the same ingredients that come in DOS beer, even though the
manufacturer claimed it was an entirely new brew.
Windows NT Beer
Comes in 32-oz. cans, but you can only buy it by the truckload. This causes most people to have to go
out and buy bigger fridges. The can looks just like Windows 3.1 Beer's, but then the company promised
to change the can to look just like Windows 95 Beer's. Touted as an "industrial strength" beer, and
suggested only for use in bars.
Unix Beer
Comes in several different brands, in cans ranging from 8 oz. to 64 oz. Drinkers of Unix Beer display
fierce brand loyalty, even though they claim that all the different brands taste almost identical.
Sometimes the pop-tops break off when you try to open them, so you have to have your own can opener
around for those occasions, in which case you either need a complete set of instructions, or a friend
who has been drinking Unix Beer for several years.
--------------------------------------------------------------------------------
B: IF COMPUTER OPERATING SYSTEMS WERE LIKE AIRLINES...
1: DOS Airlines
Passengers are handed maps, compasses, rulers, pencils, and an airplane manual (shrink- wrapped) as
they enter the plane. They have to figure out how to get the plane to wherever they want to go. Some
succeed very well. Others crash, but they shouldn't have been messing around with airplanes anyway.
2: Maclntosh Airlines
All the stewards, stewardesses, captains, baggage handlers, and ticket agents look the same, act the
same, and talk the same. Every time you ask questions about details, you are told you don't need to
know, don't want to know, and everything will be done for you without you having to know, so just shut
up.
3: OS/2 Airlines
If you succeed in getting on board the plane and the plane succeeds getting off the ground, you have a
wonderful trip ...
4: Windows Airlines
The airport terminal is nice and colorful, with friendly stewards and stewardesses, easy access to the
plane, and an uneventful takeoff... then the plane blows up without any warning whatsoever.
5: NT Airlines
Everyone marches out on the runway, says the password in unison, and forms the outline of a plane.
Then they all sit down and make a whooshing sound like they're flying.
6: UNIX Airlines
Everyone brings one piece of the plane with them when they come to the airport. They all go out on the
runway and put the plane together piece by piece, arguing constantly about what kind of plane they are
building.
==================
I went to the store the other day, I was only in there for about 5 minutes and when I came out there was
a copper writing a parking ticket.
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (7 of 9) [23/03/2005 05:48:10 p.m.]
So I went up to him and said, 'Come on man, how about giving a guy a break?'
He ignored me and continued writing the ticket.
So I called him a pencil necked nazi.
He glared at me and started writing another ticket for having bald tyres!!
So I called him a horse f*cker.
He finished the second ticket and put it on the car with the first.
Then he started writing a third ticket!!
This went on for about 20 minutes, the more I abused him, the more tickets
he wrote.
I didn't give a sh*t, my car was parked around the corner...
=====================
A blonde, wanting to earn some money, decided to hire herself out as a handy-woman' and started
canvassing a nearby well- to-do neighborhood. She went to the front door of the first house, and asked
the owner if he had any odd jobs for her to do.
"Well, you can paint my porch," he said, "How much will you charge me?"
The blonde, after looking about, responded, "How about $50?"
The man agreed and told her that the paint and other materials that she might need were in the garage.
The man's wife, inside the house, heard
the conversation and said to her husband, "Does she realize that the porch goes all the way around the
house?"
A short time later, the blonde came to the door to collect her money.
"You're finished already?" the husband asked.
"Yes," the blonde replied, "and I had paint left over, so I gave it two coats."
Impressed, the man reached into his pocket for the $50.00 and handed it to her.
"And by the way," the blonde added, "it's not a Porch, it's a BMW."
=============
Two Blonde woman were in the woods hunting. One looked at the other and said, "I've got to take a
sh*t."
The other said, "Well go behind one of those big trees, and sh*t."
The first one said, "But I don't have any paper to wipe my ass." The other blonde replied, "You have a
dollar, don't you?"
The first one said, "Yeah, I've got a dollar. That's a great idea- I'll use that!"
She left and came back with sh*t all over her hands and clothes.
Her friend looked at her and asked, "What in the hell happened to you?"
The first one replied, "Have you ever tried to wipe your ass with 3
quarters, 2 dimes, and a nickel?"
============
DUNCAN THE CRAB
Duncan the humble crab and Kate the Lobster Princess were madly, deeply, and passionately in love.
For months they enjoyed an idyllic relationship, until one day Kate scuttled over to Duncan in tears.
"We can't see each other anymore....." she sobbed.
"Why?" gasped Duncan.
"Daddy says that crabs are too common" she wailed. "He claims you are a mere crab, and a poor one at
that, and crabs are the lowest class of crustacean...and that no daughter of his will marry someone who
can only walk sideways."
Duncan was shattered, and scuttled sideward away into the darkness and to drink himself into a filthy
state of aquatic oblivion.
That night, the great Lobster ball was taking place. Lobsters came from far and wide, dancing and merry
making, but the Lobster Princess refused to join in, choosing instead to sit by her fathers side,
inconsolable.
Suddenly the doors burst open, and Duncan the crab strode in.
The Lobsters all stopped their dancing, the Princess gasped, and the King Lobster arose from his
throne. Slowly, painstakingly, Duncan the crab made his way across the floor...and all could see that he
was walking ... not sideways, but FORWARDS, one claw after another!
Step by step he made his approach towards the throne, until he finally looked the King Lobster in the
eye.
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (8 of 9) [23/03/2005 05:48:10 p.m.]
There was a deadly hush.....
For quite a while......
Finally, the crab spoke.....
"F*ck, I'm pissed."
Would you like the AfraLisp Newsletterdelivered to your desktop?
If so, then just enter your email address in the box below and press the "Submit" button.
Subscribe Unsubscribe
Powered by YourMailinglistProvider.com

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Utter Rubbish-Page III
http://www.afralisp.com/utterrubbish3.htm (9 of 9) [23/03/2005 05:48:10 p.m.]
Submit
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
"Utter Rubbish"
Page V
Some Car Stickers
1. Constipated People Dont Give A Shit.
2. Practice Safe Sex, Go Screw Yourself.
3. If You Drink Dont Park, Accidents Cause People.
4. Who Lit The Fuse On Your Tampon?
5. If You Dont Believe In Oral Sex, Keep Your Mouth Shut.
6. Please Tell Your Pants Its Not Polite To Point.
7. If That Phone Was Up Your Butt, Maybe You Could Drive A Little Better.
8. My Kid Got Your Honor Roll Student Pregnant.
9. Thank You For Pot Smoking.
10. To All You Virgins: Thanks For Nothing.
11. If At First You Dont Succeed...Blame Someone Else And Seek Counseling.
12. Impotence: Natures Way Of Saying No Hard Feelings.
13. If You Can Read This, Ive Lost My Trailer.
14. Horn Broken... Watch For Finger.
15. Its Not How You Pick Your Nose, But Where You Put The Booger.
16. If Youre Not A Hemorrhoid, Get Off My Ass.
17. Youre Just Jealous Because The Voices Are Talking To Me.
18. The Earth Is Full - Go Home.
19. I Have The Body Of A God ... Buddha.
20. This Would Be Really Funny If It Werent Happening To Me.
21. So Many Pedestrians-So Little Time.
22. Cleverly Disguised As A Responsible Adult.
23. If We Quit Voting Will They All Go Away?
24. The Face Is Familiar But I Cant Quite Remember My Name.
25. Eat Right, Exercise, Die Anyway.
26. Illiterate? Write For Help.
27. Honk If Anything Falls Off.
28. Cover Me, Im Changing Lanes.
29. He Who Hesitates Is Not Only Lost But Miles From The Next Exit
30. I Refuse To Have A Battle Of Wits With An Unarmed Person.
31. You! Out Of The Gene Pool!
32. I Do Whatever My Rice Krispies Tell Me To.
33. Where Are We Going And Why Am I In This Handbasket?
37. If Sex Is A Pain In The Ass, Then Youre Doing It Wrong...
38. Fight Crime: Shoot Back!
39. If You Can Read This, Please Flip Me Back Over...[Seen Upside Down On A Jeep]
40. Remember Folks: Stop Lights Timed For 35mph Are Also Timed For 70mph.
41. Guys: No Shirt, No Service. Gals: No Shirt, No Charge
42. If Walking Is So Good For You, then Why Does My Mailman Look Like Jabba The Hut?
43. Necrophilia: That Uncontrollable Urge To Crack Open A Cold One.
44. Ax Me About Ebonics.
45. Body By Nautilus; Brain By Mattel.
46. Boldly Going Nowhere.
47. Cat: The Other White Meat.
48. Caution-Driver Legally Blonde.
49. Dont Be Sexist-Bitches Hate That.
50. Heart Attacks...Gods Revenge For Eating His Animal Friends.
51. Honk If Youve Never Seen An Uzi Fired From A Car Window.
52. How Many Roads Must A Man Travel Down Before He Admits He is lost?
53. If You Cant Dazzle Them With Brilliance, Riddle Them With Bullets.
54. Money Isnt Everything, But It Sure Keeps The Kids In Touch.
55. Saw It...Wanted It...Had A Fit...Got It!
56. My Hockey Mom Can Beat Up Your Soccer Mom.
57. GROW YOUR OWN DOPE---PLANT A MAN.
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (1 of 9) [23/03/2005 05:48:11 p.m.]
58. All Men Are Animals, Some Just Make Better Pets.
59. Some people are only alive because it is illegal to shoot them.
60. I used to have a handle on life, but it broke.
61. WANTED: Meaningful overnight relationship.
62. BEER: Its not just for breakfast anymore.
63. So youre a feminist...Isnt that precious.
64. I need someone really bad...Are you really bad?
65. Beauty is in the eye of the beer holder.
66. Money Isnt The Most Important Thing, But It Rates Right Up There With Oxygen.
The Geography of a Woman
Between the ages of 18 - 21 a woman is like Africa or Australia.
She is half discovered, half wild, and naturally beautiful with bush
land around the fertile deltas.
Between the ages of 21 - 30 a woman is like America or Japan.
Completely discovered, very well developed and open to trade especially
with countries with cash or cars.
Between the ages of 30 - 35, she is like India or Spain. Very hot,
relaxed and convinced of its own beauty.
Between the ages of 35 - 40 a woman is like France or Argentina.
She may have been half destroyed during the war but can still be a warm
and desirable place to visit.
Between the ages of 40 - 50 she is like Yugoslavia or Iraq.
She lost the war and is haunted by past mistakes. Massive reconstruction
is now necessary.
Between the ages of 50 - 60 she is like Russia or Canada. Very wide,
quiet and the borders are practically unpatrolled but the frigid climate
keeps people away.
Between the ages of 60 - 70 a woman is like England or Mongolia.
With a glorious and all conquering past but alas no future.
After 70, they become Albania or Afghanistan. Everyone knows where it
is, but no one wants to go there.
The Geography of a Man
Between the ages of 15 - 70 a man is like Zimbabwe - ruled by a dick.
After a woman gave birth to her baby, the Doctor stood solemnly beside her bed.
There is something I must tell you about your baby.
"Whats wrong, the alarmed mother asked?
Your baby is a hermaphrodite.
Whats that?
It means your baby has both male and female parts.
Oh my God, thats wonderful!, the mother said, You mean it has a penis and a brain?
How to shower like a woman :
Take off clothing and place it in sectioned laundry basket according to
whites and coloured.
Walk to bathroom wearing long dressing gown.
If you see husband along the way, cover up any exposed areas.
Look at your womanly physique in the mirror - make mental note to do more
sit-ups.
Get in shower.
Use face cloth, arm cloth, leg cloth, long loofah, wide loofah and pumice
stone.
Wash hair once with cucumber and sage shampoo with 43 added vitamins.
Wash hair again to make sure it is clean.
Condition hair with grapefruit mint conditioner enhanced with natural
avocado oil, leave on hair for 15 minutes.
Wash face with crushed apricot facial, scrub for 10 minutes until red.
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (2 of 9) [23/03/2005 05:48:11 p.m.]
Wash entire rest of body with ginger-nut and jaffa cake body wash.
Shave armpits and legs.
Turn off shower.
Squeegee off all wet surfaces in shower, spray mould spots with Tilex.
Get out of shower.
Dry with towel the size of a small country.
Wrap hair in super absorbent towel.
Check entire body for spots, tweeze hairs.
Return to bedroom wearing long dressing gown and towel on head.
If you see husband along the way, cover any exposed areas.
How to Shower Like A Man :
Take off clothes while sitting on the edge of the bed.
Leave in a pile.
Walk naked to the bathroom.
If you see wife along the way, shake knob at her making woo-hoo sound
Look at manly physique in the mirror.
Admire size of your knob and scratch your ass.
Get in the shower.
Wash your face.
Wash your armpits.
Blow your nose in your hands and let the water rinse them off.
Make fart noises (real or artificial) and laugh at how loud they sound in
the shower.
Spend majority of time washing privates and surrounding area.
Wash your butt leaving those coarse hairs stuck on the soap.
Shampoo hair.
Make shampoo mohawk.
Pee.
Rinse off and get out of shower.
Partially dry-off.
Fail to notice water on floor.
Admire knob size in mirror again.
Leave sho wer door open, wet mat on floor, light and fan on.
Return to bedroom with towel around waist.
If you pass wife, pull off towel, shake knob at her and make woo-hoo noise
again.
Throw wet towel on bed.
"Knock Knock"
"Who's there?"
"Me, can I come in?"
"Sorry, we're closed".
Cannibal Jokes
Two cannibals are eating a clown. One says to the other, "Does this
taste funny to you?"
That reminds me of the cannibal that passed his friend in the woods.....
When do cannibals leave the table? When everyone's eaten.......
What is a cannibal's favorite type of TV show? A celebrity roast.....
What do cannibals eat for dessert? Chocolate covered aunts......
What do cannibals make out of politicians? Baloney sandwiches......
Have you heard about the cannibal restaurant? Dinner costs an arm and a
leg......
Did you hear about the cannibal who loved fast food? He ordered a
pizza with everybody on it.......
Cannibal's recipe book: How to Serve Your Fellow Man.......
One cannibal to another: I never met a man I didn't like...........
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (3 of 9) [23/03/2005 05:48:11 p.m.]
Two cannibals were sitting by a fire. The first says, "Gee, I hate my
mother-in-law." The 2nd replies, "So, try the potatoes."
The first cannibal asked the 2nd cannibal, "Aren't you done eating
yet?" The 2nd cannibal replied, "I'm on my last leg now."
While on his state visit to England, George Bush met The Queen, and he
turns round and says: "As I'm the President, I'm thinking of changing
how my great country is referred to, and I'm thinking that it should
be be a Kingdom."
The Queen replies "I'm sorry Mr Bush, but to be a Kingdom, you have to
have a King in charge - and you're not a King."
George Bush thought a while and then said: "How about a Principality
then?"
To which the Queen replied "Again, to be a Principality you have to be
a Prince - and you're not a Prince, Mr Bush."
Bush thought long and hard and came up with "How about an Empire then?
The Queen, getting a little annoyed by now, replies "Sorry again, Mr
Bush, but to be an Empire you must have an Emperor in charge - and you
are not an Emperor."
Before George Bush could utter another word, The Queen said: "I think
you're doing quite nicely as a Country."
Proudly showing off his new apartment to a couple of his friends late one night,
Kenny led the way to his bedroom where there was a brass gong.
"What's that big brass gong for?" one of the guests asked.
"Issss nod a gong. Issss a talking clock" Kenny replied.
"A talking clock? Seriouiouously?"
(burping) "Yup."
"Hmmm (hic)." "How's it work?" the second guest asked, squinting at it.
"Watch" Kenny said. He picked up a hammer, gave it an ear-shattering pound
and stepped back.
The three stood looking at one another for a moment in silence.
Suddenly, someone on the other side of the wall screamed
"For f**k's sake you w**ker, it's ten past three in the f**king morning!"
An advertisement in The Atlanta Journal received numerous calls:
SINGLE BLACK FEMALE seeks male companionship, ethnicity unimportant.
I'm a very good looking girl who LOVES to play. I love long walks in the woods,
riding in your pickup truck, hunting, camping and fishing trips, cozy winter nights
lying by the fire. Candlelight dinners will have me eating out of your hand.
Rub me the right way and watch me respond. I'll be at the front door when you
get home from work, wearing only what nature gave me.
Kiss me and I'm yours. Call (404) 875-6420 and ask for Topsy.
Over 15,000 men found themselves talking to the Atlanta Humane Society
about an 8-week old black Labrador retriever.
A large woman, wearing a sleeveless sundress, walked into a bar.
She raised her right arm, revealing a huge, hairy armpit.
She pointed to all the people sitting at the bar and asked,
What man here will buy a lady a drink?
The bar went silent as the patrons tried to ignore her.
But down at the end of the bar, an owly-eyed drunk slammed his
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (4 of 9) [23/03/2005 05:48:11 p.m.]
hand down on the counter and bellowed, Give the ballerina a drink!
The bartender poured the drink and the woman chugged it down.
She turned to the patrons and again pointed around at all of them,
revealing the same hairy armpit, and asked, What man here will buy
a lady a drink?
Once again, the same little drunk slapped his money down on the bar
and said, Give the ballerina another drink!
The bartender approached the little drunk and said,
I say old chap, its your business if you want to buy the lady a drink,
but why do you keep calling her the ballerina?
The drunk replied, Any woman who can lift her leg that high has to
be a ballerina!
Five cannibals get appointed as programmers in an IT company.
During the welcoming ceremony the boss says: Youre all part of our team now.
You can earn good money here, and you can go to the company canteen for
something to eat. So dont trouble the other employees.
The cannibals promise not to trouble the other employees.
Four weeks later the boss returns and says: Youre all working very hard,
and Im very satisfied with all of you. One of our cleaners has disappeared
however. Do any of you know what happened to her?
The cannibals disavow all knowledge of the missing cleaner.
After the boss has left, the leader of the cannibals says to the others:
Which of you idiots ate the cleaner?. A hand raises hesitantly, to
which the leader of the cannibals says: You fool! For four weeks
weve been eating Team Leaders, Managers, and Project Managers so
no-one would notice anything, and you have to go and eat the cleaner!
A man met a beautiful girl and she agreed to spend the night with
him for $500.00.
So they spent the night together. In the morning, before he left, he
told the girl that he did not have any cash with him, but that he would
have his secretary write a check and mail it to her, calling the payment "Rent
for Apartment." On the way to the office, he regretted what he had done,
realizing that the whole event was not worth the price.
So, he sent a cheque for $250.00 and enclosed a note :
Dear Madam:
Enclosed find a check in the amount of $250.00 for rent of your
apartment. I am not sending the amount agreed upon because when I rented the
apartment, I was under the impression that :
1. It had never been occupied.
2. There was plenty of heat.
3. It was small enough to make me cozy and at home.
Last night, however, I found out that it had been previously
occupied, that there wasn't any heat, and that it was entirely too large.
Upon receipt of the note, the girl immediately sent back the following reply:
Dear Sir:
First of all, I cannot understand how you expect such a beautiful
apartment to remain unoccupied indefinitely. As for the heat, there is
plenty of it if you know how to turn it on. Regarding the space, the
apartment is indeed of regular size, but if you don't have enough
furniture to fill it, please don't blame the landlord. I will expect full
payment due immediately or I will be forced to hire someone to remove your
furniture.
Q. What is the difference between a drug dealer and a hooker?
A. A hooker can wash her crack and sell it again.
Q. What's a mixed feeling?
A. When you see your mother-in-law backing off a cliff in your new car.
Q. What's the height of conceit?
A. Having an orgasm and calling out your own name.
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (5 of 9) [23/03/2005 05:48:11 p.m.]
Q. What's the definition of macho?
A. Jogging home from your vasectomy.
Q. What's the difference between a G-Spot and a golf ball?
A. A guy will actually search for a golf ball.
Q. Do you know how New Zealanders practice safe sex?
A. They spray paint X's on the back of the sheep that kick.
Q. What is a Yankee?
A. The same as a quickie, but a guy can do it alone.
Q. What do Tupperware and a walrus have in common?
A. They both like a tight seal.
Q. What do a Christmas tree and priest have in common?
A. Their balls are just for decoration.
Q. What is the difference between "ooooooh"and "aaaaaaah"?
A. About three inches.
Q. Why do Gay men wear ribbed condoms?
A. For traction in the mud.
Q: What's the difference between purple and pink?
A. The grip.
Q. How do you find a blind man in a nudist colony?
A. It's not hard.
Q: How do you circumcise a hillbilly?
A: Kick his sister in the jaw.
Q: Why do men find it difficult to make eye contact?
A: Breasts don't have eyes.
Q: If the dove is the bird of peace, what is the bird of true love?
A.The swallow.
Q: What is the difference between medium and rare?
A: Six inches is medium, eight inches is rare.
Q. Why do most women pay more attention to their appearance than Improving their minds?
A. Because most men are stupid but few are blind.
Q. Why do women rub their eyes when they get up in the morning?
A. They don't have balls to scratch.
A man is driving down a deserted stretch of highway when he notices a
sign out of the comer of his eye.....It reads:
SISTERS OF ST. FRANCIS
HOUSE OF PROSTITUTION
10 MILES
He thinks it was a figment of his imagination and drives on without a
second thought......Soon he sees another sign, which says:
SISTERS OF ST. FRANCIS
HOUSE OF PROSTITUTION
5 MILES
Suddenly, he begins to realize that these signs are for real....Then
he drives past a third sign saying:
SISTERS OF ST.FRANCIS
HOUSE OF PROSTITUTION
NEXT RIGHT
His curiosity gets the best of him and he pulls into the drive....On the
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (6 of 9) [23/03/2005 05:48:11 p.m.]
far side of the parking lot is a stone building with a small sign next
to
the door reading:
SISTERS OF ST. FRANCIS
He climbs the steps and rings the bell....The door is answered by a nun
in a long black habit who asks, "What may we do for you, my son?"....He
answers, "I saw your signs along the highway, and was interested in
possibly
doing business.".....
"Very well, my son. Please follow me." ....He is led through many
winding passages and is soon quite disoriented....The nun stops at a
closed door and tells the man, Please knock on this door".............
He does as he is told and another nun in a long habit, holding a tin
cup asnwers the door.....This nun instructs, "Please place $100 in the
cup,then go through the large wooden door at the end of this
hallway".......
He gets $100 out of his wallet and places it in the second nuns cup.....
He trots eagerly down the hall and slips throught the door, pulling it
shut behind him........
As the door locks behind him, he finds himself back in the parking lot,
facing another small sign:
GO IN PEACE.
YOU HAVE JUST BEEN
SCREWED BY THE
SISTERS OF ST. FRANCIS.
SERVES YOU RIGHT,
YOU SINNER.
A man is dining in a fancy restaurant, and there is a gorgeous
redhead sitting at the next table. He has been checking her out since
he sat down, but lacks the nerve to talk with her.
Suddenly she sneezes, and her glass eye comes flying out of its
socket towards the man. He reflexively reaches out, grabs it out of
the air, and hands it back.
"Oh, my, I am so sorry," the woman says as she pops her eye back in
place. "Let me buy your dinner to make it up to you."
They enjoy a wonderful dinner together, and afterwards the theater,
followed by drinks. They talk, they laugh, she shares her deepest
dreams and he shares his. She listens. After paying for everything,
she asks him if he would like to come to her place for a
nightcap.........and stay for breakfast.
The next morning, she cooks a gourmet meal with all the trimmings.
The guy is amazed!! Everything had been SO incredible!!!!
"You know," he says, "you are the perfect woman. Are you this nice to
every guy you meet?"
"No," she replies........."
Wait for it............
............
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (7 of 9) [23/03/2005 05:48:11 p.m.]
"........You just happened to catch my eye."
A woman was being sent to England to attend a two-week company training session.
Her husband drives her to the airport and wishes her to have a good trip.
The wife says, "Thank you honey, what would you like me to bring for you?"
The romantic husband smiles and says, "An English girl!"
The woman keeps quiet and bids him a loving good-bye hug and kiss.
Two weeks later husband came to collect her at the airport and asked,
"Honey, how was your trip?"
"Very good, thank you," she says.
The husband preparing for a romantic night continued,
"And, dear, what happened to my present?"
She asks, "What present?"
He winks and replies, "Remember what I asked for.... The English girl?"
"Oh, that?" the wife answers earnestly, "well, I did what I
could; now we have to wait a few months to see if it's really a girl!"
One day a guy died and found himself in hell. As he was wallowing in
despair, he had his first meeting with a demon.
The demon asked, "Why so glum?"
The guy responded, "What do you think? I'm in hell!"
"Hell's not so bad," the demon said. "We actually have a lot of fun
down here. You a drinking man?"
"Sure," the man said, "I love to drink."
"Well you're gonna love Mondays then. On Mondays all we do is drink.
Whiskey, tequila, Guinness, wine coolers, diet Tab and Fresca. We
drink till we throw up and then we drink some more!"
The guy is astounded. "Damn, that sounds great."
"You a smoker?" the demon asked.
"You better believe it!"
"You're gonna love Tuesdays. We get the finest cigars from all over
the world and smoke our lungs out. If you get cancer, no biggie. You're
already dead, remember?"
"Wow, the guy said, "that's awesome!"
The demon continued. "I bet you like to gamble."
"Why yes, as a matter of fact I do."
"Wednesdays you can gamble all you want. Craps, blackjack, roulette,
poker, slots, whatever. If you go bankrupt, well, you're dead anyhow. You
into drugs?"
The guy said, "Are you kidding? I love drugs! You don't mean . . ."
"That's right! Thursday is drug day. Help yourself to a great big bowl
of crack, or smack. Smoke a doobie the size of a submarine. You can do
all the drugs you want, you're dead, who cares!"
"Wow," the guy said, starting to feel better about his situation, "I
never realized Hell was such a cool place!"
The demon said, "You gay?"
"No."
"Ooooh, you're gonna hate Fridays!"

Utter Rubbish - Page IV


http://www.afralisp.com/utterrubbish4.htm (8 of 9) [23/03/2005 05:48:11 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Utter Rubbish - Page IV
http://www.afralisp.com/utterrubbish4.htm (9 of 9) [23/03/2005 05:48:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Aussie Sayings
IM HUNGRY
"I could eat the crotch out of a dead leper's undies."
"I could eat the horse and chase the jockey."
"So hungry I'd eat a shit sandwich, only I don't like bread."
"I could eat the arse out of a rag doll through a cane chair."
"So hungry I could eat the arse out of a low flying duck."
I'M THIRSTY
"I'm dry as a dead dingo's donger."
"I'm drier than a nuns nasty."
"I'm dry as a fuck with no foreplay."
"I'm as dry as a pommie's bath mat."
"I'm as dry as a bulls bum going up a hill backwards."
"I'm drier than an Arab's fart."
I NEED TO GO FOR A PEE
"Gonna drain me dragon."
"My back teeth are floating."
"Need to syphon the python."
"Takin' the kids to the pool."
"I got to take a snakes hiss."
"Gotta go have a slash."
"Gonna go water a horse."
"I'm off to drain the main vein."
"Time to splatter the bladder."
"I'm dying for a piss so bad I can taste it."
"Shake hands with the wife's best friend."
Aussie Sayings
http://www.afralisp.com/lisp/aussie.htm (1 of 4) [23/03/2005 05:48:13 p.m.]
I NEED TO DO A POO
"I gotta go give birth to a Kiwi."
"I'm takin' a stroll to the gravy bowl."
"It was like giving birth to Kim Beasly."
"Off to the bog to leave an offering."
"Time to snap off a grogan."
"Have to hang a brown bear in the porcelain cave."
"I'm gonna strangle a brownie."
"There's a brown dog barking at the back door."
"I'm going to give birth to your twin."
"Need to choke a brown dog."
"I've freed Nelson Mandela."
"Going for a Rodney."
"Taking out the garbage."
"I gotta back one out."
"Release the Chocolate hostage."
"i gotta lay some cables for Telstra."
VOMIT
"Calling for George.
"I was driving the porcelain bus this morning."
"I left him a lawn pizza."
"Toss a tiger on the carpet."
YES
"Does a fat dog fart?"
"Even Blind Freddy could see it."
"Is the Pope a Catholic?"
"Does a Koala shit in a gum tree and wipe his ass on a Cockatoo?"
"Does the Pope tuck his shirt in with a wooden spoon?"
"Bloody oath!"
"No wucking furries."
NO
"Pig's arse!!"
"Get Fucked!"
Aussie Sayings
http://www.afralisp.com/lisp/aussie.htm (2 of 4) [23/03/2005 05:48:13 p.m.]
INSULTS
"I hope your ears turn into arseholes and shit on your shoulders."
"Not enough brains to give 'imself a headache!"
"About as useful as tits on a bull."
"You must be the world's only living brain donor."
"He's a few wanks short of an orgasm."
"Shes had more pricks than a second hand dartboard."
"He had a head on him like a sucked mango."
"May your chooks turn into emus and kick your dunny down."
"He's got a few roos loose in the top paddock."
"So stupid that he wouldn't know a tram was up him 'til the bell rang!"
"Couldn't organise a piss-up in a brewery."
"Pull your lip over your head and swallow!"
"As ugly as a bucket full of arseholes."
"If I had a dog that looked like him, I'd shave it's arse and make it walk backwards."
"Got a face like a bashed in shit can."
"Couldn't tell his ass from a hole in the ground."
"Couldn't drive a greasy stick up a dog's arse."
"Couldn't organise a fuck in a brothel with a fist full of fifties."
"About as useful as a one-legged man in an arse-kicking competition."
"I'll kick your bum till your nose bleeds!"
"A stubbie short of a six pack."
"Seen better heads in a piss trough."
"You're as handy as shit on a stick."
"Tighter than a fish's arse."
"So tight that he wouldn't shout if a shark bit him."
"Face like a smashed crab."
"As ugly as a bulldog chewing a wasp."
"He could talk a dog off a meatwagon."
"Fucked in the head."
"You've got a head like a half-eaten pastie."
"He wouldn't go two rounds with a revolving door."
"Mate, shes as rough as a pigs breakfast."
"Your face is like a twisted Ugg boot."
"He's got a face like a cat licking shit off a thistle."
"She's been hit with the fugley stick too many times."
"She's two pick handles wide."
"An arse like two pigs fighting in a sugar bag."
"As ugly as a bag of spanners."
Aussie Sayings
http://www.afralisp.com/lisp/aussie.htm (3 of 4) [23/03/2005 05:48:13 p.m.]
"You've got a head like a dropped pie."
"He thinks his shit don' stink, but his farts give him away."
"I wish his dad had settled for a blow job."
"Fell out of the ugly tree, and hit every branch on the way down."
"If I had a head like yours I'd circumcise it."
"Wouldn't know if someone was up him sideways with an armful of deckchairs."
"As thick as two short planks!"
"You got a head like a busted watermelon."
COMPLIMENTS
"Ya bloods worth bottling!"
"He's True Blue."
"I'd be up her like a rat up a drain pipe."
"A better man never stood in two shoes!"
ASSORTED
"Drilling for Vegemite." (Anal sex)
"I'll have a super." (I'll have a beer)
"Make mine an unleaded." (I'll have a light beer)
"Going off like a frog in a sock." (try to picture this one)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Aussie Sayings
http://www.afralisp.com/lisp/aussie.htm (4 of 4) [23/03/2005 05:48:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
1. Choose a number between 1 and 9:
2. Type the name of a person you are really attracted to:
3. Type a color:
4. Type the name of your very first pet:
5. Type the names of two people you work with:

6. Now make a wish...
Fortune Teller
http://www.afralisp.com/fortunet.htm (1 of 2) [23/03/2005 05:48:14 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Fortune Teller
http://www.afralisp.com/fortunet.htm (2 of 2) [23/03/2005 05:48:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-01
=========================
Wednesday 7th January 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
I am lost.
I have gone to look for myself.
If I get back, before I return,
please tell me to wait.
=========================
The Front Stoep.
==============
Evening All and a Happy New Year to You and all Your Families.
I had a nice break. Lot's of beer, some good food and some more beer.
I've decided to start afresh this year, so all last years questions, topics,
discussions and arguments are now null and void.
So, if you've got something you'd like to discuss or complain about,
get those emails written and send them to yours truly.
Come on, hurry up I'm waiting.............!!!!!!
The AfraLisp Newsletter needs YOUR contributions.
============
John Walker visits South Africa
==========================
by Terry Baker
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (1 of 12) [23/03/2005 05:48:17 p.m.]
mailto:terry.baker@imaginet.co.za
Who is John Walker?
Way back in the latter part of the last century, about 1981, I guess,
a few guys decided to form a company, or association, called Autodesk.
The main guy was John Walker. Apart from 2 others, all of the initiators
of this project, eleven out of the 13 of the team, were part time.
(For those of you who, like me are not good at mathematics, this means
only 3 of them were full time employees.)
Anyhow, John Walker was the head hauncho. If you want all the correct facts,
read "The Autodesk File" by John Walker. I had a copy that I lent to someone
who never returned it to me, but you can download an electronic copy from the
web at http://www.fourmilab.ch/autofile/ .
From 1984 I started using AutoCAD and kept phoning the guys from Autodesk to
find out how to use the AutoCAD. Typically I phoned Richard Handyside in the UK,
and Duff Kurland in the USA. It was a real battle and a tough learning curve.
Not only was CAD a new product but so was computers, and I was only a draftie
and had no knowledge of either. These guys from Autodesk soon realised that it
may be better to get me to explain to other potential users how to use AutoCAD,
rather than have this "flood" of enquiries from a distant place in Africa.
So Autodesk started referring others to me for advice. Not long afterwards I started
selling AutoCAD and dropped the idea of actually producing drawings for a living.
That is how I got involved in selling AutoCAD.
People started getting greedy and tried to "grab" the distributorship for AutoCAD.
I was approached but declined the distributorship, being happy just to sell,
support and train.
I had numerous people phone me to say that I now had to buy AutoCAD
from them as they were the official AutoCAD distributor. Normally I would
just phone Autodesk to find out if this was true and it always turned out to
be false. This was until an architect by the name of Roberto Sandenburgh
contacted me and said she was going to see Autodesk. This she did and
came back with the distributorship. Roberta ran Acad Centre in South Africa
until her daughter, Margo took over running the company with Fernando
Pavon until they sold it in 1995.
It was in about 1992 that it was announced that the founder of Autodesk,
John Walker, was going to visit us in South Africa. By that time my original
Autodesk dealership, Infosoft, had merged with two other dealerships,
TechnoCAD and CadArt, to form the largest AutoCAD Dealership in Africa,
namely AFRACAD. The AutoCAD User Group was meeting at our premises in
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (2 of 12) [23/03/2005 05:48:17 p.m.]
Woodmead when John Walker paid us a visit. John addressed the user group
and the AutoCAD users were excited at the prospect of finally meeting their hero.
I took John to my office and showed him my original AutoCAD 360 kb 5 " floppy
disks with metal labels. John was amused and told me to keep them as they were
collectors items.
I still have those disks somewhere amongst my junk.
A few days later all the Autodesk Dealers went out to dinner at Sandton Sun Hotel
with John Walker as our guest. It was good to get to know John, and what a super
guy he is. Unfortunately his good wife could not accompany him on his visit as she,
being an Archeologist, was on assignment in Egypt at the time.
It was not long after that that John took the decision to give up the Chairmanship of
Autodesk and leave the running of the company to others. It had grown enormously
and was by then listed on NASDAQ. Visit John Walker's site http://www.fourmilab.ch
Oh, Kenny - Would you like my original 5 " floppy AutoCAD disks to auction off to
the highest bidder and use to fund your site?
If so I will try & find them for you. They may be good for beer money at least!!
Pearls of Wisdom
===============
I'm a little teapot short and stout,
here is my handle,
here is my...other handle?
Sh*t, I'm a sugar bowl!!
===============
Coding
=======
Thanks a lot your website and especially for the pages there regarding making resource
DLL files for menu icons: http://www.afralisp.com/vbaa/vba15.htm and
http://www.afralisp.com/vbaa/vbadll.htm. I've been searching for a way to eliminate
the smiley faces from my custom toolbars for some time. As I read thru the information
you provided, one thought kept coming up in my mind: "this has got to be a major pain
to do for anything more than just a few icons". I did a bit more research and discovered
an alterative way of doing things that saves you from the trouble of adding and renaming
the bitmaps one by one as you add them.
You do need Visual Basic for this technique.
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (3 of 12) [23/03/2005 05:48:17 p.m.]

Microsoft makes a resource compiler RC.EXE. With my copy of Visual Studio 6,
I have it in 2 places: one at
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\RC.EXE
and another at C:\Program Files\Microsoft Visual Studio\VB98\Wizards\RC.EXE.
They both appear to be identical. This resource compiler take a resource script (*.RC),
and generates a resource file (*.RES) that can be imported into a VB project.
So what we do is make a resource script like this:
BMP01 BITMAP Bitmap01.BMP
BMP02 BITMAP Bitmap02.bmp
BMP03 BITMAP Bitmap03.bmp
BMP04 BITMAP Sample.bmp
where the 1st item is the name of the bitmap as referenced in the MNU file, and the
last item is the name of the file. Note that the MNU reference does not need to be the
same as the file name, although you probably want to keep them the same for
organizational purposes. I'm not sure what the rules are for naming the bitmaps in
the MNU file, but I've had problems if they have special characters like spaces or
punctuation characters.

This resource file should be a plain text file and saved as a *.RC file. Then run the
resource compiler on it like this:
RC resource.rc
This will generate a file resource.res. If it fails, you can use a /v switch and it will
print out the name of each bitmap as it processes it so you can see where it fails.

After you have a resource file generated, follow the instructions on your original page
(http://www.afralisp.com/vbaa/vba15.htm) except instead of adding the bitmaps one
by one, choose Project | Add New Resource File and select the *.RES file you just created.
This adds them all in one single step and you are good to go.

Feel free to do whatever you want with with this (edit it, use it on your website or in
your newsletter or whatever). I just ask that if you put my name on it anywhere that
you don't put my e-mail address so it won't get harvested by spam-bots. I don't really
care if you credit me or not. Just consider it my way of giving you back a little for the
great service you provide on your website.
Tim Evans
=========
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (4 of 12) [23/03/2005 05:48:17 p.m.]
May be some need to calculate the area enclosed in a closed polygon.
here the code, may be you can include it in your tools :
;CODING STARTS HERE
;| This function calculate the area enclosed in each closed polygon
with the Green's Theorem
|;
(defun c:PolArea()
(setvar "cmdecho" 0)
(setq ele(entsel "\nSelect an Element: "))
(setq ele1(entget(car ele)))
; List with vertices
(setq vert(list))
(setq i 0)
(repeat (length ele1)
(setq ele2(nth i ele1)i(1+ i))
(if (= (car ele2) 10)
(progn
(setq vert(append vert(list (cdr ele2))))
(princ "\n")
(princ(cdr ele2))
)
)
)
(setq vert(append vert(list (car vert)))) ;last vertice is first one
;Calculate area
(setq are 0)
(setq i 0)
(repeat (1- (length vert))
(setq are(+ are
(-
(* (car(nth(1+ i)vert)) (cadr(nth i vert)) )

(* (car(nth i vert)) (cadr(nth(1+ i)vert)) )
)
)
)

(setq i(1+ i))
)
(setq are(abs(* are 0.5)))
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (5 of 12) [23/03/2005 05:48:17 p.m.]
(princ "\n")
(princ are)

(princ)
)
;CODING ENDS HERE
Erwin Hilb
=========
Kenny,
here is a fairly short VBA code snippet. We had a designer this week who was
having problems with drawing size 40+ Meg (normal for us, 700K or smaller).
This was after purging and cleaning out all of the anonymous blocks.
Eventually we found that he had tons of Text objects on his drawing with no
text in the value. One drawing had over 100,000 blank pieces of text (I
don't know how???).
Any how I ended up writing this code so he could "clean" his drawings on a
regular basis. The only problem we had with this code was when we tried it
on the 100,000+ text object drawing. Then we got an out of range error.
Add two command buttons to a form and copy this code into the code window.
(VBA)
Code starts here:
Private Sub CommandButton1_Click()
Clean_Text
End
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Public Sub Clean_Text()
Dim dwgnm As String
Dim shtnm As String
Dim SSget_Tblock As AcadSelectionSet
Dim Mode As Integer
Dim i As Integer
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (6 of 12) [23/03/2005 05:48:17 p.m.]
Dim Point1, Point2 As Variant
Dim Apnt1(0 To 2) As Double
Dim Apnt2(0 To 2) As Double
Mode = acSelectionSetAll

Apnt1(0) = 0: Apnt1(1) = 0: Apnt1(2) = 0
Apnt2(0) = 0: Apnt2(1) = 0: Apnt2(2) = 0
Point1 = Apnt1: Point2 = Apnt2
Dim Gpcode(0) As Integer
Dim Datavalue(0) As Variant
Gpcode(0) = 0
Datavalue(0) = "Text"
Dim GroupCode As Variant, DataCode As Variant
GroupCode = Gpcode
DataCode = Datavalue
txtcnt = 0
'select all text objects in drawing.
Randomize
Set ssetobj = ThisDrawing.SelectionSets.Add(Str(Rnd))
ssetobj.Select Mode, Point1, Point2, GroupCode, DataCode
Dim ssobjnum As Single
Dim ssobjnum2 As Single
Dim txtvalue As String
Dim txtvalue2 As String
For i = 0 To ssetobj.Count - 1
If ssetobj(i).TextString = "" Then
ssetobj(i).Erase
End If
Next i
ThisDrawing.PurgeAll
ThisDrawing.Application.Update
End Sub
Code end here
Robert Kerbo
===========
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (7 of 12) [23/03/2005 05:48:17 p.m.]
Things Weird and Wonderful
========================
You know if I had as small a sense of humor as those folks who don't enjoy my joking at poor
old Lisp's expense I might, in response to the "Ship High In Transit" joke respond with the
correct origin of that word.
The word sh*t entered modern English language derived from the Old English nouns scite
and the Middle Low German schite, both meaning "dung," and the Old English noun scitte,
meaning "diarrhea." Our most treasured cuss word has been with us a long time, showing
up in written works both as a noun and as a verb as far back as the 14th century.
Scite can trace its roots back to the proto-Germanic root skit-, which brought us the German
scheissen, Dutch schijten, Swedish skita, and Danish skide. Skit- comes from the Indo-European
root skheid- for "split, divide, separate," thus shit is distantly related to schism and schist.
(If you're wondering what a verb root for the act of separating one thing from another would
have to do with excrement, it was in the sense of the body's eliminating its waste --
"separating" from it, so to speak.
But of course I wouldn't go there.
Andy the cornbread
=================
Optical Illusions:
http://www.indianchild.com/3d%20mainpage.htm
========
Dr. Seuss as Technical Writer
If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report.
If your cursor finds a menu item followed by a dash,
and the double-clicking icon puts your window in the trash,
and your data is corrupted 'cause the index doesn't hash,
then your situation's hopeless and your system's gonna crash!
If the label on the cable on the table at your house,
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (8 of 12) [23/03/2005 05:48:17 p.m.]
says the network is connected to the button on your mouse,
but your packets want to tunnel on another protocol,
that's repeatedly rejected by the printer down the hall,
and your screen is all distorted by the side effects of gauss,
so your icons in the window are as wavy as a souse,
then you may as well reboot and go out with a bang,
'cause as sure as I'm a poet, the sucker's gonna hang!
When the copy of your floppy's getting sloppy on the disk,
And the microcode instructions cause unnecessary risc,
Then you have to flash your memory and you'll want to RAM your ROM
Quickly turn off the computer and be sure to tell your mom!
==========
Miscellaneous Stuff that I almost Forgot
================================
In the first quarter of 2004, CADzation will be releasing three new software programs
that will simplify the task of creating PDF and DWF files from a single suite of tools.
They are AcroPlot Pro, AcroPlot Matrix, and AcroPlot Auto. We are in final testing
of these products with selected CADzation customers and the results astounding.
Ever wanted to convert PLT, TIFF, CALS, and GP4 to PDF in a batch process?
AcroPlot Pro does it!
More--> http://www.cadzation.com/acroplotpro_info.htm
Ever need to open a PDF, reorder the pages, and insert a PLT or TIFF into it?
AcroPlot Matrix does it!
More--> http://www.cadzation.com/acroplotmatrix_info.htm
Looking for a way to convert 10,000 DWG's to PDF, make JPEG thumbnails,
and have it all post automatically to your web site? AcroPlot Auto does it!
More--> http://www.cadzation.com/acroplotauto_info.htm
CADzation has prerelease pricing for AcroPlot Pro at 25% off.
Buy it now and receive AcroPlot until it's released!
The Back Stoep
=============
EXCERPTS FROM A DOG'S DIARY
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (9 of 12) [23/03/2005 05:48:17 p.m.]
Day number 180, 181, 182, 183.. . . :
8:00 am - OH BOY! DOG FOOD! MY FAVORITE!
9:30 am- OH BOY! A CAR RIDE! MY FAVORITE!
9:40 am- OH BOY! A WALK! MY FAVORITE!
10:30 am- OH BOY! A CAR RIDE! MY FAVORITE!
12:00 noon- OH BOY! THE KIDS! MY FAVORITE!
1:00 pm- OH BOY! THE YARD! MY FAVORITE!
4:00 pm- OH BOY! THE KIDS! MY FAVORITE!
5:00 PM- OH BOY! DOG FOOD! MY FAVORITE!
5:30 PM- OH BOY! MOM! MY FAVORITE!
EXCERPTS FROM A CAT'S DIARY
DAY 752: My captors continue to taunt me with bizarre little dangling
objects. They dine on fresh meat, while I am forced to eat dry cereal.
The only thing that keeps me going is the hope of escape, and the
satisfaction of ruining the occasional piece of furniture. Tomorrow
I may eat another houseplant.
DAY 761 - Today I attempted to kill my captors by weaving around their
feet while they were walking and almost succeeded. Must try this at the top
of the stairs. In an attempt to disgust these vile oppressors, I made
myself vomit on their favorite chair... must try this on their bed.
DAY 766- Decapitated a mouse and brought them the headless body to make
them aware of what I am capable of, and to strike fear in their hearts. They
only cooed about what a good cat I was. Not working according to plan.
DAY 768- I am finally aware of how sadistic they are. For no reason I
was chosen for the water torture. This time it included a burning chemical
called "shampoo". What sick minds could invent such a liquid? My only
consolation is the piece of thumb still stuck between my teeth.
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (10 of 12) [23/03/2005 05:48:17 p.m.]
DAY 771 - There was a gathering of their accomplices. I was placed in
solitary throughout the event. However, I could smell the foul odor what
they call "beer". More importantly I overheard that my confinement was
due to my power of "allergies". Must learn what this is and how to use it to
my advantage.
DAY 774- I am convinced the other captives are flunkies and snitches.
The dog is routinely released and seems happy to return. He is obviously a
half-wit. The bird has got to be an informant, and speaks with them
regularly. I am certain he reports my every move. Due to his confinement
in the metal room, his safety is assured. But I can wait, it is only a
matter of time....
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If you can still hear the music, it's not loud enough!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-01


http://www.afralisp.com/newsletter/2004/2004-01.htm (11 of 12) [23/03/2005 05:48:17 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-01
http://www.afralisp.com/newsletter/2004/2004-01.htm (12 of 12) [23/03/2005 05:48:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-02
=========================
Tuesday 3rd February 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
The dumber people think you are,
the more surprised they'll be when you kill them!
=========================
The Front Stoep.
==============
"The Winds of Change are Blowing"
Big things happening in my life at the moment.
To early yet to tell you what's going on as things are still
very much up in the air.
Watch This Space...........
I receive some really weird emails sometimes.
I get a lot of people asking me all sorts of questions that
have really got nothing to do with AutoCAD, AutoLisp
or any type of coding for that matter.
Here's one of the best :
Kenny,
I am a sailor in the South African Navy. My parents live in the suburb of
Constantia and one of my sisters, who lives in Paarl North, is married to an
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (1 of 13) [23/03/2005 05:48:18 p.m.]
Australian. My father and mother have recently been arrested for growing and
selling marijuana and are currently dependent on my two sisters, who are
prostitutes in Green Point. I have two brothers, one who is currently
serving a non-parole life sentence in Pollsmoor Prison, Cape Town, for the
rape and murder of a teenage girl in 1994, the other is currently being held
in the Bellville remand centre on charges of incest with his three children.
I have recently become engaged to marry a former Thai prostitute who lives
in Sea Point and indeed is still a part time "working girl" in a brothel,
however, her time there is limited as she has recently been infected with an
STD. We intend to marry as soon as possible and are currently looking into
the possibility of opening our own brothel with my fiance utilizing her
knowledge of the industry working as the manager. I am hoping my two sisters
would be interested in joining our team.
Although I would prefer them not to prostitute themselves, it would at least
get them off the streets and hopefully the heroin.
My problem is this: I love my fiance and look forward to bringing her into
the family and of course I want to be totally honest with her. Should I
tell her about my brother-in-law being an Australian?
Pearls of Wisdom
===============
"I figured if I killed the first one, the word would get out."
- This is how I handled my teenage daughter's boyfriends.
===============
Coding
=======
Want a comfirmation box?
//DCL CODING STARTS HERE
yes_no_cancel : dialog {label="Confirmation";
spacer_1;
:boxed_column {
:paragraph {alignment=centered;
:text_part { height=3; width=50;
key="warning";alignment=centered;}
}
spacer;
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (2 of 13) [23/03/2005 05:48:18 p.m.]
}
spacer_1;
:row {alignment=centered;fixed_width=true;
children_fixed_width=true;
:button {label="&Yes";width=10;key="yes";
is_default=true;fixed_width=true;}
spacer_1;
:button {label="&No";width=10;key="no"
;fixed_width=true;}
spacer_1;
:button {label="&Cancel";width=10;key="cancel";
is_cancel=true;fixed_width=true;}
}
spacer;
}
//DCL CODING ENDS HERE
Save this as "Confirm.Dcl".
And now the AutoLisp coding :
;AUTOLISP CODING STARTS HERE
;(c)1999, Harjeet Singh
(defun yes_no_cancel (warn_text / dlg keyval)
(if (/= (type warn_text) 'STR)
(prompt "\nError: Argument supplied to YES_NO_CANCEL is not STRING."
) ;_ end of prompt
(progn (setq dlg (load_dialog "confirm"))
(new_dialog "yes_no_cancel" dlg)
(set_tile "warning" warn_text)
(action_tile "yes" "(setq keyval $key) (done_dialog)")
(action_tile "no" "(setq keyval $key) (done_dialog)")
(action_tile "cancel" "(setq keyval $key) (done_dialog)")
(start_dialog)
keyval
) ;progn
) ;if
) ;_ end of defun
;AUTOLISP CODING ENDS HERE
Save this as "Confirm.Lsp".
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (3 of 13) [23/03/2005 05:48:18 p.m.]
Usage :
(yes_no_cancel "Your Confirmation Message Goes Here")
This will return "Yes" "No" or "Cancel" as a string.
==============
Kenny,
I wish you and all the other creatures staying at your place a Happy and
Healthy New Year.
This mail is a reaction to the article in "the AfraLisp Newsletter No
2004-01" written by Robert Kerbo.
He has problems with cleaning up a drawing, and has written a nice little
program in VBA.
Great! Keep up the good work!!
I like programming to. Well, not VBA. I stick to the good old (Visual)
Lisp.
But it is silly (sorry Robert) to write a program to do a job AutoCAD is
perfectly capable of doing on its own .
AutoCAD has a perfectly good working command to do this job. It is called
ERASE.
It is one off my favourites. It gives me the oppertunity to smuggle my
errors. (Sssst. Don't tell my boss).
First I tell you the HOW, then I tell you the WHY.
The following is the condensation of an instruction session I had with a
colleague of mine.
Open a new drawing and make an empty text string.
Fill your drawing with a 100x1000 array off that empty text strings. You
can not make a bigger array, because 100.000 (one hunderd thousend) is a
historical limmit of AutoCAD and now obsolete.
Copy the matrix.
Okay, okay, I lead you by the hand in doing so.
You know how to make a text string. Do it. (If not, stop here and look for
another trade, eg. paving streets).
Still here? Oke, open the text string for edditing, and use backspace or
delete to obliterate all characters.
Next press the enter key, and you have a empty text string. (Is that
question also answered, Robert.)
Invoke array command. When selecting objects type ALL and then hit enter.
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (4 of 13) [23/03/2005 05:48:18 p.m.]
You have made a selection of one object. Finish the array command.
Invoke copy command. When selecting objects type ALL and then hit enter.
You have made a selection of hundred thousend objects. Finish the copy
command.
So, now you have 200.000 empty text strings in your drawing, even as you
don't see them.
He, you made them, remember? Have some fate in yourself. They are there.
To prove it: save your drawing and type DWGPROPS at the command prompt.
Your drawing will be about 12Mb in size.
Next put some objects in your drawing like lines, circels or text.
The whole purpose off this exercise is to remove invisible objects from a
drawing, right?
Lets remove them.
First of all switch all the layers that are turned off on.(One off the
first things you learned in your Basic AutoCAD Course).
Invoke the erase command.
When prompted to select the objects to delete type ALL at the command line
and hit enter. You made a selection off 200.000+ objects. (Great, no
limmits).
Deselect the visible objects you put in the drawing by holding down the
shift key while selecting these objects. You can do this by window and/or
crossing and/or picking. Now your selection have a size off 200.000
objects. (Remarkable, just the amount you put there in the first place).
Complete the erase command. (Hit enter, you ....).
Save the drawing and type DWGPROPS at the command prompt. Your drawing will
be about a lot smaller than 12Mb in size.
Q.E.F. (for the illiterate: Quod Erat Faciendum, What Had To Be Done).
But why does this method works?
When you open a drawing by AutoCAD the program will search the drawing file
for things to put on the screen. It is a drawing program, is it not?
It is not interested in what you can not see. It put the visible things in
the video memory of your computer for you to play with.
When you make a selection by windowing, crossing or picking, you are
selecting in the video memory, so, only visibiltys are selected.
You can not select what you can not see. (Yes, everything outside the
bounderies off your screen is also invisible).
To select also the invisible objects, that are not on a locked layer, you
have to type ALL at the command line. With this you tell AutoCAD to look in
the RAM memory and/or swapp file of the computer and make its selection
there, selecting everything that is not on a locked or frozen layer.
Do not forget to switch all layers to on!
You can not deselect what you can not see!
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (5 of 13) [23/03/2005 05:48:18 p.m.]
I hope, I made myself understood. My colleague got it, eventually.
Joop Moelee
============
Kenny,
I am using a script file to open and close a series drawings. The problem
is that some of the drawings may already be open and an extra line "Y" is
required in the script file to say "yes", open file as 'read-only'. The
problem is that the script file does not know ahead of time which files are
open. I may be able to work around this another way, but I was wondering
if there was a simple way of making a script file open all the required
drawings as 'read-only'? In his way the script file can be made the same
for all drawings even if they are open. (Is there a system variable that
can be set to force drawings to opened 'read-only'? It appears that there
may have been at one time, but these system variables have now been
removed.)
Regards
Craig Green
==========
Dear Kenny,
I would like to thank very much for giving me the opportunity to
consult you with things regarding AutoCAD.
I am a lisp programmer, and I was wondering how I would open
a drawing in a read-only state, using lisp or visual lisp functions.
Is that possible?
Awaiting your answer impatiently, I remain very truly yours,
Victor Jammal
============
Can you help??
The idea is to draw a pline at a specified width at any scale. Insert into
this pline at specified locations would be arrow heads so that in the end I
would have one continuous pline. I can get it to work by typing what I want
but it won't work in a macro. I can't get the angle specification to work
I can get the width and length of the arrow but not the angle.
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (6 of 13) [23/03/2005 05:48:18 p.m.]
Note userr1 is the drawing scale.
[ 90d ]'OSMODE;0;W;0;(* 1.5 (getvar "userr1"));(* 3.25 (getvar
"userr1"));(* pi (/ 90 180.0));w;0;0;'OSMODE;1;
thanks,
Kevin
=======
Want to draw a rectangle using AutoLisp?
;AUTOLISP CODE STARTS HERE
;Draw a rectangle using (polar) function
(defun C:RECT ()
(setq PT1 (getpoint "\nStart Point Lower Left: "))
(setq WTH (getdist "\nWidth: "))
(setq HGT (getdist "\nHeight: "))
(setq PT2 (polar PT1 0.0 WTH))
(setq PT3 (polar PT2 (* pi 0.5) HGT))
(setq PT4 (polar PT1 (* pi 0.5) HGT))
(command "._pline" PT1 PT2 PT3 PT4 "c")
)
(princ)
;AUTOLISP CODE ENDS HERE
Want to draw a rectangle using VBA?
'VBA CODE STARTS HERE
Sub Rect()
Dim VarRet As Variant
Dim PTS(0 To 7) As Double
Dim WTH As Double
Dim HGT As Double
Dim PLINE As Object

VarRet = Utility.GetPoint(, "Start Point Lower Left:")
PTS(0) = VarRet(0)
PTS(1) = VarRet(1)

WTH = Utility.GetDistance(, "Width: ")
HGT = Utility.GetDistance(, "Height: ")
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (7 of 13) [23/03/2005 05:48:18 p.m.]
VarRet = Utility.PolarPoint(VarRet, 0, WTH)
PTS(2) = VarRet(0)
PTS(3) = VarRet(1)
VarRet = Utility.PolarPoint(VarRet, 1.5708, HGT)
PTS(4) = VarRet(0)
PTS(5) = VarRet(1)
VarRet = Utility.PolarPoint(VarRet, 3.14159, WTH)
PTS(6) = VarRet(0)
PTS(7) = VarRet(1)
Set pline = ModelSpace.AddLightWeightPolyline(PTS)
pline.Closed = True ' Close Polyline
End Sub
'VBA CODE ENDS HERE
Things Weird and Wonderful
========================
To locate other ActiveX functions that create objects, you need to look
in the AutoCAD ActiveX and VBA Reference. In Visual LISP, choose Help,
Visual LISP Help Topics. From the Contents tab, double-click ActiveX and
VBA Reference, and then Methods. You immediately see an alphabetical
list with the As displayed. Here are all the VBA methods that add drawing
objects. To create a Visual LISP function, add VLA- before the method.
For example, to add a circle, you would use VLA-AddCircle.
============
Some useful Links :
Business Opportunity :
http://www.vbdesign.net/expresso/showthread.php?s=&postid=162183#post162183
The Back Stoep Online :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=64
AutoDesk VBA Newsgroup :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=66
AutoDesk Object ARX :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=68
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (8 of 13) [23/03/2005 05:48:18 p.m.]
Spanish Forum :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=18
Lost In Stupid Parenthetheeth :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=24
Guest Questions :
http://www.vbdesign.net/expresso/forumdisplay.php?s=&forumid=59
Gr-Acad - Portugeus :
http://www.gr-acad.arq.br/
CADLandia - Italian :
http://www.cadlandia.com/
Aussie CAD Links :
http://www.users.bigpond.com/johncoom/johncooc.html
Intervision - Danish :
http://intervision.hjem.wanadoo.dk/
Free Structural Software :
http://www.structural-engineering.fsnet.co.uk/free.htm
XCad - AutoCAD LT Utilities :
http://www.xcad.it/download/index.htm
AutoDesk Technical Papers :
http://www.fredrick.com/technicalsupport/ts_atods.html
AutoLisp Exchange :
http://web2.iadfw.net/terrycad/
AutoLisp Tutorials:
http://www.geocities.com/johno_iom/autolisp.html
The AutoCad Resource Website :
http://www.llpsite.com/
===========
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (9 of 13) [23/03/2005 05:48:18 p.m.]
Miscellaneous Stuff that I almost Forgot
================================
Hello,
I read your articles about making DLLs and would like to publish them on the site
of the dutch AutoCAD Architectural Desktop 2004 user group (www.adtggnl.nl).
Of course I will name you and your site. Is this ok with you or do you have
any restrictions?
Thanks,
H. Bosma
NHOLLAND University
============
Hi, I have read with interest your letter about John Walker, is a piece of
history.
In it I found the name of Roberta Sandenburgh, I would like to send her kind
regards. I had the pleasure to meet her in the TTT seminar given by Autodesk
in Sausalito 1989.
At that time I was managing the Autocad Training Center at Israeli Institute
of Productivity.
Also I would like to congratulate you and your staff for the good material
you gave us ,and continue with a prolific year.
Jacob Levy.
==========
When creating a slide library using the SLIDELIB utility you create a text file
containing the names of the slide files. SLIDELIB can read a listing created
using DOSs dir command with the /b parameter, which creates a simple listing
of just the file names. Therefore, you can place all the slide files in a folder and
redirect the dir listing to a file. For example, you can create a list named
afrasld.lst by typing the following at the DOS prompt: dir *.sld /b >afrasld.lst
The Back Stoep
=============
How to shower like a woman :
Take off clothing and place it in sectioned laundry basket according to
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (10 of 13) [23/03/2005 05:48:18 p.m.]
whites and coloured.
Walk to bathroom wearing long dressing gown.
If you see husband along the way, cover up any exposed areas.
Look at your womanly physique in the mirror - make mental note to do more
sit-ups.
Get in shower.
Use face cloth, arm cloth, leg cloth, long loofah, wide loofah and pumice
stone.
Wash hair once with cucumber and sage shampoo with 43 added vitamins.
Wash hair again to make sure it is clean.
Condition hair with grapefruit mint conditioner enhanced with natural
avocado oil, leave on hair for 15 minutes.
Wash face with crushed apricot facial, scrub for 10 minutes until red.
Wash entire rest of body with ginger-nut and jaffa cake body wash.
Shave armpits and legs.
Turn off shower.
Squeegee off all wet surfaces in shower, spray mould spots with Tilex.
Get out of shower.
Dry with towel the size of a small country.
Wrap hair in super absorbent towel.
Check entire body for spots, tweeze hairs.
Return to bedroom wearing long dressing gown and towel on head.
If you see husband along the way, cover any exposed areas.
How to Shower Like A Man :
Take off clothes while sitting on the edge of the bed.
Leave in a pile.
Walk naked to the bathroom.
If you see wife along the way, shake willy at her making woo-hoo sound.
Look at manly physique in the mirror.
Admire size of your willy and scratch your ass.
Get in the shower.
Wash your face.
Wash your armpits.
Blow your nose in your hands and let the water rinse them off.
Make fart noises (real or artificial) and laugh at how loud they sound in
the shower.
Spend majority of time washing privates and surrounding area.
Wash your butt leaving those coarse hairs stuck on the soap.
Shampoo hair.
Make shampoo mohawk.
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (11 of 13) [23/03/2005 05:48:18 p.m.]
Pee.
Rinse off and get out of shower.
Partially dry-off.
Fail to notice water on floor.
Admire willy size in mirror again.
Leave shower door open, wet mat on floor, light and fan on.
Return to bedroom with towel around waist.
If you pass wife, pull off towel, shake willy at her and make woo-hoo noise
again.
Throw wet towel on bed.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If you can still hear the music, it's not loud enough!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-02


http://www.afralisp.com/newsletter/2004/2004-02.htm (12 of 13) [23/03/2005 05:48:18 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-02
http://www.afralisp.com/newsletter/2004/2004-02.htm (13 of 13) [23/03/2005 05:48:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-03
=========================
Tuesday 10th February 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
I tried snorting coke the other day...
But I got an ice cube stuck in my nose.
=========================
The Front Stoep.
==============
Time to start having a closer look at Visual Basic and AutoCAD me thinks.
Over the next few weeks we'll be having a wee go at learning the basics of
Visual Basic. In fact to start with, we are not even going to mention AutoCAD
in any of the tutorials. Instead, we'll first have a look at some of the most
common and useful functions available in the VB stable. In this issue you'll
find an article entitled "File Functions in Visual Basic" which is part one
of a series leading to the development of a VB Drawing Backup routine.
Your feedback on this series of articles would be much appreciated.
========
Hey, I must tell you about this new restaurant I went to the other night.
Their claim to fame was that you could order anything you like and they
would provide it. Just to be difficult I ordered elephant testicles on toast.
The waiter took my order without any comment and disappeared, only
to return 10 minutes later to inform me that my order couldn't be filled as
they had ran out of toast.
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (1 of 12) [23/03/2005 05:48:20 p.m.]
What's New on AfraLisp?
====================
Lot's of Utter Rubbish added :
http://www.afralisp.com/utterrubbish4.htm
===================================
Pearls of Wisdom
===============
I bet a lot of mimes choke to death because
nobody believes they are really choking.
===============
Coding
=======
Hello Kenny,
For your friends Victor Jamal, and Craig Green (see below) in MDI
Mode... To open drawings as Read only.
;CODING STARTS HERE
(defun OpenReadOnly (strDrawingName)
(vl-cmdf "vbastmt"
(strcat "AcadApplication.Documents.Open \"" strDrawingName "\", TRUE")
)
)
;CODING ENDS HERE
Peter Jamtgaard
==============
Want to Wblock your entire drawing?
;CODING STARTS HERE
(defun c:al-wblock ()
(vl-load-com)
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (2 of 12) [23/03/2005 05:48:20 p.m.]
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))
(setq newSet (vla-add ssets "$Set"))

);progn
);if
;select all objects in the drawing
(vla-Select newSet acSelectionSetAll)
(vla-WBlock thisdrawing "c:/test.dwg" newSet)
(princ)
);defun
(princ)
;CODING ENDS HERE
=================
Would you like to visit AfraLisp?
;CODING STARTS HERE
(defun c:afralisp ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (3 of 12) [23/03/2005 05:48:20 p.m.]
(vlax-get-acad-object))))

(vla-LaunchBrowserDialog util 'theurl "AfraLisp Browser"
"Open" "http://www.afralisp.com" "ACADBROWSER" 1)
(princ theurl)
(princ)
);defun
(princ)
;CODING ENDS HERE
==================
Hi Kenny,

I liked the "Confirm" program in your last newsletter.
I have a variation on that one that buiilds the DCL code
dynamically so that you can code in any message that you want.
Jim Fisher
=========
;;AUTOLISP CODING STARTS HERE
;;
;; This program creates a multi-line dialog box, similar to the ALERT
;; function in AutoLISP, except that it contains both OK and CANCEL
;; buttons. Depending on the user selection, CONFIRM will return T or
;; nil, respectivly. The message passed is a text string, and can contain
;; the newline character (\n). If you pass the null string ("") as the
;; title argument, the program will use the default title of 'Confirm'
;;

(defun confirm (title msg / fn bkText txtList dh result)

(defun strPart (str sym side / a newstr)
(if (= (type str) 'STR)
(cond
((= side "l")
(setq
a (substr str 2 1)
newstr (substr str 1 1)
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (4 of 12) [23/03/2005 05:48:20 p.m.]
str (substr str 2)
)
(while (/= sym a)
(setq
newstr (strcat newstr (substr str 1 1))
str (substr str 2)
a (substr str 1 1)
)
)
(eval newstr)
)
((= side "r")
(setq
a (substr str 1 1)
str (substr str 2)
)
(while (/= sym a)
(setq
a (substr str 1 1)
str (substr str 2)
)
)
)
)
)
)

(defun makeDcl (fileName title textList / fh)
(if (= title "") (setq title " Confirm "))
(setq fh (open fileName "w"))
(write-line "confirm : dialog {" fh)
(write-line (strcat "label = \"" title "\";") fh)
(write-line "spacer_1;" fh)
(write-line ": paragraph {" fh)
(foreach item textList
(write-line
(strcat
": text_part {label = \""
item
"\";alignment = centered;}"
)
fh
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (5 of 12) [23/03/2005 05:48:20 p.m.]
)
)
(write-line "}" fh)
(write-line "spacer_1;" fh)
(write-line "ok_cancel;" fh)
(write-line "}" fh)
(close fh)
)

;;main function

(setq fn (strcat (getenv "temp") "\\confirm.dcl"))

(while (wcmatch msg "*\n*")
(setq
bkText (strPart msg "\n" "l")
msg (strPart msg "\n" "r")
txtList (cons bkText txtList)
)
)
(setq txtList (reverse (cons msg txtList)))

(makeDcl fn title txtList)

(setq dh (load_dialog fn))
(if (and dh (new_dialog "confirm" dh))
(progn
(if (= (start_dialog) 1)
(setq result 'T)
(setq result nil)
)
(unload_dialog dh)
result
)
)
)
;;AUTOLISP CODING ENDS HERE
===========================
Kenny,
I was trying to create a routine for autocad 2004 to allow me to draw a leader
by clicking on a toolbar button and draw the leader with no text.
I have tried to use the "leader" command along with three pauses for user
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (6 of 12) [23/03/2005 05:48:20 p.m.]
input and the "" "" "n" for no text. For some reason the leader command
doesn't like the pauses. I also tried getting the user input first by
(setq pt1 (getpoint "First point:")) and then for the next two points.
Then I would put the pt1, pt2, pt3 in place where I had the pauses and it
works but I see it before it draws the leader. I click the first point and there
is no visual reference to that point and the next and the next.
I tried (getpoint'(1 1)) but that doesn't work.

How can I get this to work? All I want to do is push a tool button and
draw a 3 point leader with no text. After the third point I want it to end.

I can get the "dim" "leader" to work but I want the arrowhead to be part
of the leader.

Thanks,
Andreas A. Pilson
==============
Things Weird and Wonderful
========================
Hi Kenny,
I am passing this on to you because it has definitely worked for me,
and at this time of year we all could use a little...calm!!!
By following the simple advice I read in an article,
I have finally found inner peace........the article read:
"The way to achieve inner peace is to finish all the things you've started."
So I looked around the house to see all the things I started and hadn't finished....
and before going to work this morning I finished off a bottle of red wine, a
bottle of white, the Bailey's, Kahlua and Tia Maria, my Prozac, some valium,
my cigarettes and a box of chocolates.
You have no idea how freakin good I feel....
You may pass this on to those you feel are in need of Inner Peace...
Regards,
Bill Storey
(In the cold north)
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (7 of 12) [23/03/2005 05:48:20 p.m.]
==============
Miscellaneous Stuff that I almost Forgot
================================
Circle H Drafting/ Design
====================
Without an imagination we
would all live under trees.
http://circlehdesign.homestead.com
Circle H Drafting/ Design/ Animation and has been in
business since January 2001. They do all kinds of drafting from Mechanical to
civil, but they specialize in Commercial and Residential.
They utilize Acad 2000 (which has Arch T included), Inventor 5.3, Mechanical
Desktop 6 (Power Pack), ADT 3.3, Acad 2004, and their premiere software in a
program called Solid Builder. They also utilize most of the Adobe line-up.
For their Animation projects they utilize both MAYA and 3D Studio Max.
All 6 of their machines are DELL Dimension 8300', with P-4 3 gig processors,
1.5 gig of Ram, 120 gig hard drives and running ATI Radian 9800 pro video
cards.
Interested? Then contact :
David & Rachel Hughes
mailto:circlehdesign@kc.rr.com
=====================
File Functions in Visual Basic - Part I
==============================
Dir$
===
One useful file function is the Dir$ function. This function works like the Dir
command at an MS-DOS command prompt. You can use the Dir$ function to retrieve
a list of one or more operating system files that match a file specification
or path. A path can include the name of a directory, a specific file name,
or both. For example, C:\*.DWG is the path to all the files in the root
directory of drive C having a DWG extension. The syntax of the Dir$ function
is as follows :
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (8 of 12) [23/03/2005 05:48:20 p.m.]
stringvar = Dir$(path[,attributes])
Finding Files
===========
One use of the Dir$ function is to determine whether a file exists. If you
try to open a database or access a file that does not exist, an error occurs.
However, you can use Dir$ first to check for a files existence before opening
it, as in the following example :
If Dir$("C:\MYFILE.DWG" = " " Then
Msgbox "The file was not found. Please try again!"
End If
The Dir$ function returns the filename without the full path if the specified
file is found, or it returns an empty string if no files were found.
The preceding line of code displays a message box if "MYFILE.DWG" does not
exist in the root directory of drive C. If the file does exist, the string
"myfile.dwg" is returned. To make things even simpler, you can create a generic
function that returns a Boolean value "True" if the given file exists.
Public Function bFileExists (Sfile As String) As Boolean
If Dir$(sFile) <> " " Then
bFileExists = True
Else
bFileExists = False
End Function
This function could then be used to check any filename passed to the program
by the user, as in the following example :
Dim sUserFile As String
sUserFile = InputBox$("Enter the File Name : ")
If Not bFileExists(sUserFile) Then
MsgBox "The file does not exist. Please try again."
End
End If
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (9 of 12) [23/03/2005 05:48:20 p.m.]
Notice that the code sample ends the program if the file does not exist,
to prevent any errors that might occur later. Another way to handle this
situation would be to keep asking the user for a filename until a valid
filename is entered.
Listing Files and Folders
====================
Another use of the Dir$ function is to return a list of files in the
specified path. If you use the Dir command at an MS DOS prompt, each
matching file is listed on the screen. However, because the Dir$ function
is designed to return only a single string
variable, you have to use a loop and retrieve one filename at a time.
(You can also display a list of files with a file list box, which is one
of Visual Basic's default controls.)
Suppose that your "C:\DRAWINGS" directory contains several drawings with
a "DWG" extension. The path used to retrieve these files with the Dir$
function would be "C:\DRAWINGS\*.DWG". You can use the following lines of
code to retrieve the filenames and add them to a list box :
sNextFile As String
sNextFile = Dir$("C:\DRAWINGS\*.DWG")
While sNextFile <> " "
lstDwgList.AddItem sNextFile
sNextFile = Dir$
Wend
In the preceding example, notice that only the file path to Dir$ is supplied
on the first call. Each subsequent call to Dir$ has no arguments, indicating
that you want to use the previous file path and move to the next filename in
the list. When no more files match, Dir$ returns an empty string and the
"While" loop terminates.
Caution : When you use Dir$ in a loop, always exit the loop after an empty
string is returned. If you try to make another call to Dir$ with no arguments,
a runtime error occurs.
The second, optional parameter of the Dir$ function is used to provide additional
conditions (beyond the specified path) with which to select files. For example,
using the constant "vbDirectory" returns only the subdirectories (or folders)
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (10 of 12) [23/03/2005 05:48:20 p.m.]
in the specified path. The constant "vbVolume" causes Dir$ to return the specified
drive's volume label. The available constants are summarized below :
vbNormal 0 (Default Value)
vbHidden 2 Include Hidden Files
vbSystem 4 Include System Files
vbVolume 8 Return Drive Volume Label
vbDirectory 16 Display SubDirectories
vbReadOnly 1 Include read-only files
Note : Constants can be added together if you want to use more than one.
For example, the following code finds the system, hidden and read only
file "IO.SYS" on a machine :
debug.Print Dir$("C:\IO.SYS" , vbHidden+vbSystem+vbReadOnly)
Note that the "vbHidden" constant refers to a file's attributes and not
the Windows Explorer option that hides certain file types.
==============================
(Second Part Next Week)
The Back Stoep
=============
A blonde girl enters a store that sells curtains. She tells the salesman :
"I would like to buy a pink curtain in the size of my computer screen."
The surprised salesman replies :
"But, madam, computers do not have curtains...."
And the blonde said: "Helloooo.... I've got Windows!!!!!!!!!!!!!!!"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Disclaimer :
Written by a highly caffeinated mammal.
---------------------------------------------------------
Did you miss a newsletter?
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (11 of 12) [23/03/2005 05:48:20 p.m.]
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-03
http://www.afralisp.com/newsletter/2004/2004-03.htm (12 of 12) [23/03/2005 05:48:20 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-04
=========================
Tuesday 17th February 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
I think animal testing is a terrible idea.
They get all nervous and give the wrong answers.
=========================
The Front Stoep.
==============
All is well with the world. It's 28 degrees C in this part of the world.
Still summer, but starting to slowly cool down for autumn.
A nice cold beer by my side and some exciting things about to happen.
But, I will say no more as I'm still awaiting final confirmation.
All will be revealed in good time.
Please be patient!!
Pearls of Wisdom
===============
"I thoroughly disapprove of duels. If someone should come up to me and
challenge me to a fight, I would take them kindly and forgivingly by hand,
lead them to a quiet place and kill them." - Mark Twain
===============
File Functions in Visual Basic - Part II
==============================
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (1 of 11) [23/03/2005 05:48:21 p.m.]
File Manipulation Functions
=======================
As with the Dir$ function, most of the file manipulation commands in
Visual Basic are as straightforward as their MS-DOS equivalents,
although with a few limitations. These commands are summarised below :
Copy a File "FileCopy" source dest
Delete one or more Files "Kill" path
Rename a File "Name" oldname As newname
Create a Folder "MkDir" pathname
Remove an empty Folder "RemDir" pathname
Change current directory "ChDir" pathname
Change current drive "ChDrive" drive
Several of these functions are described in the following sections :
Copying Files
===========
The "FileCopy" command has the limitation that you cannot use wildcards to
specify multiple files. "FileCopy" can copy files locally or over a network,
as shown in the following example :
'The following line copies a file while changing its name :
FileCopy "D:\DRAWING\TEST.DWG", "C:\BACKUP\TEST-BACK.DWG"
'The following lines of code use a network path for the source file :
Dim sDest As String
Dim sSource As String
sSource = "\\MYSERVER\DRAWINGS\TEST.DWG"
sDest = "C:\BACKUP\TEST-BACK.DWG"
FileCopy sSource, sDest
The "FileCopy" statement automatically overwrites an existing file,
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (2 of 11) [23/03/2005 05:48:21 p.m.]
unless the file is read-only or locked open by another application.
Deleting Files
============
Visual Basic also allows you to delete files by using the "Kill" statement.
"Kill" can use wildcards to specify multiple files, as in the following
example :
Kill "D:\DRAWINGS\*.DWG"
Renaming Files
==============
The "Name" statement is like the MS-DOS "RENAME" command but can be used on
only one file at a time :
Name oldname As newname
You can also use "Name" like the "MOVE" command in MS-DOS if the specified
paths are different :
'Moves the files to a new directory
MkDir "C:\BACKUP\TEST-BACK.DWG"
Name "D:\DRAWING\TEST.DWG" As "C:\BACKUP\TEST-BACK.DWG"
In the preceding example, note the "MkDir" statement, which you have
probably guessed is used to create a new directory. The "MkDir" and "RemDir"
statements add and remove directories.
Setting the Current Directory
========================
In the examples discussed so far, the path has always included the
drive and directory. However, as you may recall from using MS-DOS, during the
context of your MS-DOS session, you are always "in" a certain directory,
which is usually displayed to the left of the MS-DOS cursor. For example,
if you type CD \WINDOWS, you can rename, copy, or delete files within the
WINDOWS directory without specifying C:\WINDOWS in the pathname.
The same concept of a "current directory" applies to Visual Basic.
By using the "ChDir" and "ChDrive" statements, you can set the current
working directory on each drive and switch between current drives,
eliminating the need to specify the full path for each file operation :
'Change to the desired directory and drive and rename file
ChDir "C:\DRAWINGS"
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (3 of 11) [23/03/2005 05:48:21 p.m.]
ChDrive "C:"
Name "TEST1.DWG" As "TEST2.DWG"
'Delete a file in the current directory
ChDrive "D:"
ChDir "D:\DRAWINGS"
Kill "OLDTEST.DWG"
Performing deletes can be dangerous if you don't know the current directory.
Fortunately, Visual Basic offers a function that provides this value: the
"CurDir" function. The syntax of "CurDir" is :
stringvar = CurDir$([Drive])
Note - You can use the "Left$" function to get the current drive letter,
as in the following example :
sDriveLetter = Left$(CurDir$( ) , 1)
=============================
Okay, let's put this all together into a practical example.
Wouldn't it be nice to be able to backup all your drawings from your working
directory into a backup directory, either on another drive or to the network.
Have a look at this wee application, remembering to change the directory
paths to suit your own.
Open a new module and copy and paste this coding :
'VBA CODING STARTS HERE
Option Explicit
Sub Backup()
Dim sSourceDir As String
Dim sBackDir As String
Dim sNextFile As String
On Error GoTo FileCopyError
'Change these paths to suit.
sSourceDir = "C:\DRAWINGS\"
sBackDir = "D:\BACKUP\"
sNextFile = Dir$(sSourceDir & "*.DWG")
While sNextFile <> ""
FileCopy sSourceDir & sNextFile, sBackDir & sNextFile
sNextFile = Dir$
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (4 of 11) [23/03/2005 05:48:21 p.m.]
Wend
MsgBox "Drawing Backup Complete. Have a Nice Day."
Exit Sub
FileCopyError:
MsgBox "There was a problem copying the Drawings"
End
End Sub
'VBA CODING ENDS HERE
=====================
This, of course, could easily be expanded into a fully functional backup
routine with all the bells and whistles. I do though, have to leave you
with something to do!!
============
Unfortunately, the following will only work in Visual Basic and not with VBA.
Do you fancy drawing something using Visual Basic?
Create a new project and add a new form.
Now copy and paste this coding :
'VB CODING STARTS HERE
Private Sub Form_Click()
Const PI = 3.14159
Const ARCSIZE = 45
Dim X As Integer, Y As Integer, R As Integer
Dim arcstart As Single, arcend As Single
Dim nCount As Integer
X = Me.ScaleWidth / 2
Y = Me.ScaleHeight / 2
R = X / 2
Me.DrawMode = vbCopyPen
Me.FillStyle = vbFSTransparent
Me.Circle (X, Y), R
Me.DrawMode = vbXorPen
Me.FillColor = vbBlue
Me.FillStyle = vbSolid
For nCount = 0 To 360
arcstart = nCount
arcend = nCount + ARCSIZE
If arcend > 360 Then arcend = arcend - 360
Me.Caption = "Arc of " & ARCSIZE & " degrees starting at " _
& nCount
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (5 of 11) [23/03/2005 05:48:21 p.m.]
Circle (X, Y), R, , -acrstart * PI / 180, -arcend * PI / 180
DoEvents
Circle (X, Y), R, , -arcstart * PI / 180, -arcend * PI / 180
Next nCount
End Sub
'VB CODING ENDS HERE
=====================
Interesting Heh??
=====================
Coding
=======
This is the first time I email AfraLisp so let me start out by saying what a fantastic
web site it is. I've found so much useful information there.
Ok, now that I've buttered you up, I have a question. Is it possible to have a list
box or popup list box in DCL work similar to a combo box in VB(A). What I mean is,
I would like to be able to type in some text in a list box to add to the list.
Is that possible? If so, could you provide an example? If not, could you suggest
a workaround? Thanks again for an excellent web site,
Ron Baril
=========
Kenny
Question if i may
I'm running a VB program that opens autocad in batchplot function, ie opens
Autocad, Plots using predefined settings and then close's Autocad
and starts again.
My problem is that on the last Drawing file autocad stalls after plotting ie
it can't close out of autocad.
Is there away of closing autocad from VB..? or do i have to run the VB from
a Script which would have a Quit statement.
I would prefer to close from VB..???
any ideas would be great

Regards
Aidan Mc Neice
=============
Hi Kenny,
Is it possible to run a Unix program from an Excel application using VBA?
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (6 of 11) [23/03/2005 05:48:21 p.m.]
My work requires to :
1) FTP file from local machine to Unix
2) Check the file has been transferred successfully
3) Check the number of columns(it can be delimited by TAB or COMMA)
4) Run the Unix Program which uses the FTPed file
5) Once the Output is created, FTP is back to local machine
I can do steps 1,2,4,5. If not possible, I will have to use Jscript(& not Excel).
Thanks & regards
Prashant Jaiswal
===============
Hi Kenny. I was reading this last newsletter and read a question about a
leader in 2004.
I have one that might work for them. Here it is. I have one for a 3
point leader and a 2 point leader.
Of course they can modify this to be there layer standard and such.

ID_Leader_3_0 [_Button("Leader 3", "ldr3", "ldr3")]^C^C(setq clay(getvar "clayer"))
clayer;ldr;leader;non;\\\;;n;(setvar "clayer" clay)
ID_Quick_Leader_0 [_Button("Leader 2", "ldr2", "ldr2")]^C^C(setq clay(getvar "clayer"))
clayer;ldr;leader;non;\\;;n;(setvar "clayer" clay)
Thanks
Darek D. Watson
=============
Kenny,
I'm developing an application in Visual Basic 6.0 that will be installed on different
Windows operating systems. The application also references the Office object modules,
which I want to use to instantiate Word, Outlook and Excel. Visual Studio 6.0 has a
Package and Deployment Wizard, which creates an installation file containing all
the .ocx files etc. The problem I have is the fact that this package does not want to
install on platforms different than mine. The installation returns an error stating
that some files on the clients PC is outdated, and that they will be updated after a
reboot. This doesn't solve the problem though. How do I ensure that my application
is compatible with different setups than mine?
Colin Davies
===========
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (7 of 11) [23/03/2005 05:48:21 p.m.]
From last week :
Kenny,
I was trying to create a routine for autocad 2004 to allow me to draw a
leader by clicking on a toolbar button and draw the leader with no text.
Simple answer:
AutoCAD provides a command called "Qleader"
enter "Qleader" and go to "Settings"
and a dialog box pops up.
Select your options for how you want your leaders to look.
straight lines or splines
number of vertices
place text or not
any angle constraints, etc.
press OK and start placing leaders.
Robert Endres
============
Things Weird and Wonderful
========================
"DWF Writer." is a printer driver that allows any software package
to generate DWF files. Last week, Autodesk made the 5MB download
available officially from its own Web site at :
http://www.autodesk.com/dwfwriter (registration required).
=============
Want to create PDF's?
Check this out :
http://www.pdf995.com/index.html
============================
This is VERY interesting if you're into history :
http://www.evidenceincamera.co.uk
==============================
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (8 of 11) [23/03/2005 05:48:21 p.m.]
How's about a new compression program
http://www.7-zip.org/
Submitted by :
Troy Williams
Dangerous Subversive #386
======================
Miscellaneous Stuff that I almost Forgot
================================
A couple of new things on AfraLisp.
Scott McGlynn has kindly denoted a nice little application that will
Batch Convert Drawings to AutoCAD R14 format.
Well worth looking at as a basis for batch processing.
You can find it on the VBA Tutorial page :
http://www.afralisp.com/vba.htm
And from moi :
Hiding Dialogs Using VBA
http://www.afralisp.com/vba/vba-hide.htm
The Back Stoep
=============
The RedHead :
A young redhead goes into the doctor's office and says that her body hurts
wherever she touches it.
Impossible," says the doctor. "Show me."
She takes her finger and pushes her elbow and screams in agony.
She pushes her knee and screams, pushes her ankle and screams.
Everywhere she touches makes her scream.
The doctor says, "You're not really a redhead, are you?"
"No," she says, "I'm actually a blonde."
"I thought so," the doctor says. "Your finger is broken".
Tara the noo,
Kenny Ramage Q.B.E.
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (9 of 11) [23/03/2005 05:48:21 p.m.]
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Disclaimer :
Written by a highly caffeinated mammal.
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (10 of 11) [23/03/2005 05:48:21 p.m.]
Search
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-04
http://www.afralisp.com/newsletter/2004/2004-04.htm (11 of 11) [23/03/2005 05:48:21 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-05
=========================
Tuesday 24th February 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
A chicken crossing the road is poultry in motion.
=========================
The Front Stoep.
==============
I am officially working notice. As from the 15th of March I will be leaving my
present job and relocating somewhere. Where? Who knows as I have not
yet found another job. Could be Cape Town. Could be Jo'burg. Could be
Baghdad - should be lot's of work there.
Don't worry, the Newsletter and AfraLisp will continue as normal. Might even
get better if I don't have to work so hard during the day.
Any offers for a 47 year old Drawing Office/Systems Manager who tells good jokes
and is a connoisseur of beer?
========
By the way, did anyone notice that I numbered last weeks Newsletter wrongly?
No you didn't 'cos not one of you complained!!
Hellooooooo......Is there anybody out there??????
Pearls of Wisdom
===============
God does not play dice with the universe: He plays an ineffable game of His
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (1 of 12) [23/03/2005 05:48:23 p.m.]
own devising, which might be compared, from the perspective of any of the
other players [i.e. everybody], to being involved in an obscure and complex
variant of poker in a pitch-dark room, with blank cards, for infinite stakes,
with a Dealer who won't tell you the rules, and who smiles all the time.
Terry Pratchett & Neil Gaiman, Good Omens
===============
Coding
=======
Error Trapping
=============
As you are writing your code, Visual Basic informs you of syntactical errors.
However, once the program is running, you may encounter unexpected
runtime errors in many circumstances.
For example, suppose you try to open a text file that the user has deleted.
When a compiled program has an error like this, an error message is
displayed and the program ends.
Although you cannot predict and write code for every possible type of error,
"File Not Found" errors are fairly easy to handle. If you do not write code to
work around the error, you can at least provide a message that makes more
sense before ending the program.
The "On Error" Statement
======================
The most common way to handle error conditions is to use Visual Basic's
"On Error" statement.
The "On Error" statement interrupts the normal flow of your program when
an error occurs and begins executing your error handling code. A typical
use is as follows :
On Error Goto FileOpenError
When this statement is executed, any errors that occur in subsequent
statements cause Visual Basic to stop normal line-by-line execution and
jump to the statement labeled as "FileOpenError".
Labeling Code Lines
===================
Line labels in Visual Basic are similar to the line numbers of early BASIC.
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (2 of 12) [23/03/2005 05:48:23 p.m.]
In Visual Basic, line labels can include text if you want, but each label must
be unique. They are followed by a colon (:), as in the following example :
Private Sub Form_Load ()
On Error Goto FileOpenError
Open "C:\SOMEFILE.TXT" For Unput As #1
Line Input #1, sData
Exit Sub
FileOpenError:
MsgBox "There was a problem opening the file. Stop for coffee!"
End
End Sub
In the preceding sample code, if the "Open" or "Line Input" statements cause
an error, the statements starting at the label "FileOpenError" are executed,
causing the message to be displayed and ending the program.
You should note a few points about the sample code. First, note the location
and style of the error handling routine. It is usually placed near the end of the
subroutine, with the label not indented to indicate a special section of code.
Second, and more important, note the "Exit Sub" statement after the "Open"
statement. It is necessary to prevent the error handler routine from executing
even when the "Open" statement was successful.
Controlling Program Flow After an Error
=================================
In the preceding code example, you simply end the program if an error occurs.
However, you can handle the error in several (better) ways :
a) Exit the subroutine after informing the user of the error, and allow the program
to continue running with limited functionality.
b) Resume execution with the next statement following the error.
c) Provide a way for the user to correct the error and retry the offending statement.
You can also have multiple labels within a procedure and set the current error handler
multiple times. For example, you can add a line to the code sample after the "Open"
statement that specifies a new label, "FileInputError". You can also turn off error
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (3 of 12) [23/03/2005 05:48:23 p.m.]
handling with the following statement :
On Error Goto 0
The "On Error" statement goes hand in hand with the "Resume" statement. For example,
this statement causes errors to be ignored and the program to proceed through each line
of the code anyway :
On Error Resume Next
You should use the preceding line of code sparingly because it really just ignores
errors rather than handles them. A better use of "Resume" is to go to another section
of code. as in the following example :
Private Sub Form_Load ()
On Error Goto FileOpenError
RetryHere:
Open "C:\SOMEFILE.TXT" For Unput As #1
Line Input #1, sData
Exit Sub
FileOpenError:
Dim sMessage As String
sMessage = "There was a problem opening the file. " & VbCrLf
sMessage = sMessage & "Press Retry to try again, or Cancel to quit."
If MsgBox (sMessage, vbRetryCancel + vbCritical, "Error!") = vbRetry Then
Resume RetryHere
Else
End
End If
End Sub
========
You can though use "On Error Resume Next" if you are trying to connect to AutoCAD
from an external Visual Basic or other application :
'if error carry on with next line
On Error Resume Next
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (4 of 12) [23/03/2005 05:48:23 p.m.]
'set reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application.16")
'if there is an error (AutoCAD not open)
If Err Then
'clear the error
Err.Clear
'open AutoCAD
Set acadApp = CreateObject("Autocad.Application.16")
'setq reference to AutoCAD Application
Set acadApp = GetObject(, "AutoCAD.Application.16")
'if there is another error
If Err Then
'inform user
MsgBox Err.Description
'exit application
Exit Sub
End If
End If
=======
Next, set the document variable to the Document object in the AutoCAD
application. The Document object is returned by the ActiveDocument
property of the Application object.
Dim ThisDrawing as AcadDocument
Set ThisDrawing = acadApp.ActiveDocument
From this point on, use the "ThisDrawing" variable to reference the
current AutoCAD drawing just like AutoCAD VBA.
Determining The Type of Error
=========================
After an error has occurred, your code can find out more information about the
error in several ways :
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (5 of 12) [23/03/2005 05:48:23 p.m.]
a) Err - Contains a number that represents the error.
b) Error - Contains a string describing the error.
c) Err Object - Contains error number, description and additional information.
Also used to raise your own custom errors.
If you know how to recover from certain errors that may occur, you can use these
objects to respond intelligently to a specific error. In one of the previous examples, you
received a "File Not Found" error, which is number 53. You can easily add code
in the error handler to take appropriate action (that is, check another file) if the
value of "Err" is 53.
Hint : When you are writing an error handling routine with a message box,
display the error number and description in your message box to make
troubleshooting easier.
===================
Dear Kenny
Do you can me to help?
That is very important for me.

Working with (setq JoyObj (vlax-Create-Object " Scripting.FileSystemObject "))
and (setq JoyFile (vlax-invoke-method joyobj ' GetFile " c:\\autoexec.bat "))
I get #<VLA-OBJECT IFile 01f36c38>

Using the function below I get
_$ joysize
230
in Bytes
;;;_$ dateC
;;;37834.5
;;;_$ dateLM
;;;38001.7
;;;_$ DateLa
;;;38036.0

(defun JoyFileDate (obj /)
(setq JoySize (vlax-variant-value (vlax-get-property JoyFile 'Size)))
(setq dateC (vlax-get-property JoyFile 'DateCreated))
(setq dateLA (vlax-get-property JoyFile 'DateLastAccessed))
(setq dateLM (vlax-get-property JoyFile 'DateLastModified))
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (6 of 12) [23/03/2005 05:48:23 p.m.]
) ;_ fim de defun

How to convert DateC DateLA DateLM values for the pattern
Friday, August 1 of 2003 11:27:42
or 01/08/2003 11:27:42
or 08/01/03 11:27:42

Thank you very much
Sebastio
=========
Just use the FormatDateTime function :
FormatDateTime(DateCreated,2)
will show a short date in VbScript.
===================
I was wondering if you remember a couple of selection tools (in lisp I think)
called Freeze Entity & Thaw Entity? You could pick any number of entities &
it would put them on a layer called Freeze then freeze them. Thaw entity
would thaw them & return them to their original layers. You hade to be
careful because if you repeated freeze without thawing what was already
there they lost their original layer identity(s). The same would happen if you
left anything there when closing a drawing. I remember them from a few
years ago when using R14 & R15. I'm back using R15 because of where I'm
working & can't find them. They were actually pretty useful.

Thanks & best regards,
Eric Humrickhouse
================
Want to convert a Circle to a PolyCircle?
;CODING STARTS HERE
;Written By: Jason Piercey 07.31.01
;Revised: 01.16.02
(defun C:Cl2Pl (/ CirEnt CirElst CirCen CirRad
CirLay CirLin CirClr CirLts
PlineEnt
)
(while
(or
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (7 of 12) [23/03/2005 05:48:23 p.m.]
(not CirEnt)
(not (equal (assoc 0 (entget CirEnt)) '(0 . "CIRCLE")))
)

(setq CirEnt (car (entsel "\nSelect a Circle : ")))
)

(setq CirElst (entget CirEnt)
CirCen (cdr (assoc 10 CirElst))
CirRad (cdr (assoc 40 CirElst))
CirLay (cdr (assoc 8 CirElst))
CirLin (cdr (assoc 6 CirElst))
CirClr (cdr (assoc 62 CirElst))
CirLts (cdr (assoc 48 CirElst))
)

(setq PlineEnt (list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
(cons 8 CirLay)
'(100 . "AcDbPolyline")
'(90 . 2)
'(70 . 1)
'(43 . 0.0)
'(38 . 0.0)
'(39 . 0.0)
(cons 10 (polar CirCen (* pi) CirRad))
'(40 . 0.0)
'(41 . 0.0)
'(42 . 1.0)
(cons 10 (polar CirCen (* pi 2.0) CirRad))
'(40 . 0.0)
'(41 . 0.0)
'(42 . 1.0)
'(210 0.0 0.0 1.0)
)
)

(if CirLin (setq PlineEnt (append PlineEnt (list (cons 6 CirLin)))))
(if CirClr (setq PlineEnt (append PlineEnt (list (cons 62 CirClr)))))
(if CirLts (setq PlineEnt (append PlineEnt (list (cons 48 CirLts)))))
(entmake PlineEnt)
(entdel CirEnt)
(princ "\nCircle has been converted to a pline")
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (8 of 12) [23/03/2005 05:48:23 p.m.]
(princ)
)
;CODING ENDS HERE
=================
Things Weird and Wonderful
========================
Want an AutoCAD Drawing Viewer that can read R2004 drawings and it's free??
http://www.infograph.com/products/dwgviewer/
Unfortunately, you cannot print or plot a drawing unless you pay.
Devious swine's..............
=======================================
World's Easiest Quiz
=================
(Passing requires 4 correct answers)
1) How long did the Hundred Years War last?
2) Which country makes Panama hats?
3) From which animal do we get cat gut?
4) In which month do the Russians celebrate the October Revolution?
5) What is a camel's hair brush made of?
6) The Canary Islands in the Pacific are named after what animal?
7) What was King George VI's first name?
8) What color is a purple finch?
9) Where are Chinese gooseberries from?
Check your answers below in the Back Stoep!
=====================================
Miscellaneous Stuff that I almost Forgot
================================
The Top Twenty search phrases on AfraLisp :
1 vba tutorial
2 afralisp
3 AutoLISP
4 vba tutorials
5 LISP editor
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (9 of 12) [23/03/2005 05:48:23 p.m.]
6 visual lisp
7 autocad 2002 express tools
8 toolbar.dll
9 autocad 2004 express tools
10 powerpoint vba
11 autocad tutorial
12 plt extension
13 AcCleanReg2004.exe
14 lisp tutorial
15 vba primer
16 express tools 2004
17 autocad express tools download
18 vba read text file
19 VBA
20 .PLT extension
===============
And from Lee Ambrosius
http://hyperpics.com/ :
Environment Variables Quick Guide -
http://hyperpics.com/downloads/resources/customization/autolisp/
AutoCAD%20Environment%20Variable%20Quick%20Guide.pdf
Environment Variables General Overview -
http://hyperpics.com/downloads/resources/customization/autolisp/
AutoCAD%20Environment%20Variables.pdf
More from Lee himself, next week......
===============================
The Back Stoep
=============
19 ways to keep your insanity
1. At lunch time, sit in your parked car with sunglasses on and point
a hair dryer at passing cars. See if they slow down.
2. Page yourself over the intercom. Don't disguise your voice.
3. Every time someone asks you to do something, ask if they want fries
with that.
4. Put your garbage can on your desk and label it "IN".
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (10 of 12) [23/03/2005 05:48:23 p.m.]
5. Put decaf in the coffee maker for 3 weeks. Once everyone has gotten
over their caffeine
addictions, switch to espresso.
6. In the memo field of all your checks, write "for sexual favous".
7. Finish all your sentences with "in accordance with the prophesy".
8. Dont use any punctuation marks.
9. As often as possible, skip rather than walk.
10. Ask people what sex they are. Laugh hysterically after they answer.
11. Specify that your drive-through order is "to go".
12. Sing along at the opera.
13. Go to a poetry recital and ask why the poems don't rhyme.
14. Put mosquito netting around your work area. Play a tape of jungle sounds all day.
15. Five days in advance, tell your friends you can't attend their party because you're
not in the mood.
16. Have your coworkers address you by your wrestling name, Rock Hard Kim.
17. When the money comes out the ATM, scream "I won!", "I won!" "3rd time this week!!!!!"
18. When leaving the zoo, start running towards the parking lot, yelling run for your lives,
they're loose!!"
19. Tell your children over dinner. "Due to the economy, we are going to have to let one of
you go."
==========
Answers To World's Easiest Quiz
===========================
1) How long did the Hundred Years War last? = 116 years
2) Which country makes Panama hats? = Ecuador
3) From which animal do we get cat gut? = Sheep and Horses
4) In which month do Russians celebrate the October Revolution? = November
5) What is a camel's hair brush made of? =Squirrel fur
6) The Canary Islands in the Pacific are named after what animal? =Dogs
7) What was King George VI's first name? = Albert
8) What color is a purple finch? = Crimson
9) Where are Chinese gooseberries from? = New Zealand
What do you mean you failed?
==========================
Tara the noo,
Kenny Ramage Q.B.E.
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (11 of 12) [23/03/2005 05:48:23 p.m.]
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Disclaimer :
Written by a highly caffeinated mammal.
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-05
http://www.afralisp.com/newsletter/2004/2004-05.htm (12 of 12) [23/03/2005 05:48:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-06
=========================
Tuesday 2nd March 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
If it weren't for physics and law enforcement,
I'd be unstoppable.
=========================
The Front Stoep.
==============
Is it my imagination or is my mailbox getting smaller? I don't seem to
receive half as much email as I used too, especially email answering
questions that appear in this here publication, or emails with nice little
AutoLisp or VBA routines that other subscribers would find interesting.
Strange! Maybe it's something to do with global warming or the price
of corned beef in Outer Mongolia. Anyway, not to worry as I'm sure you
will all help and start pecking away at your keyboards and sending
interesting and informative material to Kenny.
I mean, he can't do it all himself............ All the time..........
By the way, anybody feel like commenting on the Visual Basic articles???
Pearls of Wisdom
===============
The History exam was a piece of cake -- which was a bit of a surprise
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (1 of 11) [23/03/2005 05:48:25 p.m.]
actually, because I was expecting some questions on a sheet of paper.
===============
A Letter From Randall Rath
=======================
Hello!
This is really nothing more than an invitation.
To what?
CORBIMITE/VB Design's solution to the AUGI Guild/Forum problem!
I have created a set of forums that address ALL of the major issues
presented by current and ex-guild members (now moving over to
alternate resources) and I want to ask all of you to inspect what we
(Frank Zander & I) have built and to post/e-mail your opinions. comments,
and feedback. I really believe that this is the solution - it gives AUGI
a way to meet their obligations and Guild members a way to
post/track/reply via e-mail!
The site is located at:
http://www.acaduser.com
Everyone on this mailing list is welcome to register! Once you see it,
I'm certain that you will agree that this is the way to bring forums to
the Guilds and Web hosting to AUGI - Please feel free to post
comments/opinions in the forums - and, if you wonder about the use
of the AUGI title and graphics, They are fully aware of what we are doing!

Coding
=======
The following is published here with the kind permission of Lee Ambrosius :
http://hyperpics.com/
Please be aware of word wrap when cutting and pasting.
Creating a Custom Double Click Edit
==============================
(AutoCAD 2000i and higher)
This example is used to demonstrate how you can replace the standard
functionality of the Double Click Editing inside of AutoCAD of your own
handler. This allows for changing the default editors and the way objects
are handled.
Module Code - All code should be placed in the class module called ThisDrawing.
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (2 of 11) [23/03/2005 05:48:25 p.m.]
Option Explicit
'' The program is provided AS IS with no expressed written warranty
'' Copyright 2003 - HyperPics
''
'' You can freely use this code for personal use and as long as you
'' keep the reference to the original author in place. This code can not be used
'' in a commercial for sale product without written consent from the original
'' author.
''
'' Created by Lee Ambrosius (lee_ambrosius@hyperpics.com)
'' HyperPics.com
''
'' Created on 03/06/03
''
'' Last updated 05/07/03
'' - Corrected minor problem with behavior that was undone and removed
" double click problem
'' when nothing was selected in the drawing
''
'' Updated 05/06/03
'' - Corrected minor problem with single editor objects that got disabled
" when making change for
'' multiple objects from update done on 5/05/03
''
'' Update - 05/05/03
'' - Corrected problem with deselecting lines and other specific objects
" not covered in conditionals
'' - Added support for the PickFirst System Variable. If PickFirst = 0 then
" nothing happens
'' - Added support for single object selection conditional so it works like
" the standard
'' Double Click functionality of AutoCAD.
''
'' Update - 03/10/03
'' - Corrected UCS problem with it being rotated and reporting the
" coordinates in correctly
''
'' Update - 03/07/03
'' - Added support for all Dim objects
'' - Xref support was enhanced to work with Absolute, Relative and No Path options
'' - Rtext support if the Rtext.arx is loaded
'' - Added support for 2002 and 2004 to use the Enhanced Attribute box
'' - Added Z point value to point
'' - Attribute Definition
'' - Text
'' - Polyline
'' - Spline
'' - Mline
''
'' What do you need?
'' Windows 98 or higher
'' I.E. 5 or higher
'' Microsoft Script Host 5.6 (recommended)
'' AutoCAD 2000i or higher
''
'' How to use:
'' DblkClkEdit needs to be set to Off in AutoCAD. Paste the code into the
'' ThisDrawing class module inside of the VBAIDE.
Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)
If CStr(ThisDrawing.GetVariable("PICKFIRST")) = "1" Then
Dim acadObj As AcadObject
Dim ssetObj As AcadSelectionSet
On Error Resume Next
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (3 of 11) [23/03/2005 05:48:25 p.m.]
Set ssetObj = ThisDrawing.SelectionSets.Add("MySSet")
If Err <> 0 Then
Set ssetObj = ThisDrawing.SelectionSets.Item("MySSet")
Err.Clear
End If
Set ssetObj = ThisDrawing.PickfirstSelectionSet
If ssetObj.Count = 1 Then
PickPoint = ThisDrawing.Utility.TranslateCoordinates(PickPoint, acWorld, acUCS, False)
Dim blkObj As AcadBlockReference
Dim exBlkObj As AcadExternalReference
'' Grab each object out of the selection set
For Each acadObj In ssetObj
'' Push to the Immediate Window the Object Name
Debug.Print acadObj.ObjectName
If acadObj.ObjectName = "AcDbRotatedDimension" Then ' Rotated Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbAlignedDimension" Then ' Aligned Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbDiametricDimension" Then ' Diameter Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbRadialDimension" Then ' Radius Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDb2LineAngularDimension" And acadObj.ObjectName = "AcDb3LineAngularDimension" Then ' Angular Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbOrdinateDimension" Then ' Ordinate Dimension
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbFcf" Then ' Tolerance
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbMText" Then ' Multi-line Text
ThisDrawing.SendCommand "._Mtedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbText" Then ' Text
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "RText" Then ' Remote Text - Edit
'' Get the list of loaded ObjectARX applications
Dim arxList As Variant, bArxFlag As Boolean
arxList = ThisDrawing.Application.ListArx
bArxFlag = False
'' Loop through the array
If VarType(arxList) <> vbEmpty Then
Dim I As Integer
For I = LBound(arxList) To UBound(arxList)
If UCase(arxList(I)) = "RTEXT.ARX" Then
bArxFlag = True
End If
Next
End If
'' If the flag is true then Remote Text Express Tool is loaded
If bArxFlag = True Then
ThisDrawing.SendCommand "._Rtedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " E "
End If
ElseIf acadObj.ObjectName = "AcDbAttributeDefinition" Then ' Attribute not in block
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (4 of 11) [23/03/2005 05:48:25 p.m.]
ThisDrawing.SendCommand "._DDedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbHatch" Then ' Hatch
ThisDrawing.SendCommand "._hatchedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbPolyline" Then ' Ployline
ThisDrawing.SendCommand "._Pedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbSpline" Then ' Spline
ThisDrawing.SendCommand "._Splinedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbMline" Then ' Mline
ThisDrawing.SendCommand "._Mledit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
ElseIf acadObj.ObjectName = "AcDbBlockReference" Then ' Block Insert or External Reference
Set blkObj = acadObj
On Error GoTo NoXref
Set exBlkObj = acadObj
Xref:
'' Xref can have or not have attributes
If exBlkObj.HasAttributes Then
'' Reference to enhanced Attribute editor - R2002 and 2004
If Left(ThisDrawing.GetVariable("ACADVER"), 5) = "15.06" Or Left(ThisDrawing.
GetVariable("ACADVER"), 3) = "16.0" Then
ssetObj.SelectAtPoint PickPoint
ThisDrawing.SendCommand "._Eattedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
Else '' Reference to old Attribute editor - R2000i
ssetObj.SelectAtPoint PickPoint
ThisDrawing.SendCommand "._Ddatte " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
End If
Else
Dim Msg As String
Dim Response As Integer
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Msg = "Do you want to open this Xref?" + vbCr + "Block Name: " + exBlkObj.Name + vbCr
If fso.fileexists(ThisDrawing.Path & "\" & exBlkObj.Path) = True Then
Msg = Msg + "Xref Path: " + ThisDrawing.Path + "\" & exBlkObj.Path
ElseIf fso.fileexists(exBlkObj.Path) = True Then
Msg = Msg + "Xref Path: " + exBlkObj.Path
End If
Response = MsgBox(Msg, vbYesNo + vbQuestion + vbDefaultButton1, "Open Xref")
If Response = vbYes Then ' User choose Yes.
If CInt(ThisDrawing.GetVariable("SDI")) = 0 Then 'Check for MDE
If fso.fileexists(ThisDrawing.Path & "\" & exBlkObj.Path) = True Then
ThisDrawing.Application.Documents.Open ThisDrawing.Path & "\" & exBlkObj.Path
ElseIf fso.fileexists(exBlkObj.Path) = True Then
ThisDrawing.Application.Documents.Open exBlkObj.Path
End If
Else
If fso.fileexists(ThisDrawing.Path & "\" & exBlkObj.Path) = True Then
ThisDrawing.Open ThisDrawing.Path & "\" & exBlkObj.Path
ElseIf fso.fileexists(exBlkObj.Path) = True Then
ThisDrawing.Open exBlkObj.Path
End If
End If
Else ' User choose No.
GoTo EndBlock
End If
End If
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (5 of 11) [23/03/2005 05:48:25 p.m.]
Set fso = Nothing
GoTo EndBlock
NoXref:
'' Block can have or not have attributes
If blkObj.HasAttributes Then
'' Reference to enhanced Attribute editor - R2002 and 2004
If Left(ThisDrawing.GetVariable("ACADVER"), 5) = "15.06" Or Left(ThisDrawing.
GetVariable("ACADVER"), 4) = "16.0" Then
ssetObj.SelectAtPoint PickPoint
ThisDrawing.SendCommand "._Eattedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
Else '' Reference to old Attribute editor - R2000i
ssetObj.SelectAtPoint PickPoint
ThisDrawing.SendCommand "._Ddatte " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
End If
Else
ssetObj.SelectAtPoint PickPoint
ThisDrawing.SendCommand "._Refedit " & CStr(PickPoint(0)) & "," & CStr(PickPoint(1)) &
"," & CStr(PickPoint(2)) & " "
End If
EndBlock:
Else ' Other objects not handled above
ThisDrawing.SendCommand "'._properties "
End If
Next
ElseIf ssetObj.Count > 1 Then
ThisDrawing.SendCommand "'._properties "
End If
'' Delete Selection Set
ssetObj.Delete
End If
End Sub
=============
Thank you Lee.
The original source code can be download from Lee's site if you so wish :
http://hyperpics.com/
===================
Kenny,
Our office has just swapped over to AutoCAD 2004. I was wondering if you or anyone
else knows of a good replacement for the old 'AutoCAD Today' feature which has been
removed in this new version.
I know must people didn't like it, but I found 'AutoCAD Today' absolutely invaluable
for keeping track of the many drawings in the many projects we work on. I really feel
lost without it and I am VERY upset that it has been removed. With 'AutoCAD Today'
I could quickly see all the drawings I worked on yesterday or several weeks before
- saves having to remember lots and lots of job and drawing numbers. Now all we
are left with is 9 of the previous drawings opened (big deal!) and you can't even
get a preview. I also found 'AutoCAD Today' very handy when filling out my time
sheet at the end of the week because 'AutoCAD Today' was able to show me all the
drawings I had been working on, on a day by day basis for the whole week.
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (6 of 11) [23/03/2005 05:48:25 p.m.]
The best replacement I have seen is a free program called 'recent' at www.dotsoft.com.
It lists the last 26 drawings used. A bit of an improvement on AutoCAD 2004's 9 recent
drawings but with no thumbnail preview and no day by day listing it is still a far cry
from good old 'AutoCAD Today'!

Also, I was wondering if you or anyone else knows of a good replacement for the new
'ddedit' interface. I know the new interface has a lot of good features, but for straight
forward text editing, I much prefer the old 2002 ddedit interface. I wish Autodesk had
provided a '-ddedit' command to bring up the old interface!

Regards

Craig Green
==========
Kenny,
There has been a lot of discussion into making drawings read-only.
I found this little routine in the AutoCAD Help and thought that it
may not be foolproof, but it could make life a misery fror someone
who doesn't know anything about VBA. All you need to do is embed
this into the drawing that you do not want changed :
'VBA CODING STARTS HERE
Private Sub AcadDocument_ObjectErased(ByVal ObjectID As Long)
' This example intercepts a drawing ObjectErased event.
' This event is triggered when an object is removed from a drawing.
' To trigger this example event:
'Delete (Cut) an existing object from an open drawing
' Use the "Object" variable to determine the type of object removed
MsgBox "The ID of the object deleted is: " & ObjectID
End Sub
'VBA CODING ENDS HERE
George Binns
===========
Things Weird and Wonderful
========================
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (7 of 11) [23/03/2005 05:48:25 p.m.]
Re: Hellooooooo......Is there anybody out there??????
YEP!!
Nieko Baisaus
============
Hi Kenny,
I am about to relocate too! Next week I am going to visit Baghdad
for the first time in 10 years!. I can ask for a job offer for you if you
like.
Mid of May, I am planning to immigrate to Canada. Do you know
anybody who can help me find a good job in Winnipeg?!
At least I know where I am about to resettle.
Good luck
Sherko
Amsterdam
mailto:S.Sharif@nw.bam-it.nl
=========================
Miscellaneous Stuff that I almost Forgot
================================
The Expresso Cafe
================
Much more than just another 'forum' or Bulletin Board,
The Expresso Cafe is a place to solve problems, share
thoughts, learn, and relax.
Services include :
- 7 AutoCAD Programming forums
- 8 General Language forums (Lisp, VB, VBA, C++)
- Private messaging
- Search engine
- Jukebox
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (8 of 11) [23/03/2005 05:48:25 p.m.]
- Arcade
- Quiz Center
- Live I.R.C. Channel
And, of course, a community of knowledgeable AutoCAD
VBA/Lisp programmers to help solve those tough questions.
Join today!
http://www.vbdesign.net/expresso/register.php
======================================
The Back Stoep
=============
Tony Blair is being shown around a hospital. Toward the end of his
visit, he's shown into a ward populated by people with no obvious
signs of injury.
After greeting the first patient, the chap replies:
"Fair fa' your honest sonsie face,
Great chieftain e' the puddin' race!
Aboon them a' ye your place
Painch, tripe, or thairm :
Weel are ye wordy o' a grace
as lang's my arm"
A curious Mr Blair greets the next patient, who replies:
"Some hae meat, and canna eat,
And some wad eat that want it,
But we hae meat and we can ea,
And sae the Lord be thankit".
The third patient responds to the now thoroughly confused Prime Minister
thus:
"Wee sleekit, cow'rin, tim'rous beastie,
O, what a panic's in thy breastie!
Thou need na start awa sae hasty,
Wi bickering brattle!
I wad be laith to rin an chase thee,
Wi murdering pattle!"
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (9 of 11) [23/03/2005 05:48:25 p.m.]
Blair turns to the doctor accompanying him and asks :
"What is this, some sort of mental ward?"
"No," replies the doctor: "It's the Bad Burns unit."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-06


http://www.afralisp.com/newsletter/2004/2004-06.htm (10 of 11) [23/03/2005 05:48:25 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-06
http://www.afralisp.com/newsletter/2004/2004-06.htm (11 of 11) [23/03/2005 05:48:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-07
=========================
Monday 8th March 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
If u cn rd ths u cn bcm a prgmr.
=========================
The Front Stoep.
==============
I received this interesting email :
Hey Kenny!

Re: Is it my imagination or is my mailbox getting smaller?

NEWSGROUPS! Least that's my take. I am ending my AutoCAD Clinic
support column in CADalyst magazine because I'm just not getting any
letters any more seeking help. The column has existed for almost 14
years [4 of them by me] and I used to get scores of emails every month.
They way I look at it, why email me for a problem that won't get an
answer for a month or two? Especially when you can go to a ng and
get an answer in a day.

Mike Tuersley
===========
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (1 of 19) [23/03/2005 05:48:27 p.m.]
Is Mike correct in what he says? What do you think?
Personally, I agree with him. But, would that not mean the
demise of Newsletter such as this? Not necessarily I say!
As you've probably noticed, I have slowly but surely
- sneakily - started changing the format of this letter from that
of Questions and Answers, to that of a more tutorial/information
type of publication, not always specifically AutoCAD or
coding orientated. There will always be room for Q and A
but even those that I publish are one's that I feel are out
of the ordinary.
Any suggestions in regards to what you would like to read here?
===============
Pearls of Wisdom
===============
If your parents didn't have any kids,
there's a good chance you won't.
===============
Coding
=======
Hello from Germany,
I have two things for you.
First a AutoLisp Tool which make the DesignCenter to show more dwg-like
Files as dwt and dws File-Types.
It has some nice registry functions within. The main Command is C:ADC+.
Test it. It works fine in german Version an should work in international
Versions too, because it finds the Registry-Path by itself with vlax-product-key
and then creates a copy of the ADC-dwg-Extension in the Registry with the new
extension-name. I think it is very useful.
;CODING STARTS HERE
(vl-load-com)
(defun C:ADC+ (/ ERASEFLAG EXTENSION)
(if (not (REG:TESTWRITE))
(alert
(strcat
"Sorry, unable to write to the Windows-Registry."
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (2 of 19) [23/03/2005 05:48:27 p.m.]
"\nContact your CAD-Admin or login as User"
"\nwith writing-Access to the Registry."
) ;_ end of strcat
) ;_ end of alert
(progn
(initget 1 "dwT dwS All")
(setq EXTENSION
(getkword
"Enhanced FileType-Support for DesignCenter, select File-Extension
[dwT/dwS/All]: "
) ;_ end of getkword
) ;_ end of setq
(if EXTENSION
(progn
(initget "Activate Deactivate")
(setq ERASEFLAG
(getkword
(strcat
"\nDesignCenter-Support for "
(strcase EXTENSION)
" File-Type(s) [Activate/Deactivate]<Activate>? "
) ;_ end of strcat
) ;_ end of getkword
) ;_ end of setq
(if (or (not ERASEFLAG) (= ERASEFLAG "Activate"))
(setq ERASEFLAG NIL)
(setq ERASEFLAG t)
) ;_ end of if
(if (= EXTENSION "All")
(mapcar
(function (lambda (X) (MS:DC-SWITCH-EXTENSION ERASEFLAG X))
) ;_ end of function
'("dwt" "dws")
) ;_ end of mapcar
(MS:DC-SWITCH-EXTENSION ERASEFLAG EXTENSION)
) ;_ end of if
(if ERASEFLAG
(princ (strcat "\nOK, DesignCenter-Support for "
(strcase EXTENSION)
" File-Type(s) DEACTIVATED."
) ;_ end of strcat
) ;_ end of princ
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (3 of 19) [23/03/2005 05:48:27 p.m.]
(princ (strcat "\nOK, DesignCenter-Support for "
(strcase EXTENSION)
" File-Type(s) ACTIVATED."
) ;_ end of strcat
) ;_ end of princ
) ;_ end of if
(princ "\nRestart AutoCAD for Effect.")
) ;_ end of progn
) ;_ end of if
) ;_ end of progn
) ;_ end of if
(princ)
) ;_ end of defun
;;; erzeugt oder lscht den DCenter-Wert fr die bergebene Extension.
;;; Argumente:
;;; ERASEFLAG = nil oder T, wenn T wird die extension gelscht, wenn nil erzeugt
;;; EXTENSION = Zeichenkette, definiert die zu bercksichtigende Dateierweiterung
;;; Prfung auf Lnge und "dw" Anfang
;;;
;;; Funktion legt in jedem Fall eine Backup-Extension der "dwg" als "..." an.
(defun MS:DC-SWITCH-EXTENSION (ERASEFLAG EXTENSION
/ ADCBACKUPKEY
ADCDWGKEY ADCEXTKEY
ADCKEY ADCTARGETKEY
CHANGED-EXT WRITE-BACKUP
)
(setq EXTENSION (strcase EXTENSION t))
(if (and (= (strlen EXTENSION) 3) (wcmatch EXTENSION "dw?"))
(progn
(if (setq ADCKEY (REG:ACADDCKEY))
(progn
(setq ADCEXTKEY (strcat ADCKEY "\\" "Extensions")
ADCTARGETKEY (strcat ADCEXTKEY "\\." EXTENSION)
ADCBACKUPKEY (strcat ADCEXTKEY "\\.zzz")
ADCDWGKEY (strcat ADCEXTKEY "\\.dwg")
) ;_ end of setq
;; Cleanup Backup-Pfad
(if (member ".zzz" (vl-registry-descendents ADCEXTKEY))
;_ existiert der Backup-Eintrag schon?
(if
(not (REG:TEST-LAYOUT-CLSID ADCBACKUPKEY))
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (4 of 19) [23/03/2005 05:48:27 p.m.]
;_ existiert, aber keine Daten gesichert...
(setq WRITE-BACKUP t) ;_ erzeuge Backup
(setq WRITE-BACKUP NIL) ;_ Backup existiert schon
) ;_ end of if
(setq WRITE-BACKUP t) ;_ erzeuge Backup
) ;_ end of if
(if WRITE-BACKUP
(progn
(setq CHANGED-EXT
(REG:->KEY-LST-STRING-SUBST
"zzz"
"dwg"
(REG:->KEY-VALUE-LST ADCDWGKEY)
) ;_ end of REG:->KEY-LST-STRING-SUBST
) ;_ end of setq
(REG:WRITE-KEY-VALUE-LST CHANGED-EXT)
) ;_ end of progn
) ;_ end of if
(if ERASEFLAG
(if (REG:TEST-LAYOUT-CLSID ADCTARGETKEY)
(REG:DELETE-KEY-VALUE-LST
(REG:->KEY-VALUE-LST ADCTARGETKEY)
) ;_ end of REG:DELETE-KEY-VALUE-LST
) ;_ end of if
(REG:WRITE-KEY-VALUE-LST
(REG:->KEY-LST-STRING-SUBST
EXTENSION
"zzz"
(REG:->KEY-VALUE-LST ADCBACKUPKEY)
) ;_ end of REG:->KEY-LST-STRING-SUBST
) ;_ end of REG:WRITE-KEY-VALUE-LST
) ;_ end of if
) ;_ end of progn
) ;_ end of if
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
;;; Gibt den Namen "HKEY_LOCAL_MACHINE" zurck
(defun REG:WINBASEKEY (/)
"HKEY_LOCAL_MACHINE"
) ;_ end of defun
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (5 of 19) [23/03/2005 05:48:27 p.m.]
;;; Gibt den Namen "HKEY_LOCAL_MACHINE\\SOFTWARE" zurck
(defun REG:WINSOFTWAREKEY (/)
(strcat (REG:WINBASEKEY) "\\" "SOFTWARE")
) ;_ end of defun
;;; Liest den DesignCenter Key fr die aktuell laufende AutoCAD-VErsion aus
(defun REG:ACADDCKEY (/ DCKEY retval)
(setq DCKEY "AutodeskApps\\AcadDC"
;_ Teilschlssel zum ADC Eintrag von R2000 bis R2004 identisch
RETVAL (strcat (REG:WINBASEKEY) "\\" (vlax-product-key) "\\" DCKEY)
) ;_ end of setq
(if (not (vl-registry-descendents RETVAL))
(setq RETVAL NIL)
) ;_ end of if
retval
) ;_ end of defun
;;; Liest einen Registry-Tree ab dem bergebenen Key
;;; und erzeugt daraus eine entsprechende, hierarchische Liste:
;;; Format:
;;; ("KEYNAME" [((VALUENAME . VALUEDATA)(VALUENAME . VALUEDATA)...)
;;;oder nil] [SUBKEY-LIST oder nil])
;;; Format der SUBKEY-LIST: Liste von Listen, die genauso wie die Hauptliste
;;;aufgebaut sind.
;;; Verschachtelung entsprechend des Registry-Trees.
;;; Z.B.:
;;; ("HKEY_LOCAL_MACHINE\\Software\\Autodesk\\...\\.dwg"
;;; (("Container" . 1)
;;; ("Default_IconIndex" . 2)
;;; ("Default_Clsid" . "{C8F4366D-BAC6-4463-9F42-C2627D8E86FB}")
;;; )
;;; (("HKEY_LOCAL_MACHINE\\Software\\Autodesk\\...\\.dwg\\Blocks"
;;;(("LocalName" . "Blcke")...) nil)
;;; ("HKEY_LOCAL_MACHINE\\Software\\Autodesk\\...\\.dwg\\Dimstyles"
;;;(("LocalName" . "Bemstile")... ) nil)
;;; ("HKEY_LOCAL_MACHINE\\Software\\Autodesk\\...\\.dwg\\Layers"
;;;(("LocalName" . "Layer")...) nil)
;;; (...)
;;; )
;;; )
(defun REG:->KEY-VALUE-LST (KEY / RETVAL SUBKEYNAMES VNAMES)
;; Value-Handling fr Key
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (6 of 19) [23/03/2005 05:48:27 p.m.]
(if (setq VNAMES (reverse (vl-registry-descendents KEY t))) ;_ hat der Key values?
(setq
VNAMES (mapcar (function (lambda (X)
(cons X (vl-registry-read KEY X))
) ;_ end of lambda
) ;_ end of function
VNAMES
) ;_ end of mapcar
) ;_ end of setq
) ;_ end of if
(setq RETVAL (list KEY VNAMES))
(if (setq SUBKEYNAMES (reverse (vl-registry-descendents KEY)))
(setq SUBKEYNAMES
(mapcar
(function (lambda (X)
(REG:->KEY-VALUE-LST (strcat KEY "\\" X))
) ;_ end of lambda
) ;_ end of function
SUBKEYNAMES
) ;_ end of mapcar
) ;_ end of setq
) ;_ end of if
(append RETVAL (list SUBKEYNAMES))
) ;_ end of defun
;;; tauscht einen String in allen Keys der Registry-Tree-Liste
(defun REG:->KEY-LST-STRING-SUBST
(NEW PATTERN KEYLST / ELEM-NEU KEY SUB-KEY-LST SUB-KEY-LST-NEW)
(setq KEY (car KEYLST)
KEYLST (subst (vl-string-subst NEW PATTERN KEY) KEY KEYLST)
) ;_ end of setq
(if (setq SUB-KEY-LST (nth 2 KEYLST))
(foreach ELEM SUB-KEY-LST
(setq SUB-KEY-LST-NEW
(cons
(REG:->KEY-LST-STRING-SUBST NEW PATTERN ELEM)
SUB-KEY-LST-NEW
) ;_ end of cons
) ;_ end of setq
) ;_ end of foreach
) ;_ end of if
(setq KEYLST (list (nth 0 KEYLST)
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (7 of 19) [23/03/2005 05:48:27 p.m.]
(nth 1 KEYLST)
(reverse SUB-KEY-LST-NEW)
) ;_ end of list
) ;_ end of setq
) ;_ end of defun
;;; Erzeugt alle Registrierungseintrge die in der bergebenen Registry-Tree-Liste
;;; enthalten sind.
(defun REG:WRITE-KEY-VALUE-LST (LST / KEY SUB-LST VAL-LST)
(if (setq KEY (car LST))
(if (vl-registry-write KEY)
(progn
(if (setq VAL-LST (nth 1 LST))
(foreach ELEM VAL-LST
(vl-registry-write KEY (car ELEM) (cdr ELEM))
) ;_ end of foreach
) ;_ end of if
(if (setq SUB-LST (nth 2 LST))
(foreach ELEM SUB-LST
(REG:WRITE-KEY-VALUE-LST ELEM)
) ;_ end of foreach
) ;_ end of if
) ;_ end of progn
) ;_ end of if
) ;_ end of if
) ;_ end of defun
;;; Lscht alle Registrierungseintrge die in der bergebenen Registry-Tree-Liste
;;; enthalten sind.
(defun REG:DELETE-KEY-VALUE-LST (LST / SUB-KEYS)
(while (not (vl-registry-delete (car LST)))
(if (setq SUB-KEYS (nth 2 LST))
(foreach ELEM SUB-KEYS
(REG:DELETE-KEY-VALUE-LST ELEM)
) ;_ end of foreach
) ;_ end of if
) ;_ end of while
) ;_ end of defun
;;; Testfunktion: Kann der User in die Registrierung schreiben?
(defun REG:TESTWRITE (/ RETVAL TESTKEY)
(setq TESTKEY (strcat (REG:WINSOFTWAREKEY) "\\" "VLWRITETEST")
RETVAL (vl-registry-write TESTKEY)
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (8 of 19) [23/03/2005 05:48:27 p.m.]
) ;_ end of setq
(if RETVAL
(vl-registry-delete TESTKEY)
) ;_ end of if
RETVAL
) ;_ end of defun
;;; Testet fr einen bergebenen Key, ob es fr den SubKey "Layouts",
;;; Wertname "CLSID" einen Wert gibt.
(defun REG:TEST-LAYOUT-CLSID (key /)
(vl-registry-read (strcat key "\\Layouts") "CLSID")
) ;_ end of defun
;;; Liest die Keys fr den bergebenen Schlssel in
;;;"HKEY_LOCAL_MACHINE\\SOFTWARE"
;;; aus. z.B.: (REG:FIND-SW-KEYS "Autodesk")
(defun REG:FIND-SW-KEYS (SWKEY / RETVAL)
(setq RETVAL (REG:WINSOFTWAREKEY)
SWKEY (strcase SWKEY)
) ;_ end of setq
(if (member SWKEY (mapcar 'strcase (vl-registry-descendents RETVAL)))
(setq RETVAL (vl-registry-descendents (strcat RETVAL "\\" SWKEY)))
(setq RETVAL NIL)
) ;_ end of if
(reverse RETVAL)
) ;_ end of defun
;;; Versuch einer Key-exist Funktion, leider geht es nicht... Mal schauen...
;;; Funktioniert nicht
(defun REG:KEYEXIST? (KEY VALUE / TEST-LST)
(if (setq TEST-LST (REG:REGSTR->KEY-VAL KEY))
(if (not (vl-catch-all-error-p
(vl-catch-all-apply 'vl-registry-descendents (list (car TEST-LST)))
) ;_ end of vl-catch-all-error-p
) ;_ end of not
(if (vl-registry-descendents (car TEST-LST))
KEY
) ;_ end of if
) ;_ end of if
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (9 of 19) [23/03/2005 05:48:27 p.m.]
) ;_ end of if
) ;_ end of defun
(defun REG:REGSTR->KEY-VAL (KEY / LASTBACKSLASH)
(if KEY
(if
(setq LASTBACKSLASH (vl-string-position (ascii "\\") KEY NIL t))
(list (substr KEY 1 LASTBACKSLASH)
(substr KEY (+ LASTBACKSLASH 2))
) ;_ end of list
) ;_ end of if
) ;_ end of if
) ;_ end of defun
;CODING ENDS HERE
The second thing is something about the Express-Tools 2004.
I have made a translation of all Source-Code Files and the help-file with a
team of CAD-Admins (a real Internet-based Project).
We have cleaned some bugs too. I don't know, if you have any other
german-readers on your list, but it could be interesting for other language
translations, because we have marked ANY changes with a comment.
Whenever you find a comment like ";;;***ET2GP-" we have made a
translation or repaired a bug.
You can find us at: http://www.defun.de/express/
Ciao,
Marc
=====
I have a weird problem, when I use the getpoint function,
the value is truncated. For instance, I pick the point with
coordinates
N 929091.88
E 2174244.55
but the returned value for the point is
(217424e+6, 929092.0, 0.0)

What is going on?
Dave McClure
============
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (10 of 19) [23/03/2005 05:48:27 p.m.]
Kenny,
This may be of interested to the die hard drafters out there.
Not much to do with Coding, but it's still in our field.
I found this site when working for a company who forced
me to use LT. My god the horror, as a code junkie I had to
find some alternatives, and Stef's website for LT helped
out a ton! Follow this for a great thread about the good ole' days.

http://www.flatmtn.com/cad/links-oldcad.html

Wonderful site, you're doing a great job! Keep it up.

Kind Regards,
Matthew Corbin
=============
Kenny,
Glad the thread was noteworthy. So you want to publish some LT info.
What are you looking for? Maybe some code for common tools. I know layer
utilities are always hot topics in the forums. Diesel was hard to get
used to, but it can add some robustness (is that a word?) to your very
dull LT system. Here are some layer functions you can create pretty
quickly by adding a new toolbar with some buttons and copy & paste the
code right into the macro section.

FreezeLayer
*^C^C_setenv;oldlayer;$m=$(getvar,clayer);_ai_molc;\"-layer;set;
$M=$(getenv,^M;oldlayer);freeze;$(getvar,clayer)";;LayerOff
*^C^C_setenv;clay1;$m=$(getvar,clayer);^P_ai_molc;\^P_setenv;
clay2;"$m=$(getvar,clayer)";_-layer;_off;"""$m=$(getenv,clay2);
_y;_s;$m=$(getenv,clay1);;;"""
LockLayer
*^C^C_setenv;oldlayer;$m=$(getvar,clayer);_ai_molc;\"_-layer;_s;
$M=$(getenv,oldlayer);_lock;$M=$(getvar,clayer)";;
Isolate ^C^C_ai_molc \-layer freeze * ;;;
UnlockAllLayer ^C^C-layer;_un;*;;
LayerOn ^C^C-layer _on *;;
ThawLayer ^C^C-layer;_t;*;;

Watch for word wrapping.These macros are quick and dirty. I'm afraid
it's about the best you can get when programming in Diesel.This worked
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (11 of 19) [23/03/2005 05:48:27 p.m.]
on LT versions 2000, 2000i, & 2002. Hope this "gets the ball rolling".
I've got a few more tricks, so whenever you want them give me a holler.
Cheers,
Matthew Corbin

P.S. I once toyed with the thought of using VB with LT, but LT didn't
include the IDE. Maybe someone has had some luck going down that route.
===========================
Hi Kenny:
I had no idea you were looking for more code snippets. Frankly, they've
been my favourite part of the newsletter in the recent past, excepting
the new VBA code (please keep it coming, we VBA newbies need help!).
I've dug through my bag o' tricks to find something strange for you and
the rest of the folks.
I wrote this lisp routine after feeling the need to make quick blocks on
the fly. All you do is pick the entities and an insertion point. The
block is then made with a random name.
;Code starts here
================
(defun C:IMP (/ SLCT CDATEX BNAME)
(setvar "cmdecho" 0)
(princ "\nSelect items to IMPLODE: ")
(setq
SLCT (ssget)
GPO (getpoint "\nInsertion Point: ")
CDATEX (rtos (getvar "cdate") 2 9)
BNAME (strcat (substr CDATEX 10 8))
)
(command "_block" BNAME GPO SLCT "")
(command "_insert" BNAME GPO "" "" "")
(setvar "cmdecho" 1)
)
(princ)
================
;Code ends here
Cheers.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (12 of 19) [23/03/2005 05:48:27 p.m.]
Ron - Windsor, Ontario, Canada.
===========================
Kenny,
You wanted some reaction to your articles? Well heres one.
Some time ago you gave some tricks to do some manipulation
with folders and files. Heres another way :
In VB go to Pulldown menu Project - References.
In the dialogbox choose Microsoft Scripting Runtime
In the source code add: Global fso As New FileSystemObject
Now you can simply type fso.[option]

This is far easier to use. Pressing the F1 button gives you an excellent help.
Hope this is something you wanted?
Greetings,
H. Bosma
========
Dear Kenny,
I am having problems with nested xrefs in vba.
It's easy to find all xrefs in modelspace or paperspace
and change the path, but how do I find the xrefs inside
an xref or inside a block?
Finding the top level xref's is done very fast with a selection set.
But is it possible to use selection sets inside an xref or block?
Now I am doing for each block
For each Obj in Block...
If Obj.Objectname= AcadBlocReference or something like that
Next
That may take a few minutes when there are many large
xrefs and blocks.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (13 of 19) [23/03/2005 05:48:27 p.m.]
mvh,
Ragnar Thor Mikkelsen
www.designdata.no
=================
Hi,

We are try to establish some CAD standards in our little office
and in the process made a template file with about 140 layers.
What is happening that anyone who work using this template
use to purge unused layers and if someone needs them again
he/she has to create them again.

What I want is to know that How i can stop those layers from
accidental purge.

Thanks

Gouhar
=======
Hi Kenny,
How is your employment situation?
I trust you have found something that is
(a) Better
(b) Stimulating
(c) Fun
(d) All the above.
Anyway, you were whining about me not contributing to your newsletter. Your
newsletter is the finest anywhere. It is my favorite. I know it doesn't need
my contributions.
So, having said that here is a contribution:
I found by accident that when you offer options in a command line prompt you
can get automatic cursor menu support.
For example if you start the circle command you see this at the command
prompt:
CIRCLE Specify center point for circle or [3P/2P/Ttr (tan tan radius)]:
If you right click in the drawing window while at this prompt and get a
cursor menu you will see "3P, 2P, and Ttr (tan tan radius)" as options that
you can select in that menu.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (14 of 19) [23/03/2005 05:48:27 p.m.]
So . . . if you've written a program that asks for user input at the command
prompt (and who hasn't) you can get the same functionality if you follow a
couple of rules.
1. Use square brackets to enclose your options.
2. Separate your options with a forward slash.
You'll see what I mean if you try the sample code below. Just copy it into a
regular module in AutoCAD VBA.
Run the program. You will get the prompt
Command: Do Something Really Great [New/Edit/Copy/Delete/Smeg] <New>:
At this point pop up your cursor menu. Usually that means hold down the
right mouse button.
You should see all of your options. Select one.
(I only tried this in R2004.)
' Start of code
Public Sub InputOptions()
Dim strOptions As String
Dim strOpt As String
Dim strDefault As String
strDefault = "New"
strOptions = "New Edit Copy Delete Smeg"
ThisDrawing.Utility.InitializeUserInput 0, strOptions
On Error Resume Next
strOpt = ThisDrawing.Utility.GetKeyword( _
"Do Something Really Great [New/Edit/Copy/Delete/Smeg] <"
& _
strDefault & ">: ")
On Error GoTo 0
If strOpt = "" Then strOpt = strDefault
MsgBox "You selected the " & strOpt & " option." & vbCrLf & _
"You must be very proud.", vbOKOnly, "Command line options"
End Sub
' End of code
I hope you find this [Amusing/Entertaining/Exciting/Brilliant] <Brilliant>.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (15 of 19) [23/03/2005 05:48:27 p.m.]
=Mark
======
Craig Green is missing "AutoCAD Today" in Acad 2004 because he is using it
for i.e. time-tracking.
But there are more usefull functions. Like library drawings.
A couple off times a year I have to make drawings for fire-protection,
mecanical constructions, pneumatic diagrams, etc. etc.
For this drawings I have a lot of blocks as bolts and nuts, pneumatic
components, building / furniture blocks.
Putting those blocks into menus takes a lot of work, making slides and
typing the icon/pulldown menus.
Instead I made a simple script to insert those symbols in a drawing, all at
0,0,0.
I now have drawings called Nuts, Pneumatc, Fire,Metal screws,Furniture,
Kitchen and a couple off others.
When I open Today I find those drawings under the tab Symbol Lybraries and
by selecting one open it in Design Center.
Try this out. It makes my life a lot simpler. No longer extensive searches
for a specific symbol.
To install Today with AutoCAD2004:
1) Copy the following files from Acad2002 to Acad 2004.
..\Autocad 2002\AcToday.arx
..\Autocad 2002\TodayStyleErr.css
..\Autocad 2002\TodayRes.dll
..\Autocad 2002\WebDepot\ErrorHandler\RepairTodayRes.dll
..\Autocad 2002\WebDepot\ErrorHandler\RepairToday.exe
..\Autocad 2002\actodaydef.htm
..\Autocad 2002\actodayhelp.htm
..\Autocad 2002\TodayDiagnostics.htm
..\Autocad 2002\TodayErrorHandler.htm
..\Autocad 2002\TodayFixer.htm
..\Autocad 2002\TodayDiagnostics.inc
..\Autocad 2002\TodayErrorHandler.inc
..\Autocad 2002\TodayFixer.inc
..\Autocad 2002\acdctoday.ocx
..\Autocad 2002\TodayStyleErr.css.org
C:\Documents and Settings\User1\Favorites\Media\CNET Today -
Technology News.url
2) Load AcToday.arx in Acad.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (16 of 19) [23/03/2005 05:48:27 p.m.]
Today should work.
Joop Moelee
===========
Things Weird and Wonderful
========================
Conspiracy theories - http://www.whatreallyhappened.com/
No1 hit singles 1956-2002 - http://www.onmc.iinet.net.au/
I.R.S. forms - http://www.irs.ustreas.gov/
See what others are searching the web for - http://www.metaspy.com/
Pole Shift theories and maps - http://www.zetatalk.com/poleshft/p00.htm
================
Miscellaneous Stuff that I almost Forgot
================================
Dear Sir,

Can I get all these newsletters as a book (PDF Format).
Because some of the newsletters, I may missed to read.
That will be good reference for me and other readers also.

Thanks in Advance

L.Gnanamuthu
=============
Mmmm, now that's a thought!
(Kenny runs off and fiddles with switches and does things.)
Guess what?
You can find all the AfraLisp Newsletters, in PDF format here :
http://www.afralisp.com/newsletter/newsletter.zip ( 828kb )
I have "misplaced" all the Newsletters prior to 2001. So if anyone still has
any of them, I would be delighted to have a copy.
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (17 of 19) [23/03/2005 05:48:27 p.m.]
Newsflash - I've just received all the Newsletter from 1999.
A BIG thanks to Steve Chorney.
I'll have them all posted by next week.
============================
The Back Stoep
=============
A small boy was lost at a large shopping mall. He approached a
uniformed policeman and said, "I've lost my dad!"
The policeman asked, 'What's he like?"
The little boy replied, "Beer and women with big tits."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download all the AfraLisp Newsletters,
in PDF format here: http://www.afralisp.com/newsletter/newsletter.zip ( 828kb )
Issues 2001-01 to 2004-05
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (18 of 19) [23/03/2005 05:48:27 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-07
http://www.afralisp.com/newsletter/2004/2004-07.htm (19 of 19) [23/03/2005 05:48:27 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-08
=========================
Sunday 14th March 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Visit "The CAD Vault" NOW....
http://www.cadvault.com/forums
=========================
Dead people are cool.
=========================
The Front Stoep.
==============
There have been, over the last decade, thousands of CADD related sites.
Some have specialized in programming, others in providing tools and tips,
and lately we have seen the introduction of forums - a place to gather and
discuss the problems that plague the industry or to share ideas. Many of
these sites have been restrictive, choosing to target their content at a
single platform, or limiting speech against a product, especially where
advertising or support dollars are involved or are the creation of the
company that sells the products being discussed.
All of that is about to change.
Introducing The CAD Vault, http://www.cadvault.com/forums
Using the best forum software available, CAD Vault (or just "The Vault")
will provide a common meeting place for all CADD disciplines, and (this is
the best part) it is being built to the specifications of the community.
Come visit The Vault today and help build a better community for tomorrow!
===============
Hi Kenny,
Mikes comment:
"They way I look at it, why email me for a problem that won't get an answer
for a month or two? Especially when you can go to a ng and get an answer in
a day. "
Mike Tuersley
Your response:
"Is Mike correct in what he says? What do you think?
Personally, I agree with him. But, would that not mean the demise of
Newsletter such as this? Not necessarily I say!"
My thoughts:
I agree with you in agreeing with him. The newsgroups have changed the niche
that newsletters or articles in magazines fill. True, if I want an answer to
a specific question I'll post it and hopefully get a reply that works and
quickly. This is especially true of the forums at vbDesign's Expresso.
The thing that is different about newsletters and/or magazines is that they
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (1 of 8) [23/03/2005 05:48:28 p.m.]
provide answers to questions that I didn't ask. In some ways that is more
useful. Newsletters like yours have really expanded my horizons. They
presented questions I never would have thought to ask. What authors like
Mike and you might consider is writing answers in your articles to questions
that you see frequently in the newsgroups. It might be that you have all the
questions you want or need. They are just not getting mailed specifically to
you.
I don't think that newsgroups and newsletters are at odds. They each fill a
different need in the CADD community.
=Mark Johnston
===============
Pearls of Wisdom
===============
We all make mistakes... said the Dalek climbing off the dustbin.
===============
Coding
=======
In response to...
We are try to establish some CAD standards in our little office.......
... Our template has many layers also. In order to keep them from being
purged we draw a line and text on each layer out in the negative land
(left of 0,0), its very similar to a legend of layers. This gives users
a quick way of using match properties also, since all template layers
are shown.
Example:
Line sample Layer name Usage
---------- AWA Walls
---------- ADO Doors
Troy Gates
=========
Hi can you help me with a lisp program that will run a program to insert
spaces into a car park.
If so i would be extremely greatful.
Sean Noble
===========
Kenny

Some time ago I recall providing you with details of how I use
.x and .y filters in the POP0 section (shift right click) of the
acad.mns to allow me to draw lines to the x or y component of a
selected point.

It is a very long story, but our IT people have chosen to place
the standard acad.mns file in a 'read only' folder on a national
network for all of us to use and they will not
allow it to be changed. (NOT HAPPY!!!)

Do you know of a way to load a modified version of the POP0 code
AFTER AutoCAD has loaded? I have tried, but nothing seems to work.
Craig Green
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (2 of 8) [23/03/2005 05:48:28 p.m.]
===========
Craig,
Have a look at this:
http://www.afralisp.com/vba/vbamenu2.htm

And please take note of this statement towards the bottom of the page:

"Do you notice that this does not force the AutoCAD menu to recompile
but just adds and deletes from it on the fly."
============
Kenny,
Ever wonder why AutoCAD doesn't allow you to scale the X and Y axes
separately when using the SCALE command? Here is a solution that I devised
taking advantage of the fact that AutoCAD allows you X and Y scale a block.
The routine makes a block out of your selection set, inserts it to the X and
Y scales and then purges the block from the drawing. This routine can be
very handy sometimes.
Jeremy Dunn
===========
;CODING STARTS HERE
(defun C:XYSCALE (/ ss xsf ysf p oldsn)
(if (setq ss (ssget))
(progn
(setq p (getpoint "\nSelect base point: ")
xsf (getreal "\nX scale factor[1]: ")
xsf (if xsf xsf 1.0)
ysf (getreal "\nY scale factor[1]: ")
ysf (if ysf ysf 1.0)
)
(command "-BLOCK" "XYBlock" p ss "")
(command "._ERASE" ss "")
(setq oldosn (getvar "OSMODE"))
(setvar "OSMODE" 0)(setvar "ATTREQ" 0)(setvar "ATTDIA" 0)
(command "-INSERT" "XYBlock" p xsf ysf 0)
(setvar "OSMODE" oldosn)(setvar "ATTDIA" 1)(setvar "ATTREQ" 1)
(command "._EXPLODE" (entlast))
(command "-PURGE" "B" "XYBlock" "N")
)
(alert "No objects selected - try again.")
)
(princ)
)
(princ)
;CODING ENDS HERE
==================
Kenny,
I have a question.
In Visual Lisp when you access the layers and a layer comes up as
bylayer for the linetype, and it is set to say continuous but is set to
bylayer how can I extract the information that tells us that it is set
to a continuous linetype but set to bylayer.
Cant figure this one out and thought you could give me a hand
Tom Black
=========
We receive polyline artwork all the time where the arcs are actually
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (3 of 8) [23/03/2005 05:48:28 p.m.]
made up of small lines. This is no good when you laser cut the artwork.
Have you come across anything that will automatically transform these
lines in to smooth arcs without losing the original shape.
I hope you can help me in this matter.

Ronny Liebregts
==============
This is a simple macro to e-mail parts of a dwg to someone
using Outlook Express from inside the drawing.
Note there is no error checking and Outlook must be installed
on the workstation.
James Murphy/Jerry Winters
========================
'CODING STARTS HERE
Sub EmailSelection()
Dim MySS As AcadSelectionSet
Set MySS = ThisDrawing.SelectionSets.Add("ssMail")
ThisDrawing.Utility.Prompt vbCrLf & "Select entities to e-mail: "
MySS.SelectOnScreen
Dim mailbody As String
Dim FName As String
Dim MailFrom As String
Dim MailTo As String
FName = ThisDrawing.Utility.GetString(False, vbCrLf & _
"Enter a Drawing name.: ")
MailTo = ThisDrawing.Utility.GetString(False, vbCrLf & _
"Email To Address: ")
mailbody = ThisDrawing.Utility.GetString(True, vbCrLf & _
"Enter the text to the message: ")
ThisDrawing.Wblock "c:\" & FName, MySS
SendAsMail MailTo, mailbody, "The drawing you requested from me", _
"C:\" & FName & ".dwg"
Kill "c:\" & FName & ".dwg"
MySS.Delete
ThisDrawing.Utility.Prompt vbCrLf & "The file was sent"
End Sub
Function SendAsMail(MailTo As String, mailbody As String, _
MailSubject As String, AttachFile As String)
Dim myOlapp As Object
Dim myitem As MailItem
Dim aFile As Attachment
Set myOlapp = CreateObject("Outlook.Application")
Set myitem = myOlapp.CreateItem(olMailItem)
Set myAttachments = myitem.Attachments
myAttachments.Add AttachFile
myitem.To = MailTo
myitem.Subject = MailSubject
myitem.HTMLBody = mailbody
myitem.Send

End Function
'CODING ENDS HERE
=================
Hey Kenny, I need some help. I need program that will freeze a layer by
selecting an object.
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (4 of 8) [23/03/2005 05:48:28 p.m.]
Sounds simple huh?
Here's my problem:
1. The object is part of a block.
2. The object is on a different layer than the block.
3. The block is part of an xref.
I hope someone has already addressed this problem.
Cheers. Ron, Windsor, Ontario, Canada
BTW, here's something for ya...
HOW TO IMPRESS A WOMAN

* Wine her,
* Dine her,
* Hug her,
* Support her,
* Hold her,
* Surprise her,
* Compliment her,
* Smile at her,
* Listen to her,
* Laugh with her,
* Cry with her,
* Romance her,
* Encourage her,
* Believe in her,
* Pray with her,
* Pray for her,
* Cuddle with her,
* Shop with her,
* Give her jewellery,
* Buy her flowers,
* Hold her hand,
* Write love letters to her,
* Go to the end of the Earth and back again for her.

How to Impress a Man:

* Show up naked... Bring food... Don't block the TV!
==========================================
Things Weird and Wonderful
========================
How Ugly Are You?
http://hometown.aol.com/howuglyareu
Save the Lobsters
http://www.geocities.com/savethelobsters_main/
The Society for the Advancement of Global Non-Conformity
http://www.psynet.net/tcow
Bob's School of Paralegal Studies and Sheetmetal Repair
http://www.mindspring.com/~jims/outhouse.htm
Squirrel Hazing - The Untold Story
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (5 of 8) [23/03/2005 05:48:28 p.m.]
http://web.wt.net/~psherr/squirrel_hazing.htm
Insect Recipes
http://www.ent.iastate.edu/Misc/InsectsAsFood.html
Mothers Against Boomerangs
http://www.utexas.edu/students/mother/
Miscellaneous Stuff that I almost Forgot
================================
Would you like to read and write to the Registry?
'CODING STARTS HERE
Sub Reg_Read_Write()
Dim Ctr As Integer
Dim Total As Integer
Dim Remain As Integer
Total = 3
Ctr = GetSetting("AfraLisp", "License", "Counter", 0)
If Ctr > Total Then
MsgBox "Sorry, License has Expired"

Else
Remain = Total - Ctr
MsgBox "You still have " & Remain & " program runs left"
Ctr = Ctr + 1
SaveSetting "AfraLisp", "License", "Counter", Ctr
End If
End Sub
'CODING ENDS HERE
=================
The Back Stoep
=============
And one from Craig Green........

A timeless lesson on how consultants can make a difference
for an organization....

Last week, we took some friends out to a new restaurant and
noticed that the waiter who took our order carried spoon in
this shirt pocket. It seemed a little strange but I ignored
it.

AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (6 of 8) [23/03/2005 05:48:28 p.m.]
However, when the busboy brought our water and utensils, I
noticed that he also had a spoon in his shirt pocket.
Then I looked around the room and saw that all the staff
had spoons in their pockets. When the waiter came back to
serve our soup I asked,
"Why the spoon?"

"Well," he explained, "the restaurant's owners hired Andersen
Consulting, experts in efficiency, in order to revamp all our
processes. After several months of statistical
analysis, they concluded that the spoon was the most frequently
dropped utensil.
This represents a drop frequencey of approximately 3 spoons per
table per hour.
If our personnel are prepared to deal with that contingency, we
can reduce the number of trips back to the kitchen and save 15
man-hours per shift."

As luck would have it I dropped my spoon and he was able to replace
it with his spare spoon.
"I'll get another spoon next time I go to the kitchen instead of making
an extra trip to get it right now," he said.

I was rather impressed. I then noticed that there was a very thin
string hanging out of the waiter's fly.
Looking around, I noticed that all the waiters had the same string
hanging from their flies.

My curiosity got the better of me and before he walked off, I asked
the waiter,
"Excuse me, but can you tell my why you have that string right there?"

"Oh, certainly!" he answered, lowering his voice. "Not everyone is
as observant as you.
That consulting firm I mentioned also found that we can save time in
the restroom."

"How so?"

"See," he continued, "by tying this string to the tip of you know what,
we can pull it out over the urinal without touching it and that way
eliminate the need to wash our hands, shortening the time spent in the
restroom by 76.39 percent."

After you get it out, how do you put it back," I asked him.

"Well," he whispered, lowering his voice even further, "I don't know
about the others, but I use the spoon."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download all the AfraLisp Newsletters,
in PDF format here: http://www.afralisp.com/newsletter/news.zip
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (7 of 8) [23/03/2005 05:48:28 p.m.]
( 1033 kb )
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-08
http://www.afralisp.com/newsletter/2004/2004-08.htm (8 of 8) [23/03/2005 05:48:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-09
=========================
Tuesday 23rd March 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Visit "The CAD Vault" NOW....
http://www.cadvault.com/forums
=========================
All right. Who set the phasers to deep fat fry?
=========================
The Front Stoep.
==============
Okay, quick update on what is happening in my life.
Finished in my present job lunchtime last Monday the 15th.
Left for Cape Town straight away.
Spent the whole of last week finding a house to rent, (until we buy)
setting up bank accounts, bar accounts, telephones, TV aerials, ISP's, etc, etc.
Remember, we are moving to a different country and they've got different money.
I did though, drink lot's of beer and ate well.
The wife loves me 'cos I gave her lot's of money.
Drove back to Namibia today - broke and with a hangover.
Will start packing now for the big move on the 31st of this month and
hopefully will be all warm and snug in our new abode by about the 2nd April.
More info in regards to my new job later.
Hey, Cape Town is great!!!
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (1 of 10) [23/03/2005 05:48:31 p.m.]
P.S. Just so you've all got ample warning, there will be a Newsletter next week,
but there is a possibility of a gap of a week or two due to the above issues.
=================
Pearls of Wisdom
===============
Maths and alcohol don't mix.
Don't drink and derive.
===============
Coding
=======
Kenny,
Just some feedback for you. Firstly your site is unmatched as a resource for
buddying programmers - Ive learnt a lot from your site, so THANK YOU.
On one of your tutorials - Standing Alone with Acad Install, I think some
of your syntax may not be 100% correct. Where you use the following:
< InstallPath >
I think it should be corrected to:
<InstallPath>
(spaces removed). I found using the syntax you had in your tutorial that
the pathing wouldnt work from my INI file. Have you heard of this from
any other users? I found that only the latter syntax worked correctly.
Regards,
Chris Needham
http://cadmodz.com/
=================
Hi Rodney
As i was searching for autolisp routine to swap blocks and your routine
came up in afralisp newsletter.
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (2 of 10) [23/03/2005 05:48:31 p.m.]
Your block switch routine does wonder but i wonder if you could make it
switch only the selected blocks instead of globally switch all blocks
within the drawing. I have a very simple routine below which matching one block to
another, but im not capable program it to selecti multiple blocks to match
another block match.
;CODING STARTS HERE
(defun C:=bk (/ ent1 ent2 el1 el2 pt1 pt2 olderr)
(setq olderr *error* ; Initialize variables
*error* chgterr
)
;convert radians to degrees
(DEFUN RTD (r)
(* 180.00 (/ r pi))
)
(setq ent1 (car (entsel "\nPick 1st object "))
ent2 (car (entsel "\nPick 2nd object "))
el1 (entget ent1)
el2 (entget ent2)
pt1 (cdr (assoc 10 el1))
pt2 (cdr (assoc 10 el2))
rt1 (cdr (assoc 50 el1))
deg (rtd rt1)
)
(command ".erase" ent1 "")
(command ".copy" ent2 "" pt2 pt1)
(command ".change" "L" "" pt1 deg)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
;CODING ENDS HERE
Thanks,
John Dam
==========
Re: ......freezing layer (by Ron, Windsor, Ontario, Canada)
Ron,
You have the solution already in your hand cq mouse.
When you are trimming or extending in your drawing you can select lines and
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (3 of 10) [23/03/2005 05:48:31 p.m.]
such from blocks and xrefs to extend or trim to.
You should use the AutoCAD and Visual Lisp help files.
I suggest you take a look in the Visual Lisp help file and search for the
keywords: entsel, nentsel and nentselp.
With this information it should not be to difficult to extract the layer
name and than freeze the layer.
Good luck and happy typing,
Joop Moelee
===========
Kenny,
Reading the newsletter and looking in on several forums it occurred to me
that a lot of readers / participants are asking for complete solutions for
their problem.
But this way they will never learn anything. They are end-users.
I have no problem with end-users, that is what all programs are made for,
but I like to let people learn something.
For example:
Tom Black has a nice one. He wants to know how to retrieve the
properties of an element that is drawn in linetype bylayer while the
layer is set to continuous.
It is not so difficult writing a lisp routine to extract this data. A bit
of work, but not difficult.
I will not give you the code, just a way to solve the problem.
Let us start tackling this problem.
By the way, Tom why being so modest? How about doing it properly and add
lineweight and color?
First of all we need to know what properties a line does have.
Open AutoCAD with a new drawing and create a line.
Activate the Visual Lisp Editor and type at the console prompt (setq ent
(nentsel))
Hit enter and select the line. On the console appears something like
(<Entity name: 4023fe30> (414.623 189.133 0.0)) and when we put variable
ent in the watch window we see there the same.
To see what <Entity name: 4023fe30> contains double-click on ent in the
watch window.
A Inspect:List window opens.
Doubleclick on {<Entity name: 4023fe30>}.
A AcadLine window opens.
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (4 of 10) [23/03/2005 05:48:31 p.m.]
Doubleclick on {LAYER}.
A Autocad Table Entry window opens.
Doubleclick on {raw-data}.
A Inspect:List window opens.
Put all those inspect windows to the left side of your screen, one above
the other.
Look at the ACAD LINE window, please.
The only properties you see are {handle}, {layer}, {extrusion direction},
{start point} and {end point}.
Not what we are looking for. But if we look at the window with the layer
properties we see a lot more. For example the linetype and color the layer
is set to.
Ok. Next step.
Draw another line and change its color to red and linetype to hidden.
Select the line with (setq ent (nentsel)) and do the same as previous
placing the windows on the right side of the ones you opened before.
Compare them, and what do you see?
Eureka! You see the entries {linetype} and {color}.
Conclusion:
When you check for the absence of those entries you know if the line is
bylayer or bycolor or not.
Is this also true for ltscla and lweight?
All the other data you need can be found in the same way.
Let me know when you find out.
I have given you a good (I think) start for solving similar problems.
Break every problem down to as small parts as possible and start solving
these partial problems.
Joop Moelee
============
Hi Kenny
This is my first time i ever send you an email, but been reading your
newsletter for awhile now.
I got this simple lisp whick break a section of the line which run thru
another line at any angles,
The problem with this lisp is it doesn't works with polyline/lwpolyline
Could you please help to solve this problem.
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (5 of 10) [23/03/2005 05:48:31 p.m.]
Since the (assoc 10) start point (assoc 11) end point only apply to
lines.
;;;Code start here;
(defun C:BREAKLINE ()
(setq var1 (getvar "osmode"))
(setq scale (getvar "dimscale"))
(setq brklen 2.5)
(setvar "osmode" 0)
(setq selc (entsel "\nSelect the line to be broken: "))
(setvar "osmode" 32)
(setq ptp (getpoint "\nSelect first point of intersection "))
(setvar "osmode" 0)
(setq ent1 (car selc))
(setq ent2 (entget ent1))
(setq Pt1 (cdr (assoc 10 ent2)))
(setq Pt2 (cdr (assoc 11 ent2)))
(setq angr (angle Pt1 Pt2))
(setq hi (* scale brklen))
(setq Pt3 (polar Ptp angr hi))
(setq Pt4 (polar Ptp (+ angr pi) hi))
(command ".break" ent1 Pt3 Pt4)
(setvar "osmode" var1)
(princ)
)
;;;Code end here;
Any help would be greatly appriciated
Thanks,
John Dam
==========
Hi Kenny,
From your articles I made bitmap DLL's for Autocad menus
using the free resource hacker and they worked well until our office
got 2004 and windows XP. Now the icons don't show. Has the menu
structure changed or is it XP? Do you have a fix?
regards

AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (6 of 10) [23/03/2005 05:48:31 p.m.]
STEPHEN ANDREWS
=================
Things Weird and Wonderful
========================
Hello....can you help me a lisp program about a file name in cad
how a create file name on paper sheet without rewrite it.
so..only writing save or new file in path file ....for example
.....c:/temp/H4R15.dwg and there is automatically on paper sheet H4R15.dwg
in lower left corner.
Haris abd.
========
Interspecies Telepathic Communication
http://www.cyberark.com/animal/telepath.htm
Anarchist Gallery
http://www.geocities.com/SoHo/Gallery/4168/
The Bureau of Missing Socks
http://www.funbureau.com/
How to Toilet Train Your Cat
http://www.rainfrog.com/mishacat/toilet.shtml
First Church of Jesus Christ, Elvis
http://jubal.westnet.com/hyperdiscordia/sacred_heart_elvis.html
Miscellaneous Stuff that I almost Forgot
================================
Free online AutoCAD 2000 tutorials are offered by myCADsite.com. The site
includes 39 lessons that will take a user from Step 1 to advanced 3D
concepts. The tutorials build on the previous and each one has a self-quiz
at the end. The site also includes links, drawing samples and some simple
Autolisp downloads. The latest addition is a review of AutoCAD 2005.
Thank you,
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (7 of 10) [23/03/2005 05:48:31 p.m.]
Art Whitton
Las Vegas
www.myCADsite.com
===================
The Back Stoep
=============
Things you would never know if it weren't for the movies............

Large, loft apartments in New York City are plentiful and affordable,
even if the tenants are unemployed.
One of a pair of identical twins is evil.
Should you decide to defuse a bomb, don't worry about which wire to cut.
You will always choose the right one.
It doesn't matter if you are greatly outnumbered in a fight involving martial arts.
Your enemies will wait patiently to attack you one by one... dancing around in
a threatening manner until you have dispatched their predecessors.
When you turn out the light to go to bed, everything in your bedroom will still be
clearly visible but slightly blue.
If you are blonde and pretty, it is possible to be a world-famous expert on nuclear
fission, dinosaurs, hieroglyphics, or anything else, at the age of 22.
All beds have special L-shaped covers that reach up to the armpits of a woman
but only to the waist of the man lying beside her.
It's easy to land a plane, providing there is someone in the control tower to
talk you down.
The ventilation system of any building is the perfect hiding place.
No one will ever think of looking for you in there, and you can travel to any
other part of the building without difficulty.
Should you wish to pass yourself off as a German officer, it is not necessary to
speak the language. A German accent will do.
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (8 of 10) [23/03/2005 05:48:31 p.m.]
A man will show no pain while taking the most horrific beating, but will wince
when a woman tries to clean his wounds.
If staying in a haunted house, women must investigate any strange noises in
their most diaphanous underwear, which is what they happened to be wearing
when the car broke down.
All bombs are fitted with electronic timing devices with large red readouts so you
know exactly when they're going to go off.
A police detective can only solve a case after he has been suspended from duty.
If you decide to start dancing in the street, everyone around you will be able to
mirror all the steps you come up with, and hear the music in your head.
Police departments give their officers personality tests to make sure each is
assigned a partner who is their total opposite.
When they are alone, all foreigners prefer to speak English to each other.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download all the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (9 of 10) [23/03/2005 05:48:31 p.m.]
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-09
http://www.afralisp.com/newsletter/2004/2004-09.htm (10 of 10) [23/03/2005 05:48:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-10
=========================
Tuesday 29th March 2004
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Visit "The CAD Vault" NOW....
http://www.cadvault.com/forums
=========================
Move your vowels every day or
you'll get consonated.
=========================
The Front Stoep.
==============
I'm sat in front of my PC writing this with removal men busy loading up the
truck.
Sorry, but I've got to sign off. I'll be back in about two weeks and this
time
from a new country and home. My email address will remain active for the
foreseeable future, but please don't expect any sort of reply for a few
days.
Pearls of Wisdom
===============
Don't use a big word where a diminutive one will suffice.
===============
Coding
=======
Kenny
Your readers who use 'Page setup names' when plotting may be interested in
this program.
Often we receive drawings from other offices, which contain page setup names
for their
printers. Or sometimes, I simply forget to define the page setups when I
first start one of
my own drawings. The program first deletes all the existing page setup
names in the
current drawing and then replaces them with the page setup names defined in
another
drawing. I chose, in this case, to hard code into the program the drawing
name containing
the required page setup names. For this reason, anyone using this program
must change
one line of the program to suit their own situation.
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (1 of 10) [23/03/2005 05:48:32 p.m.]
That is, change the line:
(command "psetupin" "C:/BLANK_DRAWING/BLANK.DWG" "*") ; <--<<< Drawing
containing default page to point to a drawing that contains the required
page setup names.
;CODING STARTS HERE
; Setup named Page Setups - C Green 22/3/2004
; Program first deletes existing page setups
(defun c:psetup ( / ans ps)
(princ "\Update page setups:")
(initget 1 "Y y N n")
(setq ans (getkword "\nAre you sure you want to delete the current page
setups? (Y or N): "))
(setq ans (strcase ans))
(if (= ans "Y")
(progn
(vl-load-com)
; Get the page setups
(vlax-for ps (vla-get-plotconfigurations
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vla-delete ps) ; Delete the current page setup
);vlax-for
(princ "\nOld page setups deleted.")
(command "psetupin" "C:/BLANK_DRAWING/BLANK.DWG" "*") ; <--<<< Drawing
containing default page setups.
(princ "\nNew page setups added. Please save your drawing.")
);progn
);if
(princ)
)
;CODING ENDS HERE
Green House
============
Hey Kenny, this one's for John Dam:
;CODING STARTS HERE
; Breaks using intersection osnap
(defun C:BREAKLINE ()
(setvar "cmdecho" 0)
(setq PK1 (getvar "pickbox"))
(setvar "pickbox" 6)
(setq OM (getvar "osmode"))
(setvar "osmode" 32)
(setq AP1 (getvar "aperture"))
(setvar "aperture" 10)
(setq HILITE (getvar "highlight"))
(setvar "highlight" 1)
(while
(setq LN (entsel "\nChoose Line to Break .... "))
(setvar "osmode" 32)
(setq BKPT (getpoint "\nPick Break Intersection .... "))
(command "break" LN "f" BKPT "@")
(setvar "osmode" 0)
)
(setvar "osmode" OM)
(setvar "pickbox" PK1)
(setvar "aperture" AP1)
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (2 of 10) [23/03/2005 05:48:32 p.m.]
(setvar "highlight" HILITE)
(setvar "cmdecho" 1)
(princ)
)
(princ)
;CODING ENDS HERE
Bob Abernethy
=============
Kenny
Please find below two 'swap block' programs that I use that may be of
interest to John Dam. I wrote these programs over 10 years ago - they may
not be very elegant, but they do work. Note that no checking is done for
attributes.
The first is called: SB.lsp. The program first asks you to select the
blocks - pick as required or window large areas. Then you type in the name
of the block to be changed (or Enter for all blocks). Then type in the
name of the new block you want the old blocks to be changed too.
The second is called SBP.lsp. The program first asks you to select a block
which will be the NEW block. Then the select the blocks to change - pick
as required or window large areas. Then you type in the name of the block
to be changed (or Enter for all blocks).
Regards
Craig Green
==========
;CODING STARTS HERE
; SBP command - Swap block to match the one pointed too.
; C Green 10/3/1999
(defun c:sbp ()
(setq nb (entsel "\nPoint to block to match: "))
(setq nb (car nb))
(if (= "INSERT" (cdr (assoc 0 (setq e (entget nb)))))
(progn
(setq c (assoc 2 e))
(setq nb (cdr c))
;
(prompt "\nSelect blocks to change... ")
(setq chm 0 p (ssget)) ; Select objects
(if p ; If any objects selected
(progn
(setq ob (getstring "\nOld block name. <Entre> For all blocks: "))
(setq ob (strcase ob))
(setq nb (strcase nb))
(setq l 0 n (sslength p))
(while (< l n) ; For each selected object...
(if (= "INSERT" (cdr (assoc 0 (setq e (entget (ssname p l)))))); Look
for INSERT entity type
(progn
(setq entl (entget (ssname p l)))
(setq l (+ 1 l))
(setq c (assoc 2 entl))
(setq bn (cdr c)) ; Existing block name
(if (or (= bn ob) (= ob ""))
(progn
(setq d (cons (car c) nb))
(setq e2 (subst d c entl))
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (3 of 10) [23/03/2005 05:48:32 p.m.]
(entmod e2)
(setq chm (1+ chm))
)
)
)
(setq l (1+ l))
)
)
)
)
(princ "Changed ")
(princ chm)
(princ " blocks.")
(terpri)
)
(prompt "\nNot a block!")
)
(princ)
)
(princ)
;CODING ENDS HERE
======
;CODING STARTS HERE
; SB command - Swap block
; C Green 27/4/1990
(defun c:sb ()
(setq chm 0 p (ssget)) ; Select objects
(if p (progn ; If any objects selected
(setq ob (getstring "\nOld block name. <Entre> For all blocks: "))
(setq ob (strcase ob))
(setq nb (getstring "\nNew block name: "))
(setq nb (strcase nb))
(setq l 0 n (sslength p))
(while (< l n) ; For each selected object...
(if (= "INSERT" ; Look for INSERT entity type
(cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq entl (entget (ssname p l)))
(setq l (+ 1 l))
(setq c (assoc 2 entl))
(setq bn (cdr c)) ; Existing block name
(if (or (= bn ob) (= ob ""))
(progn
(setq d (cons (car c) nb))
(setq e2 (subst d c entl))
(entmod e2)
(setq chm (1+ chm))
)
)
)
(setq l (1+ l))
)
)
))
(princ "Changed ")
(princ chm)
(princ " blocks.")
(terpri)
(princ)
)
(princ)
;CODING ENDS HERE
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (4 of 10) [23/03/2005 05:48:32 p.m.]
=================
To Kenny,
How can I inport my standard dimension variables to another person's drawing
and override his dimension variables automatically?
I'm using Autocad 2002.
Also, while I have your attention, do you know if the graphic acceleration
software 'SoftEngine' Virbrant Graphic is still in existance?
Good luck on your new job and new pad.
Matt
=====
Cheers, Kenny,
Great newsletter, this week. Eager to here the news, about the new gig.
Check out http://www.btlsp2000.com/cpstc.lsp, for a routine to straighten
lines, that vary slightly from the vertical or horizontal.
BT
===
Hi Kenny,
I wrote u before about the dimension Linear Scale Factor.
Some how I manage to get it through Vlisp.
Here is below my source code. u may publish in ur mail if
it is useful to some one else. & also if u know some thing
better please give me a shout on mail.
Thanks.
hear u on mail again soon.
Siraj Kazi.
==========
;CODING STARTS HERE
(defun c:psdsf (/ dimob dimobjt)
(if (setq dimob (entsel "\n *** Select Dim To get Dimscale...."))
(progn
(setq dimobjt (vlax-ename->vla-object (car dimob)))
(if (vlax-property-available-p dimobjt 'linearscalefactor)
(progn
(alert (strcat "Dimension Scale Factor = " (rtos
(abs
(vla-get-linearscalefactor dimobjt)
)
)
)
)
(prompt (strcat "\n *** Dimension Scale Factor = " (rtos
(abs
(vla-get-linearscalefactor dimobjt)
)
)
)
)
)
(alert "Selected Object is Not A Dimension. Try again ....")
)
(princ)
)
)
)
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (5 of 10) [23/03/2005 05:48:32 p.m.]
;CODING ENDS HERE
==================
Re:----BREAKLINE with polylines
John,
As you write in the AfraLisp newsletter N0. 2004-9: polylines does not have
(assoc 10) and (assoc 11) but they do have "coordinates".
Because we are going to use ActiveX I will give you some of the code needed
because it is a bit complex to explain the finer points of the used
instructions in this newsletter.
If you need / want to know more about the used code and ActiveX look at the
tutorial page of the AfraLisp website for more info about ActiveX.
Those tutorials are really great and understandable.
First you have to determine if the line is a "LINE" or a "LWPOLYLINE".
(if (or (= cdr (assoc 0 (entget (ssname selc 0)))) "LINE")
(= cdr (assoc 0 (entget (ssname selc 0)))) "LWPOLYLINE")
You must use capitals in element names. AutoCAD demands it.
Let us presume you have selected a polyline (because that is all what this
is about).
To determine the endpoints of this polyline we have to use some ActiveX
objects.
Get the entity name:
(setq TheLineEname (ssname selc 0))
Make it a ActiveX object:
(setq TheLine (vlax-ename->vla-object TheLineEname))
Extract the coordinates:
(setq ListCoordinates
(vlax-safearray->list
(variant-value
(vla-Get-Coordinates TheLine)
)
)
)
Extract start and endpoint of the polyline:
(setq StartPoint (car ListCoordinates))
(setq EndPoint (caddr ListCoordinates))
Now all you have to do is implement this coding into your application.
Do not forget to put (vl-load-com) at the beginning of your routine to add
Arx capabilities, even before (defun C:--.
Last remark(s):
1) You have not declared any off the used variables in your
application.
It is (very) good practise to do so in order to forestall
interferences
from/with other applications.
For example pt1 and ent1 are variables that are so commen, that
everyone use them in every application they make.
2) You are using the AutoCAD command scaleas a varriable.
Please do not do this but use for instance MyDimScale.
3) Using full written variables improve the readebility of the code.
Use EndPoint instead of pt2.
Joop Moelee
===========
Things Weird and Wonderful
========================
For Sale By Mental Patient
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (6 of 10) [23/03/2005 05:48:32 p.m.]
http://www.total.net/~fishnet/
Porcelain Palace: Toilets
http://www.tornadohills.com/
Manson Family Picnic
http://www.mansonfamilypicnic.com/
Herman's Banana Heaven
http://members.aol.com/bumingler/bananas.html
Miscellaneous Stuff that I almost Forgot
================================
The following is from the latest Cad Encoding Newsletter :
IMPROMPTU INTERVIEW
=====================
o Taking a moment out with Kenny Ramage
Kenny Ramage has been an understated member of the CADD community for
years. I say
understated because he doesn't post boisterous comments at the Autodesk
controlled
forums, he doesn't spend time puffing his ego up at AUGI, and he does very
little
to draw attention to the massive amount of AutoLisp and VBA tutorials he
has written
over the last decade. On the other hand...
Lead singer
Guitar Player
Self-Trained Programmer
Webmaster
Husband
Father
Teacher to thousands.
...this man is larger than life and twice as ugly.
Kenny has recently made some big changes in his work and personal life,
moving from
his position and home in Oranjemund to Cape Town, and this looked like the
perfect
opportunity (he's bound to be drunk from the farewell parties) to ask a
few pointed
questions about the past and future of both AfraLisp and my favorite band
in the sand,
BedRock...
o Q. When you created AfraLisp, did you have any idea of what you might be
getting
yourself into?
Not a clue. I basically started with the intention of learning HTML. To do
that,
I had to of course have a website. At first I wanted to produce a
music website, but I wasn't playing in a band at the time so that seemed
to
be a bit pointless. I'd been dabbling in AutoLisp for a couple of years
and
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (7 of 10) [23/03/2005 05:48:32 p.m.]
had picked up a few buddies via e-mail. (I had e-mail for years before I
had
the Internet.) I thought, hey that's a great subject to create a website,
go
for it. I posted a couple of routines and was then asked a few questions.
The few questions turned into many and I realized that I was answering the
same questions time after time. Henceforth the tutorials started and have
never finished and probably never will.
============
o Q. We know you are a Rock & Roll Man, but how did you get to be part of
the Band in the Sand?
After leaving school I started a draughtsman's apprenticeship. During
that time, and to supplement my income, I played semi-professional in
Johannesburg. On completing my apprenticeship, I played fully professional
for about 3 years. Then the babies came!!!!! I now had to get a "proper"
job.
In 1989 we made the decision to relocate to Namibia. At that time I was
playing the pub circuit on weekends only. Arriving in Oranjemund, I
discovered that there was very little room for a band in our small town
and
anyway, I was a bit pissed off with music in general. Eight years later,
and
after a few drinks at a barbeque, I allowed myself to be convinced that
coming out of "musical retirement" might be a good idea. (My wife Heather
by
the way was one of the main instigators.) Imagine my delight when I
discovered the availability of digital recording units. This was the real
reason I went back to music. Before this, the cost of recording in a
studio
was so prohibited and run by arseholes. Now I could do what I wanted.
===============
o Q. Speaking of BedRock, when is the next album going to be produced?
Hah, now I am in a dilemma. Due to my relocation to Cape Town, I
officially "left" BedRock on the 13th March. Don't worry, I will still be
recording and playing - albeit with people yet to be found.. Next album?
Maybe towards the end of this year. (I've got most of the material written
already.)
============
o Q. What the hell is a Stoep and why is it in the back?
A Stoep is the Afrikaans word for back or front porch. It's where all the
drinking, gossiping, kissing and serious business discussions take place.
=============
o Q. SPAM, it's flooding the inboxes of the world and making it harder for
people like you and I to reach our audiences using e-mail as a
delivery
system. Do you have any plans to change how you reach your readers, or
will we be seeing "Tara the noo" for many years to come?
I have no intention of stopping the Newsletter. Changing the format
slightly to suit? Yes if necessary. I enjoy the Newsletter. I look forward
to compiling it every week. I just wish that more people would contribute
more in the way of articles and just generally talking shit. Content does
get to be a hassle, and as you know, there are lot's of very talented
people
out there with a good command of the English language. To get an article
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (8 of 10) [23/03/2005 05:48:32 p.m.]
out
of them though is worse then removing nose hairs with a bolt cutter.
SPAM is a problem, but I just filter out the rubbish. Hopefully my
subscribers will do the same and continue to support the Newsletter.
Anyway,
this SPAM cannot go for ever can it? Really, can it?
=============
o Q. Q.B.E.? You just made that up, didn't you? Admit it!
Q.B.E. stands for "Qualified By Experience." I have no formal education
whatsoever in the coding field. I need to protect myself somehow in case
of
law suits or even diving suits for that matter.
Could it end on a better comment? I don't think so.
Randall Rath
===========
The Back Stoep
=============
The difference between a LADY and a REAL Woman!!!!!
Ladies - If you accidentally over-salt a dish while it's still cooking, drop
in a peeled potato and it will absorb the excess salt for an instant
"fix-me-up."
Real Woman - If you over-salt a dish while you are cooking, that's too damn
bad. Please recite with me, The Real Women's motto: "I made it and you will
eat it and I don't care how bad it tastes."
Ladies - Cure for headaches: Take a lime, cut it in half and rub it on your
forehead. The throbbing will go away.
Real Woman - Take a lime; mix it with tequila, chill and drink. You might
still have the headache, but who cares?
Ladies - Stuff a miniature marshmallow in the bottom of a sugar cone to
prevent ice cream drips.
Real Woman - Just suck the ice cream out of the bottom of the cone, for
Pete's sake. You are probably lying on the couch, with your feet up, eating
it anyway.
Ladies - To keep potatoes from budding, place an apple in the bag with the
potatoes.
Real Woman - Buy boxed mashed potato mix and keep it in the pantry for up to
a year.
Ladies - When a cake recipe calls for flouring the baking pan, use a bit of
the dry cake mix instead and there won't be any white mess on the outside of
the cake.
Real Woman - Go to the bakery - they'll even decorate it for you.
Ladies - Brush some beaten egg white over pie crust before baking to yield a
beautiful glossy finish.
Real Woman - Woolies frozen pie directions do not include brushing egg
whites over the crust, so I just don't do it.
Ladies - If you have a problem opening jars, try using latex dishwashing
gloves. They give a non slip grip that makes opening jars asy.
Real Woman - Go ask the very cute neighbour to do it.
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (9 of 10) [23/03/2005 05:48:32 p.m.]
And finally the most important tip....
Ladies - Don't throw out all that leftover wine. Freeze into ice cubes for
future use in casseroles and sauces.
Real Woman - Leftover wine??
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download all the AfraLisp Newsletters, in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-10
http://www.afralisp.com/newsletter/2004/2004-10.htm (10 of 10) [23/03/2005 05:48:32 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-11
=========================
Monday 26th April 2004
=========================
http://www.afralisp.com
mailto:kramage@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
9 out of 10 men who try Camels prefer women.
=========================
The Front Stoep.
==============
Hey, we made it!
We are now resident in Cape Town, South Africa. I've got a great job and a
great bunch of people to work with. Before I go any further though, I must
ask you to take note of my new email address:
mailto:kramage@iwynberg.com
Please ensure that you use this address from now on as my old mailbox is
now an ex-mailbox - it is deceased - it is no more - it is pushing up the daisies.
It took a wee while to get on line due to communications problems that we all
live with here in Africa, but I didn't really mind as the break was rather nice.
Not much a letter this week as nobody seemed to want to write to me??
But, the doors are all open once again and I'm looking forward to a flood of
question, answers, jokes, etc, etc..........( Hint, hint ).
Oh, by the way, any readers out there from Cape Town?
If so, please drop me line or give me a buzz on 082-8304998.
It would be great to have a beer or ten together.
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (1 of 11) [23/03/2005 05:48:34 p.m.]
And now a double Oh, Oh.
Anyone interested in customising IntelliCAD?
Pearls of Wisdom
===============
Wine is sunlight, held together by water.
===============
Coding
=======
Hello from Charlotte, North Carolina
I am a dedicated reader of your newsletter and have usually been able to
solve my autocad problems on websites like Afralisp or on the
newsgroups, not this time though. Please help!
In trying to create some way of quickly checking for ADA and code
compliance in our building designs I have started placing the code into
our standard blocks. So our door block has several non-printing layers
that contain various dimensions, guidelines, and notes to assist the
user in meeting code. This generally works well until the block gets
mirrored rotated etc. and the text becomes unreadable.
Is there any way of placing text into a block in a way that will force
it to stay horizontal and non-mirrored? Or could I possibly write a
program that could search through a drawing and somehow?? fix the text
in the blocks that are messed up?
Thanks so much,
Zachary Kane
============
Dear Sir,
Currently i'm using Autocad 2004....
In this pkg...some new features is I can't explain....
I need your help....
How to create tool palettes file (extension is .xpt) ?
I want add lisp routine in tool palettes....
Your's,
Alpesh Upadhyay
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (2 of 11) [23/03/2005 05:48:34 p.m.]
===============
Sending Code snippets to the forum for others to get benefits out is indeed
a generous act, but it would be nice that the code should be complete, bug
free or if their any bugs they must be highlighted.
In this regard, I shall point out the Lisp utility forwarded by :
BILL TONNESEN EMAIL >> BT_DND@HOTMAIL.COM
;cpstc.LSP 040209 Square all lines
The following functions were used in the utility but was not included in
the code.
1) SVar .
2) mget .
3) prj
4) mag
5) dispn
6) (itzovr)
Regards,
UbaidUllah
==========
Hi there,
I have been working on a lsp routine to make an archived copy of a working
drawing.
Step 1. Save the existing drawing.
Step 2. Renames the drawing by prefixing with archive then the date
Step 3. Bind all xrefs
Step 4. Purge the drawing (3 times)
Step 5. Save and close the archive drawing and open the existing drawing.
For some reason that I cant see it trips at step 3.
Can you advice me where I'm going wrong?
Thanks
Iain Johnson
===========
;CODING STARTS HERE
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (3 of 11) [23/03/2005 05:48:34 p.m.]
(defun c:archive ()
;define function
(alert "Ensure all unloaded Xrefs are detached")
;warning to remove unloaded xrefs
(setvar "HIGHLIGHT" 0)
;switch off highlight
(setvar "CMDECHO" 0)
;switch off command echo
(setq thedate (today))
;calculate and format date
(setq DN (getvar "DWGNAME"))
;get drawing name
(setq DP (getvar "DWGPREFIX"))
;get drawing path
(setq TM (strcat DP DN))
;make full path for file
(setq DAF (strcat DP "archive " thedate " "DN))
;make new drawing archive file name
(command "saveas" "" "y" "")
;save existing drawing
(command "saveas" "" DAF "")
;save existing drawing
(command "xref" "" "B" "" "*")
;bind all xrefs
(command "purge" "" "A" "")
(command "purge" "" "A" "")
(command "purge" "" "A" "")
;bind all purge drawing x3
(command "close" "" "y" "")
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (4 of 11) [23/03/2005 05:48:34 p.m.]
;close and save bound drawing
(command "open" "" TM "")
;save existing drawing
(setvar "ATTDIA" 1)
;switch the dialogues back on
(setvar "HIGHLIGHT" 1)
;switch Highlight On
(setvar "CMDECHO" 1)
;switch Cmdecho On
(princ)
);defun
;=========================================================
(defun TODAY ( / d yr mo day)
(setq d (rtos (getvar "CDATE") 2 6)
yr (substr d 3 2)
mo (substr d 5 2)
day (substr d 7 2)
);setq
(strcat day "." mo "." yr)
);defun
(princ)
;CODING ENDS HERE
==================
Userforms
=========
If you have programmed with AutoLisp and the Dialogue Control Language (DCL),
you will be familiar with designing dialogue boxes. Compared to DCL though,
designing dialogue boxes in VBA is a breeze. The basis of all dialogue boxes in
VBA is the Userform. This Tutorial will show you how to display and manipulate
Userforms.
A Userform is a container that holds all the controls such as labels, textboxes,
pictures, etc. that make up part of your applications interface.
A Userform has it's own Properties, Methods and Events. Let's have a look at some
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (5 of 11) [23/03/2005 05:48:34 p.m.]
of them :
Displaying a Userform
==================
The syntax for displaying a Userform is as follows :
UserFormName.Show
So, to display a Userform named Userform1, you would use the following code:
Userform1.Show
If you want to, you can preload the Userform into memory without actually displaying it.
This can be useful as it can sometimes take a few seconds for a complex Userform to appear.
The ability to preload the Userform allows you to decide when you would like this operation
to take place. To preload a Userform you would use the following code :
Load Userform1
Hiding/Unloading a Userform
========================
To temporarily hide a Userform, you would use the Hide method. This is a very good example
of how dialogue boxes in VBA are so much simpler than in AutoLisp. To hide a Userform you
would use the following code:
Userform1.Hide
To Unload a Userform from memory use the following code :
Unload Userform1
You could also use the 'Me' keyword :
Unload Me
Useform Events
=============
Userforms support many predefined events. Among the most commonly used events are
Initiliaze, Click and Terminate events.
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (6 of 11) [23/03/2005 05:48:34 p.m.]
Note A VBA module that contains an event procedure can be called a module
'behind' the Userform. A module that contains event procedures is not visible in the Modules
collection of the Projects window of the VBA Editor. You must double-click the body of the
Userform to view the Userform Code Module.
Let's have a look at some Userform Events. Start your VBA Editor and insert a
Userform into a new Project. Double-Click the Userform and type in the following code:
Private Sub UserForm_Click()
Me.Height = Int(Rnd * 500)
Me.Width = Int(Rnd * 750)
End Sub
Private Sub UserForm_Initialize()
Me.Caption = "Userform Events"
Me.BackColor = RGB(10, 25, 100)
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
msg = "Now Unloading " & Me.Caption
MsgBox prompt:=msg, Title:="QueryClose Event"
End Sub
Private Sub UserForm_Resize()
msg = "Width: " & Me.Width & Chr(10) & "Height : " & Me.Height
MsgBox prompt:=msg, Title:="Resizing Event"
End Sub
Private Sub UserForm_Terminate()
msg = "Now Unloading " & Me.Caption
MsgBox prompt:=msg, Title:="Terminate Event"
End Sub
Now run the Userform.
This is what happens when you run the project:
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (7 of 11) [23/03/2005 05:48:34 p.m.]
Firstly, The Intialize event procedure changes the Caption property to "Userform Events"
and the Backcolor property to dark Blue.
When you click the Userform the Click Event procedure is initiated and the Userform is
re-sized. Also, because you created a resize event procedure, you receive 2 message boxes.
The resize event occurs twice because your code behind the click event changed both the
Width and Height properties of the Userform.
When you close the Userform, the QueryClose event procedure is triggered. This displays
a message box with the caption you gave the Userform in the code for the Initialize event.
The QueryClose event is useful when you want to perform a certain set of actions when the
Userform is closed by the user.
The Terminate Event then triggers a message box which states that the Caption of the
Userform is Userform1. The Terminate Event occurs after the Userform is removed from memory
and the Caption of the Userform returns to it's original state.
========================
Things Weird and Wonderful
========================
Bob The Disappearing Worm's Vast Chunk of Worm Heaven
http://csmctmto.interpoint.net/orchyd/
===============================
International Headquarters of Losers and Smartasses
http://www.geocities.com/SoHo/Lofts/3856/smartass.htm
===============================
Swedish Cursing
http://www.bart.nl/~sante/enginvek.html
===============================
Ink-blot Test Wallpaper
http://www.inkblottestwallpaper.com/
===============================
Miscellaneous Stuff that I almost Forgot
================================
I've just heard the Michael Jackson is breaking up........
============
Kenny's new company:
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (8 of 11) [23/03/2005 05:48:34 p.m.]
http://www.et-global.com
======================
The Back Stoep
=============
The How and Why of Electricity
==========================
Submitted by J.F.Moelee
Electricity is made in factories, where it is stored in electric cables.
That is why electric cables are long. Sometimes electric cables are stored on
cable-reel to accumulate more kilowatts. The bigger the reel the more kilowatts.
Some sorts of electricity do not use cables, like lightning and portable radios.
This kind of electricity is not generated but can be found in a draught.
Electricity generates a low buzzing sound.
One can use this in doorbells, phones and electrical organs.
Electricity must be connected to earth, except with planes and the
applications in paragraph two.
Electricity is made from two ingredients: positive and negative.
In The Netherlands one has a liking for brown wire and the other for blue wire.
When those two met in a plug, they will mix and you have electricity.
Electricity can also be stored in batteries.
It is not common that a big battery contains more electricity than a small one.
It depends on how empty it is. Big batteries are filed with a shovel,
small ones with a pair of tweezers.
A light switch is some sort of clamp that squeezes the wire so hard the electricity
is stopped. If one operates the switch, the pressure is released and the electricity
flows to the bulb.
A bulb is a piece of wire in which one can see the pure essence of electricity.
Normally the wire is isolated, however not in the bulb and that is why one can
see the electricity. The special spherical form acts as a magnifying glass to see
the electricity more clearly.
Light bulbs have a limited live span, because the heat turns the oxygen in the bulb
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (9 of 11) [23/03/2005 05:48:34 p.m.]
into water. In time the water level in the bulb reaches the wire and the light bulb
goes out permanently.
When the light suddenly disappears there may be three causes:
a. The bulb filled with water and the light extinguish.
b. The horrible boy next-door holds the electrical cable with a kink so no electricity
can pass anymore.
c. One off the cable reels in the factory went out of electricity and the watchman
forgot to replace it with a fresh one.
Although the industry makes perfect good wires, i.e. wire netting, it is not allowed to
use them in an electrical installation. The electricity looses its heat to fast and the
electricity factory can do nothing with this used electricity.
Nowadays many electricity factories also make intelligent electricity.
They store them in so-called glass-fibre cables. With this special, but more expensive,
electricity devices like computers and intelligent toasters are being kept running.
Characteristics of this electricity are it does not buzz but makes a creaky sound
and is much less visible as ordinary electricity.
That is why this electricity cannot be used in light bulbs.
Fuses are removable peaces of wire through which electricity flows after it is used
to cool down. Despite all technological innovation during the last time, it still is not
possible to make those pieces of wire thick enough, so they break down easily.
The industry expects to develop very soon a fuse that lasts longer.
If a computer or intelligent toaster suddenly quits the causes named in paragraph ten
may be the reason.
But with intelligent electricity it is possible that the electricity is not intelligent enough
for the device in question.
That is why most computers and toasters also use standard electricity.
The knowledge acquired by the device enables it to upgrade the intelligence of normal
electricity.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (10 of 11) [23/03/2005 05:48:34 p.m.]
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download all the AfraLisp Newsletters, in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-11
http://www.afralisp.com/newsletter/2004/2004-11.htm (11 of 11) [23/03/2005 05:48:34 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-12
=========================
Monday 3rd May 2004
=========================
http://www.afralisp.com
mailto:kramage@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Visit the Expresso Cafe
http://www.vbdesign.net/expresso
=========================
Oh! Oh! Oh! - Dyslexic Santa.
=========================
The Front Stoep.
==============
Very busy last week and even busier this week. A BIG presentation tomorrow - more
on this at a later stage - and then I'm off back to Namibia on Wednesday. I've been invited
to Oranjemund by the General Manager of the company I used to work for.
It's his 50th birthday and he has requested my presence as he's booked BedRock
and of course, at this stage they are short of a lead guitarist/vocalist.
I can't complain, as I'm travelling there and back on the Citation AND I get paid
AND wined and dined whilst I'm there. All at their expense!!!
(All together now, "Happy Days are here again.............."
It's also a good opportunity to drum up some business for my new company.
(Ha, I'm devious hey?)
Have you had a look at the "Cad Vault" yet?
http://www.cadvault.com
Check out the "Freelance CAD Counter" section.....
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (1 of 13) [23/03/2005 05:48:36 p.m.]
=========================================
P.S. Anyone interested in customising IntelliCAD?
I won't ask again!!! Well maybe not.......
Pearls of Wisdom
===============
Hold a hard drive to your ear and listen to the C.
===============
Coding
=======
Given a list:
(1 25 26 13 1 6 5 89 1 554 2 1 1 8744 55 551 15656 5485 654 1 5)
entering:
(match testlist 1)
will return:
(0 4 8 11 12 19)
;CODING STARTS HERE
(defun match (lst num / tmp)
(setq idx 0)
(mapcar '(lambda (x)
(if (eq x num) (setq tmp (cons idx tmp)))
(setq idx (1+ idx))
)
lst)
(reverse tmp)
)
;CODING ENDS HERE
Jeff Mishler
==========
Kenny,
Sounds like you are happy to be in Cape Town. Welcome back!
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (2 of 13) [23/03/2005 05:48:36 p.m.]
Re UbaidUllah's request for a list of support routines to a primary routine,
"cpstc.lsp", latest edition, Afralisp, please refer him to the "fntn" series of
files at http://www.btlsp2000.com/page9.html.
Cheers, ...Bill
===========
Dear Kenny,
Im a beginnerso excuse me please?
Im trying to write an SSGET filter list that, among other things,
will filter all entities with a Z-Coordinate greater than 10 (say).
Ive tried the help files and even checked out your Selection
Sets tutorial (which taught me how to start using them by the way)
but seem to be blind to the solution.
Ive prayed before for insights and received them, but this one Id
like to hand over to You. I know youre not God, but (laughing) you
might be able to help me!?
Mit freundlichen Grssen,
Mark Leslie
==========
Do you know where I can find the Lisp routine that transfers mouse
selected entities from paper space to model space while retaining
the scale and vise versa?
Thanks,
Dennis C. Agabon
===============
Kenny
Good to hear you made it to Cape Town. Great to hear your job is working out OK.
Some of your readers may be interested in the attached program that is based on a
program I wrote more than 10 years ago now. The program called "setout.lsp" can be
used to layout blocks on architectural building plan drawings. The program inserts
blocks in rooms with the spacing between the blocks equal to twice the spacing between
the walls and the blocks. It can be used to help layout luminaires (light fittings),
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (3 of 13) [23/03/2005 05:48:36 p.m.]
fire detectors, loud speakers etc. on electrical plans etc. If your readers are
interested, I could provide a version that 'locks' the blocks into the center of the
nearest ceiling tile and accommodates blocks with one attribute.
I have developed the core of this program into very useful automatic lighting and
fire detector design programs. The main restriction of this program is that the
rooms must be horizontal. However, I haven't found this to be too much of a problem.
Regards
Craig Green
;CODING STARTS HERE
; setout.lsp - C Green - 1/5/2004 - Block layout program
;
; Note:
; Does not handle blocks with attributes
;
; Tip: Hit <Enter> for room points = previous room points
;
(defun c:setout ( / ang blk blkpt col col2 cx cy dx dxw dy dyw lenx leny lnx lny offx
offy row row2 sblip sc scd scmde tmp x1 x2 y1 y2)
;(defun c:setout ()
;I know... too many variables!
;
; DEFAULT BLOCK NAME, ANGLE AND SCALE - CHANGE TO SUIT.
(cond ((= blkd nil) (setq blkd "block1"))) ; <--- Default block name
(cond ((= angd nil) (setq angd 0.0))) ; <--- Default angle
(cond ((= scd nil) (setq scd 100.0))) ; <--- Default block scale
;
; Get user's input
(prompt "\nSetout V1.0 - Block layout program:")
; Get Room co-ordinates
(prompt "\nTwo points to define room.")
(setq pt1 (getpoint "\nFirst corner: "))
(if (= pt1 nil) (setq pt1 pt1d) (setq pt1d pt1))
(setq pt2 (getcorner pt1 "\nSecond corner: "))
(if (= pt2 nil) (setq pt2 pt2d) (setq pt2d pt2))
; SWAP pt1 AND pt2 IF REQUIRED
(setq x1 (car pt1))
(setq x2 (car pt2))
(setq y1 (cadr pt1))
(setq y2 (cadr pt2))
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (4 of 13) [23/03/2005 05:48:36 p.m.]
(if (> x1 x2)
(progn
(setq tmp x1)
(setq x1 x2)
(setq x2 tmp)
)
)
(if (> y1 y2)
(progn
(setq tmp y1)
(setq y1 y2)
(setq y2 tmp)
)
)
(setq pt1 (list x1 y1 0.0))
(setq pt2 (list x2 y2 0.0))
;
(setq lenx (- (car pt2) (car pt1)))
(setq leny (- (cadr pt2) (cadr pt1)))
;
(prompt "\nName of block: <")
(prin1 blkd)
(prompt "> ")
(setq blk (getstring))
(cond ((= blk "") (setq blk blkd)))
(cond ((/= blk "") (setq blkd blk)))
;
(prompt "\nScale of block: <")
(prin1 scd)
(prompt "> ")
(setq sc (getstring))
(cond ((= sc "") (setq sc scd)))
(cond ((/= sc "") (setq scd sc)))
;
(setq col (getreal "Number in x direction <1>: "))
(if (= col nil) (setq col 1.0))
(setq row (getreal "Number in y direction <1>: "))
(if (= row nil) (setq row 1.0))
;
(prompt "\nAngle of block: <")
(prin1 angd)
(prompt "> ")
(setq ang (getreal))
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (5 of 13) [23/03/2005 05:48:36 p.m.]
(cond ((= ang nil) (setq ang angd)))
(cond ((/= ang nil) (setq angd ang)))
;
(prompt "Working...")
(setq sblip (getvar "blipmode"))
(setq scmde (getvar "cmdecho"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
;
(setq row2 (* 2.0 row))
(setq col2 (* 2.0 col))
(setq dyw (/ leny row2))
(setq dxw (/ lenx col2))
(setq dy (* 2.0 dyw))
(setq dx (* 2.0 dxw))
(setq cx (car pt1))
(setq cy (cadr pt1))
(setq cx (+ cx dxw))
(setq cy (+ cy dyw))
(setq pt1 (list cx cy))
;
; Layout all the blocks
(setq blkpt pt1)
(setq offy 0.0)
(setq lny 0.0)
(while (< lny row)
(setq offx 0.0)
(setq lnx 0.0)
; Draw one row of blocks
(while (< lnx col)
(command "insert" blk blkpt sc sc ang)
(setq offx (+ offx dx))
(setq lnx (+ lnx 1.0))
(setq blkpt (polar blkpt 0.0 dx))
)
(setq offy (+ offy dy))
(setq lny (+ lny 1.0))
(setq blkpt (polar pt1 (/ pi 2.0) offy))
)
(setvar "blipmode" sblip)
(setvar "cmdecho" scmde)
;
(prin1)
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (6 of 13) [23/03/2005 05:48:36 p.m.]
)
;CODING ENDS HERE
Craig Green
===========
Things Weird and Wonderful
========================
Most Important Software Products
http://www.byte.com/art/9509/sec7/art5.htm
====================================
SAC
http://www.sac.sk/
===============
Miscellaneous Stuff that I almost Forgot
================================
VBA and Sequential Text Files
==========================
This was written anonymously by Douglas Brown, full time Baxi-Burner
Gas Central Heating Pilot Light and part time infuriating humorist.
It is thus copyright of Lennox Palace Lunatic Asylum (2004) and may not be used
without a yellow polka-dot tie. Douglas is 84.
CopyWrong Douglas Brown
=======================
Sometimes you may need to store and retrieve information but do no need
the power of a spreadsheet or database. (not to mention the extra coding,
configuration and support files that go along with it.) In these cases a text
file may be just the thing you need. The process of storing and retrieving
information is simple, and the file can be edited by anyone - even if that
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (7 of 13) [23/03/2005 05:48:36 p.m.]
person doesn't have a spreadsheet/database tool.
Let's have a look first at reading from a sequential text file.
Let's say we have a text file containing a list of standard layers that we
would like to import into AutoCAD.
Here's what we would need to do :
1. Open the file for input.
2. Read a line from the file and store it in a variable.
3. Add the contents of the variable to a list box.
4. Repeat steps 2 and 3 for each line in the file.
5. Close the file.
O.K. first let's create our text file. Open Notepad and enter these layer names :
Annotations
Architectural
Beers
Border
Civil
Dimensions
Electrical
Existing
Instrumentation
Mechanical
Piping
Steel
Text
Now save this file as Layer.txt, ensuring that it is within your support path.
Now open a new Project and Userform. Place a Listbox on the form keeping
the default name.
In the Userform Initialize event procedure, place the following code :
'CODING STARTS HERE
Private Sub UserForm_Initialize()
Dim sTemp As String
'clear listbox
ListBox1.Clear
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (8 of 13) [23/03/2005 05:48:36 p.m.]
'open the text file
Open "Layer.txt" For Input As #1
'until the end of file
While Not EOF(1)
'read the line and store it in a variable
Line Input #1, sTemp
'display in the list box
ListBox1.AddItem sTemp
'loop
Wend
'close the file
Close #1
End Sub
'CODING ENDS HERE
Run the Project. Looks good heh?
In the preceding example, 1 is the file number. However, if you open and
close multiple files throughout your program, using this number might not
be a good idea. In that case, you should use the "FreeFile" function.
I've re-written the coding below to include this function as well as some
basic error trapping :
'CODING STARTS HERE
Private Sub UserForm_Initialize()
Dim sTemp As String
Dim nFile As Integer
On Error GoTo err_handler
'get the next free file number
nFile = FreeFile
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (9 of 13) [23/03/2005 05:48:36 p.m.]
'clear listbox
ListBox1.Clear
'open the text file
Open "Layer.txt" For Input As #nFile
'until the end of file
While Not EOF(nFile)
'read the line and store it in a variable
Line Input #nFile, sTemp
'display in the list box
ListBox1.AddItem sTemp
'loop
Wend
'close the file
Close #nFile
Exit Sub
err_handler:
MsgBox Err.Number & " " & Err.Description
Err.Clear
Exit Sub
End Sub
'CODING ENDS HERE
To write data, you open the file for sequential output or append.
Have a look at the following two lines of code, each of which opens
a file for output :
'output mode - always creates a new file, erases any existing information
Open "DwgLog.txt" for Output as #nFile
'append mode - adds to an existing file or creates one
Open "DwgLog.txt" for Append as #nFile
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (10 of 13) [23/03/2005 05:48:36 p.m.]
Append mode means data written to a file is added to the end of existing data.
Opening a file for Output means that any existing data will be erased.
In either case the Open statement automatically creates the file if it does not exist.
Have a look at the following coding that when you run it, will write a Log file
containing the date, time and Drawing Number :
'CODINGSTARTS HERE
Sub DrgLog ()
Dim nFile1 As Integer
Dim Dname As String
On Error GoTo err_handler
'retrieve the drawing name
Dname = ThisDrawing.GetVariable("DWGNAME")
'get the next free file number
nFile1 = FreeFile
'open the file to append to
Open "DrgLog.txt" For Append As #nFile1
'write to the file
Print #nFile1, Format$(Now, "mm-dd-yy hh:mm:ss") & " - " & Dname
'close the file
Close #nFile1
Exit Sub
err_handler:
MsgBox Err.Number & " " & Err.Description
Err.Clear
Exit Sub
End Sub
'CODING ENDS HERE
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (11 of 13) [23/03/2005 05:48:36 p.m.]
DrgLog.txt should have been created in your working directory.
Open it and have a look. It should look something like this :
11-05-04 09:57:20 - X3481.dwg
11-05-04 19:57:21 - X3482.dwg
11-05-04 14:40:20 - K2341.dwg
11-05-04 15:21:40 - K3418.dwg
Every time the routine is run, the date, time and Drawing Number is added to the file.
(Hey, we could make a good drawing log file out of this?)
=============================
The Back Stoep
=============
A blind man and his seeing eye dog are in the supermarket doing some shopping.
Suddenly in the middle of an aisle, the man picks up his dog by the tail and starts
swinging it around. A startled shop assistant rushes over and says to the man,
"What's the matter?" she yells, "Can I help you?"
The blind man continues swinging the dog and casually replies,
"No thanks, I'm just looking around."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download most of the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
The Expresso Cafe
http://www.vbdesign.net/expresso
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (12 of 13) [23/03/2005 05:48:36 p.m.]
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-12
http://www.afralisp.com/newsletter/2004/2004-12.htm (13 of 13) [23/03/2005 05:48:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-13
=========================
Tuesday 11th May 2004
=========================
http://www.afralisp.com
mailto:kramage@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
I am a nobody, and nobody is perfect;
therefore I am perfect.
=========================
The Front Stoep.
==============
Well another week has passed us by. Can you believe that it's already
the fifth month!!! It's nearly Christmas again, and I do believe that
it's time for a new AfraLisp Project. So, have you any ideas on what
shape or form this Project should consist of? I'll have a wee think
over the next week and I would like to ask you all to do the same.
It would be nice to have something that could include all the subscribers
of this Newsletter as it would bring us all together an emotional way,
and allow to get into each others deepest thoughts and desires.
(Hee, hee hee.....)
Oh, I'm running short of content for the Coding section.
Pleeeeeeaaaase, send me something.........
Pearls of Wisdom
===============
A grenade thrown into a kitchen in France would result in
Linoleum Blownapart.
===============
Coding
=======
Would you like to automatically generate and send an email message,
with a subject and text as well as an address?
Start a new Project and insert a form.
On the toolbox, right-click and choose "Components".
Find and check the Microsoft MAPI Messages Control, and the
Microsoft MAPI Session Control.
Add them to the form along with a button control, retaining their
default names.
Now copy and paste the following code into the button's Click Event :
'CODING STARTS HERE
AfraLisp Newsletter No 2004-13
http://www.afralisp.com/newsletter/2004/2004-13.htm (1 of 4) [23/03/2005 05:48:37 p.m.]
Private Sub CommandButton1_Click()
On Error GoTo mailerr:
MAPISession1.SignOn
If MAPISession1.SessionID <> 0 Then
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose 'start a new message
.RecipDisplayName = "Kenny The Great"
'replace the following email address with your own
.RecipAddress = "you@somewhere.com"
.MsgSubject = "Message To Kenny"
.MsgNoteText = "Hi Kenny"
.Send False 'don't display a dialog
End With
MsgBox "Message sent"
Exit Sub
End If
mailerr:
MsgBox "Error " & Err.Description
End Sub
'CODING ENDS HERE
Now run the application.
(I hope you remembered to change the email address).
======================
Hello, thanks for the great newsletters. I created a copy rotate command
that I think you would like to include in your newsletter
Here it is:
;CODING STARTS HERE
(defun c:copyrotate ()
(princ "Please select the objects to copy rotate: ")
(setq FG-Obj (ssget))
(setq FG-P1 (getpoint "Base point: "))
(command "move" FG-Obj "" FG-P1 pause)
(setq FG-P2 (getvar "lastpoint"))
(command "copy" FG-Obj "" FG-P2 FG-p1)
(command "rotate" FG-OBJ "" FG-P2)
(princ)
)
(princ)
;CODING ENDS HERE
Bill.
===
Nothing is worse than accidentally triggering an option that takes a long time,
and then not being able to cancel it. It's no good having a Cancel button,
because no click event will fire until the loop is done.
The simplest way around this problem is to use DoEvents.
This command hands control back to Windows so that click events or other
actions can be processed before the loop continues.
Here's how to do it :
i) Declare a variable in the Declarations section of the form :
AfraLisp Newsletter No 2004-13
http://www.afralisp.com/newsletter/2004/2004-13.htm (2 of 4) [23/03/2005 05:48:37 p.m.]
Dim CancelFlag as Boolean
ii) For the button which starts the long process, add the following code :
CommandButton1.Enabled=False
CancelFlag=False
iii) In the middle of the loop add :
DoEvents
If CancelFlag then
Exit Sub
CommandButton1.Enabled=True
End If
iv) The code for the Cancel button is :
CancelFlag=True
Note: If you use DoEvents, there is a possibility that the user may again
click the button which triggers the loop. You can prevent this by disabling
the button - CommandButton1.Enabled=False - or by setting a flag so that
the loop will not run again.
Things Weird and Wonderful
========================
Google WOW
If you have not yet tried...
http://labs.google.com/personalized
Get on it!
========
Something Awful
http://www.somethingawful.com/
===========================
Fark.com
http://www.fark.com/
=================
Portal of Evil
http://www.portalofevil.com/
=======================
Miscellaneous Stuff that I almost Forgot
================================
DodoCAD
========
Unable to fly and extinct for years.
DodoCAD is a working collection of Free custom AutoCAD utilities.
The project also serves as a framework for further development of
these tools, detail libraries, and drawing standards, especially as
used in Architecture and Engineering (A&E).
The initial series of releases is simply to prove the project's viability,
and to open discussion for how this framework might be developed.
While many terrific tools have already been coded and await inclusion
into the releases (as code licensing and ownership issues are resolved),
we hope that DodoCAD can expand to include best of class utilities as
offered by many proprietary packages currently.
http://dodocad.sourceforge.net/
AfraLisp Newsletter No 2004-13
http://www.afralisp.com/newsletter/2004/2004-13.htm (3 of 4) [23/03/2005 05:48:37 p.m.]
==========================
The Back Stoep
=============
There was a guy in a bar one night who got really drunk, I mean
really, really, really drunk. When the bar closed he got up to go home.
As he stumbled out the door he saw a nun walking on the sidewalk.
So he stumbled over to the nun and punched her in the face.
Shocked, the nun felt her knees go beneath her but before she could
do or say anything he punched her again.
This time she fell down and he stumbled over to her and kicked
her in the bum, then he picked her up and threw her into a wall.
By this time the nun was pretty weak and couldn't move very much.
Then he stumbled over to her, put his face right next to hers and
said................
"NOT VERY STRONG TONIGHT, ARE YOU BATMAN?"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download most of the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-13
http://www.afralisp.com/newsletter/2004/2004-13.htm (4 of 4) [23/03/2005 05:48:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-14
=========================
Monday 17th May 2004
=========================
http://www.afralisp.com
mailto:kramage@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Are you wearing your golfer's socks?
The pair with a hole in one.
=========================
The Front Stoep.
==============
Well, I received a few interesting suggestions for Projects.
Please keep them coming and I'll list them and then we can
all decide which we would like to tackle.
One idea I would like to put forward is a short series on dealing
with controls in DCL and VBA. You know, how to write the coding
for list boxes, option buttons, etc, etc. We could end up with a complete
set of functions that could be called to use in any application.
What do you think??
Pearls of Wisdom
===============
All reports are in.
Life is now officially unfair.
===============
Coding
=======
Kenny,
You wanted some reaction to your articles? Well heres one.
Some time ago you gave some tricks to do some manipulation
with folders and files. Heres another way:
In VB goto Pulldown menu Project - References.
In the dialogbox choose Microsoft Scripting Runtime.
In the source code add:
Global fso As New FileSystemObject
Now you can simply type fso.[option]
This is far easier to use. Pressing the F1 button gives you an excellent help.
Hope this is something you wanted?
Greetings,
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (1 of 11) [23/03/2005 05:48:38 p.m.]
H. Bosma
========
Need some code? Here are useful quick keyins I like to use :
;CODING STARTS HERE
;Quick vertical/horizontal mirroring by only selecting a single;
;point to define the mirror line. I find that well over 90% of my ;
;mirroring is orthogonal. If a command name ends in C it ;
;copies what is mirrored.
;The command does a vertical mirror if it starts with V ;
;and horizontal otherwise.
(defun C:VM ()(%quickmirr "V" "Y"))
(defun C:VMC ()(%quickmirr "V" "N"))
(defun C:HM ()(%quickmirr "H" "Y"))
(defun C:HMC ()(%quickmirr "H" "N"))
(defun %quickmirr (orient cpy / ss p1 p2)
(graphscr)
(setq ss (ssget)
p1 (getpoint "\nFirst point of mirror line: ")
p2 (polar p1 (if (= "V" orient) pi1 0) 1)
)
(command "._MIRROR" ss "" p1 p2 cpy)
(princ)
)
;Type (rpt) whenever you need to pick a point in a command.
;RPT has you pick two points and returns the point between
;that divides the
;distance between them in the given ratio. 2 (midpoint) is
;the default.
(defun RPT (/ p1 p2 ang d r)
(setq p1 (getpoint "\nSelect first point: ")
p2 (getpoint p1 "\nSelect second point: ")
r (getreal "\nRatio to divide distance by[2]: ")
ang (angle p1 p2)
d (/ (distance p1 p2)(if r r 2.0))
)
(polar p1 ang d)
)
;Type ISO to toggle back and forth between isometric and
;rectangular grid
(defun C:ISO ()
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (2 of 11) [23/03/2005 05:48:38 p.m.]
(setvar "CMDECHO" 0)
(if (zerop (getvar "SNAPSTYL"))
(command "._SNAP" "S" "I" "")
(command "._SNAP" "S" "S" "")
)
(setvar "CMDECHO" 1)
(princ)
)
(princ)
;CODING ENDS HERE
How about a better REGEXP for AutoLISP? WCMATCH was an
improvement but is still not quite good enough, it could be
enhanced considerably with a little sweat. How about we
design our regexp syntax and write a better one?
Heres another idea, how bout we write a better LISP?
We would write a translator that would take our new
language from a text file and process it into an AutoLISP
file that would be the actual program that runs.
We could have functions that take optional arguments
without having to pass a list, we could use * instead of writing
nil, we could write (sin>abs>fix x) instead of (sin (abs (fix x))).
We could do anything we please.
Have fun.
Jeremy Dunn
===========
Well Kenny, you've moved to a new town and a new job and now I'll be
doing the same. After 15 years in the consulting engineering game, I'm
off to greener pastures. In two weeks I'll be leaving the relative
comfort of my life in Canada and moving to Taiwan to become an English
teacher! Thanks for all the coding tips and bad jokes over the years.
Good luck with your new job and continued success with Afralisp. It
really is the best thing out there. If I ever get back into CADding,
I'll know where to look.
I'll leave you with a few last bits of code. I hope someone may find
some use with them.
===============================================
;CODING STARTS HERE
;This is a quick trim program.
;Select 2 corners of an imaginary rectangle
;(preferably just outside the extents of the area you want trimmed)
;and the program takes care of the rest.
(defun c:TR (/ a b c d e f g h)
(terpri)
(setvar "cmdecho" 0)
(setq a (getpoint "First POINT of crossing: "))
(setq b (getpoint "Second POINT of crossing: "))
(setq c (car a))
(setq d (cdr b))
(setq e (cons c d))
(setq f (car b))
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (3 of 11) [23/03/2005 05:48:38 p.m.]
(setq g (cdr a))
(setq h (cons f g))
(command "trim" "c" a b "" "f" a e b h a "" "")
(command "trim" "c" a b "" "f" a e b h a "" "")
(princ)
)
(princ)
;CODING ENDS HERE
=============================
Kenny, I may have sent this one to you already!
;CODING STARTS HERE
;This program offsets isometric lines
;so that the offset distance is correct isometrically, not orthagonally
;as Autocad is want to do.
(defun c:ISO (/ offsetdist bb z ac d e f h i j k l)
(terpri)
(setvar "angbase" 0)
(setvar "cmdecho" 0)
(setvar "snapstyl" 1)
(princ "\rDefualt offset distance: ")
(if (= offsetdist nil)
(setq offsetdist 0)
)
(princ offsetdist)
(setq bb (getreal
"\rOffset distance in Inches (Return for default): "
)
)
(if (/= bb nil)
(setq offsetdist bb)
)
(if (and (or (= bb 0) (= bb nil)) (= offsetdist 0))
(progn
(princ
"\rDon't be silly. Why would you offset something 0 inches?"
)
(terpri)
(cancel)
)
)
(setq z T)
(while z
(setq a (entsel "\rSelect object to ISO-offset: "))
(terpri)
(if (= a nil)
(setq z nil)
)
(if (/= a nil)
(progn
(setq c (getpoint "\rDirection to offset: "))
(setq d (cadr a))
(setq e (angle d c))
(setq f (/ (* e 180) pi))
(if (<= f 90)
(progn
(setq h (* (cos (DTR 30.0)) offsetdist))
(setq i (* (sin (DTR 30.0)) offsetdist))
(setq j (+ (car d) h))
(setq k (+ (cadr d) i))
(setq l (list j k))
(command "copy" a "" d l)
)
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (4 of 11) [23/03/2005 05:48:38 p.m.]
)
(if (and (> f 90) (<= f 180))
(progn
(setq h (* (cos (DTR 30.0)) offsetdist))
(setq i (* (sin (DTR 30.0)) offsetdist))
(setq j (- (car d) h))
(setq k (+ (cadr d) i))
(setq l (list j k))
(command "copy" a "" d l)
)
)
(if (and (> f 180) (<= f 270))
(progn
(setq h (* (cos (DTR 30.0)) offsetdist))
(setq i (* (sin (DTR 30.0)) offsetdist))
(setq j (- (car d) h))
(setq k (- (cadr d) i))
(setq l (list j k))
(command "copy" a "" d l)
)
)
(if (and (> f 270) (<= f 360))
(progn
(setq h (* (cos (DTR 30.0)) offsetdist))
(setq i (* (sin (DTR 30.0)) offsetdist))
(setq j (+ (car d) h))
(setq k (- (cadr d) i))
(setq l (list j k))
(command "copy" a "" d l)
)
)
)
)
)
(princ)
)
(princ)
;CODING ENDS HERE
======================================
Cheers
Ron, Windsor, Ontario, Canada
=======================================
p.s. If anyone in Taiwan reading this is looking for a senior
structural/mechanical services draughtsman (15 years total experience)
with 5 years experience as a CAD manager and an English degree, please
email me at: ron_albrecht_cdn@yahoo.com
====================
Hello Kenny,
I wrote this a few weeks ago, sorry I didn't send it sooner. I hope that
something is usefull.
I've been a fan of your web site for a couple of years now, excellent
information! You once answered a personal question of mine, so I will
return the favor to someone else:
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (5 of 11) [23/03/2005 05:48:38 p.m.]
>From AfraLisp Newsletter No 2004-08:
X and Y scaling program:
I have issues with X or Y scaling with a block:
1. Polylines are exploded. This is the worst problem in my opinion.
(seems to be fixed in AutoCAD 2004)
2. Arcs and Circles are turned into ellipses.
3. Splines become curvy plines.
etc.
I have considered writing a program to get around these bad side effects,
but it sounds hard and I am LAZY.
======================
>From AfraLisp Newsletter No 2004-09
Joop Moelee sez:
Reading the newsletter and looking in on several forums it occurred to me
that a lot of readers / participants are asking for complete solutions for
their problem.
Ok, here is a small programming question for all of you fat brained people
out there:
ENTSEL and NENTSEL are great commands that I use a lot, but I have some
issues with these commands.
First, there doesn't seem to be a way to distinguish between a bad pick (ie
I pick empty drawing space) and a user hitting the enter key at the prompt.
Both return nil. I have noticed that some AutoCAD commands can tell if I
make a bad pick instead of simply pressing enter. The only way that I can
think of doing this is to be able to quickly check the keyboard and see if
the enter key is still depressed a millisecond after the ENTSEL command is
finished. I have had no luck with GRREAD in this respect because it always
wants to pause for keyboard input. Is visual basic my only means of getting
around this one?
On a similar note, how can I check for shift or control (such as the express
tools extended offset command)?
Second, ENTSEL and NENTSEL have no way to allow for arbitrary input.
Sometimes I want a number to be entered or a choice from data that would
make an unweildy INITGET list (ie layer names).
Okay, thats enough thinking for me...
======================
>From AfraLisp Newsletter No 2004-09
John Dam sez:
I got this simple lisp whick break a section of the line which run thru
another line at any angles,
The problem with this lisp is it doesn't works with polyline/lwpolyline
Here is a handy lisp function that finds all of the intersecting points (as
a list of points) of a line between two points and a lwpolyline:
;CODING STARTS HERE
(defun find_poly_int (POINT1 POINT2 ENTPROP / ELEV I_POINT FIRST_PT
SECOND_PT Y)
(if (= "LWPOLYLINE" (cdr (assoc 0 ENTPROP)))
(progn
(setq FIRST_PT nil SECOND_PT nil ELEV (list (cdr (assoc 38 ENTPROP))))
(foreach Y ENTPROP
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (6 of 11) [23/03/2005 05:48:38 p.m.]
(if (= 10 (car Y))
(progn
(setq SECOND_PT FIRST_PT
FIRST_PT (append (cdr Y) ELEV)
)
(if (and FIRST_PT SECOND_PT (inters POINT1 POINT2 FIRST_PT
SECOND_PT))
(setq I_POINT (append I_POINT (list (inters POINT1 POINT2
FIRST_PT SECOND_PT))))
)
)
)
)
(if (= 1.0 (cdr (assoc 70 ENTPROP)))
(progn
(setq SECOND_PT FIRST_PT
FIRST_PT (append (cdr (assoc 10 ENTPROP)) ELEV)
)
(if (and FIRST_PT SECOND_PT (inters POINT1 POINT2 FIRST_PT
SECOND_PT))
(setq I_POINT (append I_POINT (list (inters POINT1 POINT2
FIRST_PT SECOND_PT))))
)
)
)
)
)
I_POINT
)
;CODING ENDS HERE
Jason Day
=========
Kenny,
In your latest afralisp email you asked people to send ideas for a
possible new project.
Well, here is a possible project. I am a lecturer at the INHolland
University in the Netherlands. I teach AutoCAD and all what comes
with it (VIZ and so on).
What I really should like to have is a tool to simply view a drawing
my students make and be able to print the results. The things that
should be detected is what blocks are used and on what layer they
are inserted. Ive tried to make such a program myself but
I cannot find a way to detect a block with possible nested ones.
Also in the investigation
of the drawings should be the used styles for texts, dimensioning
and so on.
Do you like this project?
Hans Bosma
==========
Hi!
I'm a computer engineer here in Portugal. I have to interpret a
AutoCAD 2002 ASCII DXF file.I have printed Autodesk's own
description of the format. I've found it to be less than helpfull. :(
Have you ever seen a parser for such files written in a decent
manner? The ones i've seen only fit for a particular purpose.
I'm stuck on this. I would be greatly appreciated if you could
give me some pointers.
Thank you a lot.
Ricardo Ramalho
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (7 of 11) [23/03/2005 05:48:38 p.m.]
==============
I'm the new guy - column reader, for about 2 months now.
I have a question on batch plotting - acad14.
The version is "Extended batchplot utility version 1"
Do you have Q.B.E. in this field, if so here is my question:
How can I change the default settings in the "plot area" tab
from "display" to "extents"?
When I open the batchplot and add 10 drawings, they are all
set to plot as "Display". I want to set it to "Extents" without having
to change this every time I open batchplot. It would be nice to have
it already set to "Extents" when I open batchplot.
P.S.
I've looked the web for an update - couldn't find it.
I begin to wonder if I am a troglodite working with stones & old tools?
Regards,
Scott Vanderstelt
==============
Things Weird and Wonderful
========================
The following is rude but lovely.
You have been warned.......
Every so often there is a breakthrough in technology.
Click on the link below to see the latest for cleaning
the inside of the monitor screen. Be sure to move the
mouse all over the screen for a thorough job.
http://mirrored.flabber.nl/boob.cursor/ciagnijcycka.swf
Have Fun,
Jim Exler
========
Lost for a smart remark to see off your enemies?
Unable to deliver that killer insult? Put an end to "I was speechless!"
misery with the amazing Biblical Curse Generator, which is pre-loaded
with blistering put-downs as delivered by Elijah, Jeremiah and other
monumentally angry saints. Simply click the button below, and get
ready to smite your foes with a custom-made curse straight out of the
Old Testament.
http://www.shipoffools.com/Features/Curses/index.html
============================================
Miscellaneous Stuff that I almost Forgot
================================
What Makes 100%?
What does it mean to give MORE than 100%?
Ever wonder about those people who say they are giving more than 100%?
We have all been to those meetings where someone wants you to give over 100%.
How about achieving 103%? What makes up 100% in life?
Here's a little mathematical formula that might help you answer these questions:
If:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z is represented as:
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (8 of 11) [23/03/2005 05:48:38 p.m.]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26.
Then:
H-A-R-D-W-O-R-K
8+1+18+4+23+15+18+11 = 98%
and
K-N-O-W-L-E-D-G-E
11+14+15+23+12+5+4+7+5 = 96%
But,
A-T-T-I-T-U-D-E
1+20+20+9+20+21+4+5 = 100%
And,
B-U-L-L-S-H-I-T
2+21+12+12+19+8+9+20 = 103%
AND, look how far ass kissing will take you.
A-S-S-K-I-S-S-I-N-G
1+19+19+11+9+19+19+9+14+7 = 118%
So, one can then conclude with mathematical certainty that While Hard work
and Knowledge will get you close, and, Attitude will get you there, Bullshit
and Ass kissing will put you over the top.
Jim Exler
========
The Back Stoep
=============
A policeman was interrogating three blondes who were
training to become detectives. To test their skills in
recognizing a suspect, he shows the first blonde a
picture for five seconds and then hides it.
"This is your suspect, how would you recognize him?"
The first blonde answers: "That's easy, we'll catch
him fast because he only has one eye!"
The policeman says, "Well...uh...he has one eye
because the picture shows his PROFILE, a SIDE VIEW.
That's just ONE SIDE of him!"
Slightly flustered by this ridiculous response, he
flashes the picture for five seconds at the second
blonde and asks her:
"This is your suspect, how would you recognize him?"
The second blonde giggles, flips her hair and says:
"Ha! He'd be too easy to catch because he only
has one ear!"
The policeman angrily responds: "What's the matter
with you two? Of course only one eye and one ear are
SHOWING because it's a picture of his profile! Is
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (9 of 11) [23/03/2005 05:48:38 p.m.]
that the best answer you can come up with?!"
Extremely frustrated at this point, he shows the
picture to the third blonde and in a very testy voice
asks: "This is your suspect, how would you recognize
him?"
The blonde looks at the picture intently for a moment
and says: "Hmmmm... the suspect wears contact lenses."
The policeman is surprised and speechless because
he really doesn't know himself if the suspect wears
contacts or not.
"Well, that's an interesting answer! Wait here for
a few minutes while I check his file, and I'll get
back to you on that."
He leaves the room and goes to his office, checks the
suspect's file in his computer and comes back with a
beaming smile on his face.
"Wow! I can't believe it... it's TRUE! The suspect
does in fact wear contact lenses. Good work! How were
you able to make such an astute observation?"
"That's easy," the blonde replied.
"He can't wear regular glasses, because
he only has one eye and one ear!"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:kramage@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download most of the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-14


http://www.afralisp.com/newsletter/2004/2004-14.htm (10 of 11) [23/03/2005 05:48:38 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-14
http://www.afralisp.com/newsletter/2004/2004-14.htm (11 of 11) [23/03/2005 05:48:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-15
=========================
Tuesday 25th May 2004
=========================
http://www.afralisp.com
mailto:kramage@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
He's dead Jim. Grab his tricorder. I'll get his wallet.
=========================
The Front Stoep.
==============
Keep those Project ideas coming.........
Lot's of good one's already received, but we need more........
======
Have you heard of the International Cad Developers Association?
Thought not!!
Watch this space for more details.............
Pearls of Wisdom
===============
A midget fortune-teller who escapes from prison
is a small medium at large.
===============
Coding
=======
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (1 of 9) [23/03/2005 05:48:40 p.m.]
Hi,
First I would like to say thanks for the AfraLisp web site.
Its helped me tremendously with my Autocad Lisp/VBA education.
I was on the Tips 'n Tricks II page and noticed the Cal-Mee Expression
for the OSnap Menu. I use a similar expression and find it a little more robust.
Instead of 'CAL;MEE; I use 'CAL;(CUR+CUR)/2;
The 'CAL;MEE only accepts endpoints as inputs where
'CAL;(CUR+CUR)/2;
will take any combination of inputs such as Endpoints, Midpoints,
Intersections, Etc...
Both accomplish the same thing but the CUR+CUR method gives
the user more options. Of course it may take a few more clicks if
running OSnaps are off.
Give it a try and see what you think.
Thanks again for the great website,
Jeff Harris
=========
Kenny
How about a toolbox of handy functions and utilities. You know how you keep
going back to a set of lisps, etc and pulling code out of it because it is
useful. How about a set of those you have to have'em bits.
Keep up the fantastic work
Regards
Mark Bowes
==========
Try this:
My project idea is to have a mini-drawing-environment in Autocad
that works as a polar system. It would have the user select the center
point and then have a series of drawing and modification commands.
For example drawing lines with Ortho on would produce a ray-line
along the X coordinate and an arc along the Y coordinate. Drawing a
10" line along the Y would produce a 10" long arc. The copy command
would be a kind of copy-rotate combination that would keep the object's
rotation to the center constant as it was copied. I haven't really thought
through all the possibilities but I know that this would have been handy a
few times when working on buildings/rooms that were based off a center
point.
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (2 of 9) [23/03/2005 05:48:40 p.m.]
Thanks for all your work on Afralisp.
Zac.
====
Regarding this project:
Well, I received a few interesting suggestions for Projects. Please keep
them coming and I'll list them and then we can all decide which we would
like to tackle. One idea I would like to put forward is a short series
on dealing with controls in DCL and VBA. You know, how to write the
coding for list boxes, option buttons, etc, etc. We could end up with a
complete set of functions that could be called to use in any
application. What do you think??
I think this would be a great idea, any input needed please call on me
Please acknowledge any comments or concerns
Regards,
Zain T Campbell
==============
Hi Kenny .
Just a few weeks ago I unveild the GEOMCAL to be use as a function on LISP
For me it is one of the most wonderfull tool to handle distances , and angle ,
mainly it handle angles in degree and can give the true angle between two lines.
learn it on the ACAD help
Maybe you can develop a tutorial on it
I do not understand about vector and it's use in CAL.
Hope it make sense
Gabriel
=======
Kenny,
I've been tweaking these two scripts for ages, but I think I've
finally refined them to the point where someone else might find them
useful. Using the functions and "mapped key" functions, it enables
"VV" to save the current view and layer state, and "V" to restore it.
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (3 of 9) [23/03/2005 05:48:40 p.m.]
(defun ddc:quickview-restore()
; restore view and layerstate "_QuickView"
(if (tblsearch "VIEW" "_QuickView")
(command "-VIEW" "R" "_QuickView")
(princ "QuickView not found.")
)
(command "-LAYER" "A" "R" "_QuickView" "" "" "")
(princ)
)
(defun C:V() (ddc:quickview-restore))
(defun ddc:quickview-save()
; save current view and layerstate to "_QuickView"
; delete existing
(if (tblsearch "VIEW" "_QuickView")
(command "-VIEW" "D" "_QuickView")
)
(command "-VIEW" "S" "_QuickView")
; delete existing
(command "-LAYER" "A" "D" "_QuickView" "" "")
(command "-LAYER" "A" "S" "_QuickView" "" "" "")
; close the text window
(GRAPHSCR)
(princ)
)
(defun C:VV() (ddc:quickview-save))
Obviously this destroys the traditional "V" for VIEW, but that's
pretty easy to type by itself, and I since I use power tools to manage
layer states and use:
(defun C:ZZ()
; zoom 95% extents
(command "ZOOM" "E")
(command "ZOOM" "S" "95/100xp")
)
to Zoom Extents, it does the job.
--
Steve Hall
=========
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (4 of 9) [23/03/2005 05:48:40 p.m.]
Hi
I really need help with some autolisp project I have to make!
I need to make an entity (polyline) that it's composed by lines
and arcs and I cannot find the codes for the vertex for the arc
part of the polyline.
Prejbeanu Lucian
===============
Jason Day
You wrote:
I am LAZY
Welkom to the community of true followers of "the Devine Art of Laziness".
You also wrote:
ENTSEL and NENTSEL are great commands that I use a lot, but I have some
issues with these commands.
The standard solution is very easy if not satisfactory.
(setq Choice nil)
(while (= Choice nil)
(setq Choice (nentsel))
)
The good part is: When you make a bad choice the command won't be
terminated.
The bad part is: The command can only be terminated by making a choice or
by hitting the escape key.
So, if you use this as part of a lisp routine there is a chance that by
hitting the escape key your entire routine will be cancelled.
If so, you will have to adapt your error routine.
Joop
=====
Kenny,
Big fan of the Afralisp site, i dont work with many others whom have any 3D or
autolisp experience so if you have any thoughts on the following query id be very
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (5 of 9) [23/03/2005 05:48:40 p.m.]
interested to hear it.
Ive documented a 3D piping drawing (lines only) and im using the 3d SW view to
view it as an isometric, however unable to think of any commands that will allow
me to automatically create gaps in lines in the appropriate places so lines to the
back are clear and not overlapping the lines in the front (if you get my drift). Ive
played with a lisp routine that will identify these cross over points however have
had no success.
The aparent intesection may hold some promise however the drawing has many
and im after a way of identifying them all with the touch of a button.
If youve got any thoughts or know of any programs that may be usefull, that would
be great.
Thanks
Ben
=====
Things Weird and Wonderful
========================
Patient goes to surgery and says,
"Doctor, I have a strawberry coming out of my bottom!"
Doctor takes a look and says,
"Oh yes you have, I'll give you some cream for that".
==========================================
Hey, don't move that!!
http://www.lebonze.co.uk/stuff/move.htm
Just don't read this someplace where your laughing will disturb others.
http://unbillablehours.typepad.com/unbillablehours/2004/05/when_the_world_.html
Miscellaneous Stuff that I almost Forgot
================================
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (6 of 9) [23/03/2005 05:48:40 p.m.]
The Back Stoep
=============
Thank you Beer Gods!
How many times have you woken up in the morning after a hard night
Drinking and thought "How on earth did I get home?".
As hard as you try, you cannot piece together your return journey
from the pub to your house.
The answer to this puzzle is that you used a Beer Scooter.
The Beer Scooter is a mythical form
of transport, owned and leased to the drunk by Bacchus the Roman god of wine.
Bacchus has acquired a large batch of these magical devices.
The Beer Scooter works in the following fashion:
The passenger reaches a certain level of drunkenness and the "slurring gland"
begins to give off a pheromone. Bacchus (or one of his many sub-contractors)
detects this pheromone and sends
down a winged Beer Scooter. The scooter scoops up the passenger and deposits
them in their bedroom via a Trans-Dimensional Portal. This is not cheap to run,
so a large portion of the passenger's in-pocket cash is taken as payment.
This answers the second question after a night
out "How did I spend so much money?"
Unfortunately, Beer Scooters have a poor safety record and are thought to be
responsible for over 90% of all UDI (Unidentified Drinking Injuries).
An undocumented feature of the beer scooter is the destruction of time segments
during the trip. The nature of Trans-dimensional Portals
dictates that time will be lost, seemingly unaccounted for.
This answers a third question after a night out "What the hell happened?".
With good intentions, Bacchus opted for the REMIT (Removal of Embarrassing
Moments In Time) add on, that automatically removes, in descending order,
those parts in time regretted most.
Unfortunately one person's REMIT is not necessarily the REMIT of another and
quite often lost time is regained in discussions over a period of time.
Independent studies have also shown that Beer Goggles often cause the scooter's
navigation system to malfunction thus sending the passenger to the wrong bedroom,
often with horrific consequences.
For the family man, Beer Scooters come equipped with flowers picked from other
people's garden and Thump-A-Lot boots (Patent Pending). These boots are
designed in such a way that no matter how quietly you tip-toe up the stairs,
you are sure to wake up your other half.
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (7 of 9) [23/03/2005 05:48:40 p.m.]
Special anti-gravity springs ensure that you bump into every wall in the house
and the CTSGS (Coffee Table Seeking Guidance System) explains the bruised shins.
The final add-on Bacchus saw fit to invest in for some scooters is the
TAS (Tobacco Absorption System). This explains how one person can apparently
get through 260 Marlboro Lights in a single night.
PS: Don't forget the on-board heater, which allows you to comfortably get
home from the pub in sub-zero temperatures, wearing just a T-shirt.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:kramage@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
You can also download most of the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-15


http://www.afralisp.com/newsletter/2004/2004-15.htm (8 of 9) [23/03/2005 05:48:40 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-15
http://www.afralisp.com/newsletter/2004/2004-15.htm (9 of 9) [23/03/2005 05:48:40 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-16
=========================
Tuesday 1st June 2004
=========================
http://www.afralisp.com
mailto:afralisp@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Is it the twelveth of never YET?
=========================
The Front Stoep.
==============
The AfraLisp Books and the Newsletter Collections are now available as one
downloadable installation file.
http://www.afralisp.com/zip2/AfraLisp_Books.zip ( 5227 kb )
International CAD Academic Association
=================================
The ICAA members will consist of members who have contributed to the CAD
world through the means of tutorials, teaching or training on a non-profit basis.
Our motto will be "We Give Back".
Admission will be granted to those that contribute academically to the CAD world.
A small membership fee will be asked for to cover expenses, dis-encourage the wannabees,
and hopefully help to finance workshops, seminars, etc.
AfraLisp will host and administer, with the three volunteers as adjudicators.
Your thoughts and suggestions would be appreciated.
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (1 of 9) [23/03/2005 05:48:41 p.m.]
================
Pearls of Wisdom
===============
How come when Star Trek boldly goes where no one has gone before,
there is always someone there?
===============
Coding
=======
;CODING STARTS HERE
;| Routine to change the color of a certain attribute
in a block of a certain name from the defined color
to a new color. Change the values in the line above
the *'s to the desired blockname, layername, old color
and new color #'s.
Jeff Mishler, May 2004
|;
(defun c:attcolor ()
(att-color-shift "test2" "0" 1 8)
;************************************************* **
; (att-color-shift "test2" "0" 1 8)
; as shown will get all block inserts named "test2" and change
; any red(1) attributes on layer "0" to color 8
(princ)
)
(defun att-color-shift (name str oldcolor newcolor / count ss atts)
(vl-load-com)
(if (setq ss (ssget "x" (list '(0 . "INSERT")(cons 2 name)'(66 . 1))))
(progn
(setq count 0)
(while (< count (sslength ss))
(setq atts (vla-getattributes
(vlax-ename->vla-object
(ssname ss count))))
(foreach att (vlax-safearray->list
(vlax-variant-value atts)
)
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (2 of 9) [23/03/2005 05:48:41 p.m.]
(if (and (= (vla-get-layer att) str)
(= (vla-get-color att) oldcolor)
)
(vla-put-color att newcolor)
)
)
(setq count (1+ count))
)
)
)
)
;CODING ENDS HERE
Jeff Mishler
===========
Draw any Length of Arc
===================
Code for creating arcs of any given length based on selecting an
existing circle or arc. I use "arcman" for creating hockey arena
dasher board layouts.
;CODING STARTS HERE
(defun c:arcman (/ Askresume arc_radius arc_deg arc_rad)
(IF arc_length
(AgainArcMan)
(FirstArcMan)
); end if
(setq arc_radius (distance pt1 pt2))
(setq arc_rad (/ arc_length arc_radius)) ; find radians
(setq arc_deg (* 180.0 (/ arc_rad pi))) ; change to degrees
(command "arc" "c" pt1 pt2 "a" arc_deg) ; build arc
(command "pedit" "last" "");modified for AutoCAD 2004 pline yes variable.
(princ)
); end defun arcman
(defun AgainArcMan ()
(initget "Yes No")
(setq AskResume (getkword (strcat "\nUse last: "
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (3 of 9) [23/03/2005 05:48:41 p.m.]
(rtos arc_length 2 8)
" No or <Y>es: "
)
)
); use old values?
(if (or (= AskResume "Yes") (= askresume nul))
(setq pt2 (osnap (getpoint "\nPick start of arc: ") "end,int,mid"))
(progn ; second progn
(setq pt1 (OSNAP (getpoint "\nPick EXISTING arc: ") "CEN"))
(setq pt2 (osnap (getpoint "\nPick start of arc: ") "end,int,mid"))
(setq arc_length (getdist "\nEnter arc Length: "))
); end second Progn
); end if ask resume
); end defun again Arcman
(defun FirstArcMan ()
(setq pt1 (OSNAP (getpoint "\nPick EXISTING arc: ") "CEN"))
(setq pt2 (osnap (getpoint "\nPick start of arc: ") "end,int,mid"))
(setq arc_length (getdist "\nEnter arc Length: "))
)
(princ)
;CODING ENDS HERE
Frank Zander
===========
Kenny,
After helping you out a while back and sending you all
the back Newsletters a while ago ...
I have a small question for you
Using 2002 is it possible to lock layers so that no one could
unlock them without say a password or something?
I'm not looking at the whole drawing file just the layers.
The layer lock feature can easily be unlocked
Thanks,
Steve
======
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (4 of 9) [23/03/2005 05:48:41 p.m.]
Hi, Kenny
Re the request, latest Afralisp for a polar coordinate system,
http://www.btlsp2000.com/GGEN.LSP may be helpful.
When using, load the fntn series(1-7) of support routine files,
found at http://www.btlsp2000.com/page9.html.
...Bill
=====
Things Weird and Wonderful
========================
Imagine if the whole world farted all at once!!!
========================
I'm new to your news letter, so I'm not sure if you've seen these.
Oldy, but Goldy - The Clock :
http://www.suite101.com/files/mysites/AskAlice/Clock.htm
The Industrious Clock
http://www.lares.dti.ne.jp/%7Eyugo/storage/monocrafts_ver3/03/index.html
John Alferes
==========
Miscellaneous Stuff that I almost Forgot
================================
Hello Kenny,
Recently, someone visited www.kitox.com and asked, why Afralisp is
not listed in the links section?
Now your link is placed in the "recommended" section.
So, what about link to www.kitox.com in Afralisp?
---
best regards,
Vaidas Guogis
www.kitox.com
=============
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (5 of 9) [23/03/2005 05:48:41 p.m.]
install-us
========
Installation software for Windows
http://www.media21.de/install-us/com/index.html
Install-us makes it easy to create your own installation applications within minutes.
Install-us brings many powerful features, which will give you total control over the
installation issues of your software.
Features
========
Basics:
Click-and-Build user interface
Various project languages
Installations for 16- and 32-Bit Windows
General:
Supports all Windows platforms:
32-Bit: Windows 95/98/ME/NT/2000 and XP
16-Bit Windows 3.1 / WfW 3.11
Supports various distribution media:
Diskettes,
CD-Rom
Internet download (Self-Extracting-Setup, SFX)
Special assistant for user-friendly CD-ROM-start menus:
CD-Manager
International installations:
Install-us comes with language files for over 30 languages
File management:
Version check
Shared DLLs
Font Installation
Registration of file name extensions
Registration of ActiveX-servers (OCX)
Configurations:
Component selective Uninstall
Different Configurations (Typical, Minimum, Custom)
Windows 95/98/MENT/2000/XP specific features:
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (6 of 9) [23/03/2005 05:48:41 p.m.]
Registry
Creates shortcuts on the desktop, in the start menu, in autostart...
Addtional features:
Program folders
Start programs after installation
Variables
Reboot and Relogin
Media such as Bitmaps, Audio and Video
ini-file modification
Protection possibilities:
Password and Expiry date
User Registration System
=====================
The Back Stoep
=============
Variations On Murphy's Law
=======================
1. The Law of Common Sense: Never accept a drink from a
urologist.
2. The Law of Reality: Never get into fights with ugly people,
they have nothing to lose.
3. The Law of Self Sacrifice: When you starve with a tiger, the
tiger starves last.
4. The Law of Volunteering: If you dance with a grizzly bear, you
had better let him lead.
5. The Law of Avoiding Oversell: When putting cheese in a
mousetrap, always leave room for the mouse.
6. The Law of Motivation: Creativity is great, but plagiarism is
faster.
7. Boob's Law: You always find something in the last place you
look.
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (7 of 9) [23/03/2005 05:48:41 p.m.]
8. Wailer's Law: Nothing is impossible for the man who doesn't
have to do it himself.
9. Law of Probable Dispersal: Whatever hits the fan will not be
evenly distributed.
10. Law of Volunteer Labor: People are always available for work
in the past tense.
11. Conway's Law: In any organization there is one person who
knows what is going on. That person must be fired.
12. Iron Law of Distribution: Them that has, gets.
13. Law of Cybernetic Entomology: There is always one more bug.
14. Law of Drunkenness: You can't fall off the floor.
15. Heeler's Law: The first myth of management is that it exists.
16. Osborne's Law: Variables won't; constants aren't.
17. Main's Law: For every action there is an equal and opposite
government program.
18. Weinberg's Second Law: If builders built buildings the way
programmers wrote programs, then the first woodpecker that came
along would have destroyed civilization.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:afralisp@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (8 of 9) [23/03/2005 05:48:41 p.m.]
http://www.afralisp.com/newsletter/newsletter.htm
You can also download most of the AfraLisp Newsletters,
in PDF format here:
http://www.afralisp.com/newsletter/news.zip ( 1033 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-16
http://www.afralisp.com/newsletter/2004/2004-16.htm (9 of 9) [23/03/2005 05:48:41 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-17
=========================
Wednesday 16th June 2004
=========================
http://www.afralisp.com
mailto:afralisp@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
If you can read this,... thank a teacher.......
=========================
The Front Stoep.
==============
I'm full of the cold, and generally not in a good mood.
Guess why?
Have a wee look at the Coding Section!!!!
Pearls of Wisdom
===============
Could it be that all those trick-or-treaters wearing sheets
aren't going as ghosts, but as mattresses?
===============
Coding
=======
-
-
-
-
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (1 of 9) [23/03/2005 05:48:42 p.m.]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Nothing to put in here, 'cos it seems like nobody wants to talk to me.
=============
Things Weird and Wonderful
========================
I "stole" this link from the CadVault Forums :
http://www.angelfire.com/games3/computermods/imgs.html
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (2 of 9) [23/03/2005 05:48:42 p.m.]
Miscellaneous Stuff that I almost Forgot ================================
ResourceTool.exe
Ed Jobe 2003
http://www.afralisp.com/lispb/resourced.htm
ResourceTool is a tool for use with VB to help with compiling resource dll's for a menu.
Normally, if you use the Resource Editor add-in and you load a bmp, the editor assings a
sequential number as the resource ID. This means that if you want to continue referring to
icons in your menu by a name, you have to rename all the ID's in the RES file.
This tool avoids using the rc.exe tool that comes with Visual Studio. This utility can
compile a C++ resource file (*.rc) into a VB resource file (*.RES).
================
NSIS
====
NSIS can create Windows installers that are capable of installing, uninstalling,
setting system settings, extracting files, etc.
Because NSIS is based on script files, you can create both simple or advanced installers.
http://nsis.sourceforge.net/
======================
Have you registered at the CadVault yet?
http://www.cadvault.com
And have you visited the forums??
http://www.cadvault.com/forums/?
===========================
The Back Stoep
=============
Forwarded to me by Neil Wilsnach :
Engineer Identification Test
=======================
Engineering is so trendy these days that everybody wants to be one.
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (3 of 9) [23/03/2005 05:48:42 p.m.]
The word "engineer" is greatly overused. If there's somebody in your life who you think is
trying to pass as an engineer, give him this test to discern the truth.
You walk into a room and notice that a picture is hanging crooked. You...
A. Straighten it.
B. Ignore it.
C. Buy a CAD system and spend the next six months designing a solar-powered, self-adjusting
picture frame while often stating aloud your belief that the inventor of the nail was a
total moron.
The correct answer is "C" but partial credit can be given to anybody who writes "It depends"
in the margin of the test or simply blames the whole stupid thing on "Marketing."
SOCIAL SKILLS
----------------------------
Engineers have different objectives when it comes to social interaction.
"Normal" people expect to accomplish several unrealistic things from social interaction:
Stimulating and thought-provoking conversation Important social contacts A feeling of
connectedness with other humans.
In contrast to "normal" people, engineers have rational objectives for social interactions:
Get it over with as soon as possible.
Avoid getting invited to something unpleasant.
Demonstrate mental superiority and mastery of all subjects.
FASCINATION WITH GADGETS
---------------------------------------------------
To the engineer, all matter in the universe can be placed into one of two categories:
(1) things that need to be fixed, and
(2) things that will need to be fixed after you've had a few minutes to play with them.
Engineers like to solve problems. If there are no problems handily available, they will
create their own problems.
Normal people don't understand this concept; they believe that if it ain't broke,
don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet.
No engineer looks at a television remote control without wondering what it would take to turn
it into a stun gun. No engineer can take a shower without wondering if some sort of Teflon
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (4 of 9) [23/03/2005 05:48:42 p.m.]
coating would make showering unnecessary. To the engineer,
the world is a toy box full of sub-optimized and feature-poor toys.
FASHION AND APPEARANCE
-------------------------------------------------
Clothes are the lowest priority for an engineer, assuming the basic thresholds for temperature
and decency have been satisfied. If no appendages are freezing or sticking together,
and if no genitalia or mammary glands are swinging around in plain view, then the objective
of clothing has been met. Anything else is a waste.
DATING AND SOCIAL LIFE
--------------------------------------------
Dating is never easy for engineers. A normal person will employ various indirect and
duplicitous methods to create a false impression of attractiveness. Engineers are
incapable of placing appearance above function.
Fortunately, engineers have an ace in the hole. They are widely recognized as superior
marriage material: intelligent, dependable, employed, honest, and handy around the house.
While it's true that many normal people would prefer not to date an engineer,
most normal people harbor an intense desire to mate with them, thus producing engineer
like children who will have high-paying jobs long before losing their virginity.
Male engineers reach their peak of sexual attractiveness later than normal men, becoming
irresistible erotic dynamos in their mid thirties to late forties.
Just look at these examples of sexually irresistible men in technical professions:
Bill Gates.
MacGyver.
Randall Rath
Etcetera.
Female engineers become irresistible at the age of consent and remain that way until
about thirty minutes after their clinical death.
Longer if it's a warm day.
HONESTY
-----------------
Engineers are always honest in matters of technology and human relationships.
That's why it's a good idea to keep engineers away from customers, romantic interests,
and other people who can't handle the truth.
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (5 of 9) [23/03/2005 05:48:42 p.m.]
Engineers sometimes bend the truth to avoid work. They say things that sound like lies
but technically are not because nobody could be expected to believe them. The complete
list of engineer lies is listed below.
"I won't change anything without asking you first."
"I'll return your hard-to-find cable tomorrow."
"I have to have new equipment to do my job."
"I'm not jealous of your new computer."
FRUGALITY
--------------------
Engineers are notoriously frugal. This is not because of cheapness or mean spirit;
it is simply because every spending situation is simply a problem in optimization,
that is, "How can I escape this situation while retaining the greatest amount of cash?"
POWERS OF CONCENTRATION
----------------------------------------------------
If there is one trait that best defines an engineer it is the ability to concentrate on
one subject to the complete exclusion of everything else in the environment.
This sometimes causes engineers to be pronounced dead prematurely. Some funeral
homes in high-tech areas have started checking resumes before processing the bodies.
Anybody with a degree in electrical engineering or experience in computer programming
is propped up in the lounge for a few days just to see if he or she snaps out of it.
RISK
---------
Engineers hate risk. They try to eliminate it whenever they can. This is understandable,
given that when an engineer makes one little mistake the media will treat it like it's a
big deal or something.
EXAMPLES OF BAD PRESS FOR ENGINEERS
------------------------------------------------------------------------
Hindenberg.
Space Shuttle Challenger.
SPANet(tm)
Hubble space telescope.
Apollo 13.
Titanic.
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (6 of 9) [23/03/2005 05:48:42 p.m.]
Ford Pinto.
Corvair.
Windows (from an IT Engineers point of view).
The risk/reward calculation for engineers looks something like this:
RISK: Public humiliation and the death of thousands of innocent people.
REWARD: A certificate of appreciation in a handsome plastic frame.
Being practical people, engineers evaluate this balance of risks and rewards and decide
that risk is not a good thing.
The best way to avoid risk is by advising that any activity is technically impossible
for reasons that are far too complicated to explain.
If that approach is not sufficient to halt the project, then the engineer will fall back
to a second line of defense:
"It's technically possible but it will cost too much."
EGO
--------
Ego-wise, two things are important to engineers:
How smart they are.
How many cool devices they own.
The fastest way to get an engineer to solve a problem is to declare that the problem
is unsolvable. No engineer can walk away from an unsolvable problem until it's solved.
No illness or distraction is sufficient to get the engineer off the case.
These types of challenges quickly become personal -- a battle between the engineer and
the laws of nature.
Engineers will go without food and hygiene for days to solve a problem.
(Other times just because they forgot.)
And when they succeed in solving the problem they will experience an ego rush that is
better than sex -- and I'm including
the kind of sex where other people are involved.
Nothing is more threatening to the engineer than the suggestion that somebody has more
technical skill.
Normal people sometimes use that knowledge as a lever to extract more work from the engineer.
When an engineer says that something can't be done (a code phrase that means it's not fun to do),
some clever normal people have learned to glance at the engineer with a look of compassion and
pity and say something along these lines: "I'll ask Bob to figure it out. He knows how to solve
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (7 of 9) [23/03/2005 05:48:42 p.m.]
difficult technical problems."
At that point it is a good idea for the normal person to not stand between the engineer and
the problem.
The engineer will set upon he problem like a starved Chihuahua on a pork chop.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:afralisp@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
The AfraLisp Books and the Newsletter Collections are now available as
one downloadable installation file.
http://www.afralisp.com/zip2/AfraLisp_Books.zip ( 5227 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-17


http://www.afralisp.com/newsletter/2004/2004-17.htm (8 of 9) [23/03/2005 05:48:42 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-17
http://www.afralisp.com/newsletter/2004/2004-17.htm (9 of 9) [23/03/2005 05:48:42 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2004-18
=========================
Friday 10th July 2004
=========================
http://www.afralisp.com
mailto:afralisp@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
For Hire:
A Professional Transvestite.
Likes to eat, drink and be Mary.
=========================
The Front Stoep.
==============
The AfraLisp Newsletter may be a wee bit intermittent for the foreseeable future due
to business and personal reasons.
Please do not adjust your sets as normal service will be resumed as soon as possible.
==============
The world and life is a tough and unforgiving place.
All your well placed plans can go awry at the whim of the moment.
A lot of people do not have any idea of what or where they are within the universe.
As an example, I went into a pet shop the other day and asked the owner if I could buy a bee.
He said to me, "I'm sorry Kenny, but we don't sell bees."
I said, " Yes you do, you've got two in the window.."
The same owner of the "So Called Pet Shop" was broken into two weeks ago.
The police arrived and searched the premises and then announced that they had found a chain
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (1 of 14) [23/03/2005 05:48:44 p.m.]
with a circular piece of leather attached to one end. They claimed that they had found a lead.
==========
This is a must.
http://www.go-opensource.org
I received my CD about a month ago, but have only got around to having a good look at it
about a week ago.
Have a look, it's well worth it and I love their ideas and aims...
Pearls of Wisdom
===============
One Christmas I got a battery with a note saying, "Toy not included."
===============
Coding
=======
Kenny,
I hope to have my update to Topical Index of system variables ready by the end of June.
Would you like a copy when I finish to post on AFRALISP.com?
Gil Hoellerich
============
Of course I told him no, but he insisted.
So, with no further adieu:
http://www.afralisp.com/zip2/sysvar2004.ZIP
============
Dear Mr. Ramage,
I am trying to get Express Tools from Acad 2000 to work with Acad 2002.
Is this possible? I have tried installing them using the step by step guide on your web site.
When I try to use any Express Tool command I get the following error - error: no function
definition: ACET-AUTOLOAD.
Any other suggestions?
Thanks,
Mark Chiarizio
============
http://www.augafrica.com/docs/ExpressBonusTools.zip
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (2 of 14) [23/03/2005 05:48:44 p.m.]
============
Kenny,
I have searched and surfed endlessly for answers concerning Autolisp problems that I
am having.
I keep coming back to Afralisp and Reini Urban for answers. I have found these to be
the most informative web sites for lisps.
But now I am stumped.
I have been working on a routine that will that will ( should) insert, from a folder
containing several title blocks, a title block that
I select with attributes and will allow me to edit the attributes on insertion.
And should allow future updates to the block / blocks thru a dialog box.
Of course the simple lisp I have now inserts a predefined title block and automatically
inserts the title info as text entities, and counts up the page number by 1.
I use multiple tabs for one job in a file. Each time I use the lisp it creates a
new tab with all the right settings and inserts one title block.
However, the info is entered through the use of "command"s in the lisp and once I
save and close the file, all info variables are lost. I could write the info to a file,
but I hate creating more job specific files than what is really needed. If the title
block had attributes, I could use something similar to the "attab" or "attab_vl" lisps
on your web site.
http://www.afralisp.com/lisp/attab.htm
Currently I have modified the code to create a new tab, insert the title block,
and change the info if needed. However, using the function again, it only
retrieves / updates the first inserted block. So I went back to the original source
code of "Attab" to see what happened after inserting the default block the lisp came with.
It worked fine. I inserted the block again.
Ran the lisp, and only the last block updates.
After researching many similar routines, the following excerpt seems to be frequently used:
"(setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1))))"
Shouldn't this update all the blocks with "insert" properties, and with entities that follow?
As I had mentioned, several routines use this same method of retrieving block data.
Why does this not update all the title blocks within a drawing file? I am so handicapped
when it comes to group code use, and how to update attributes. How come the above method
seems to work for everyone else but me?
If you think having the lisp I am working on will help, I will e-mail it to you.
As it is, I am willing to bet you know what my problem is already.
I will appreciate any help you have to offer.
Thank you,
Robert
======
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (3 of 14) [23/03/2005 05:48:44 p.m.]
Kenny,
I got your latest newsletter today and wonder why you did not include my "Bottom of
Steel" list routine in the code section; seeing as you have nothing else there.
Is there a problem with the code? I hope you got it as one time an email I sent was
listed as undeliverable but said they would keep trying and that was the last I heard.
Please let me know what is up. In the meantime, I'll see if I can come up with some
more jokes for you. I never saw the joke about Budweiser in the newsletter either.
Thanks
Jim
===
Jim, your program uses slide images contained in a slide library that is impossible
for me to publish within a text based Newsletter. I will though, within the very near
future, make it available as a download on AfraLisp.
=======================
The following is from the desk of Craig Green...
Kenny,
I am sure ALL your readers will find this lisp program VERY useful ;-) I wrote this
one a few years ago (don't ask me how it works) to draw log-log graph paper. You can
copy the end result as required to produce any number of cycles.
;CODING STARTS HERE
; Draw a log-log graph (one cycle by one cyle) - By C Green - 21/1/1991 ;
(defun scx (n /)
(command "text" "r" (list (+ 0.0125 (/ (log n)
(log 10.0))) -0.02) "0.025" "90" (rtos n 2 0))
)
;
(defun scy (n /)
(command "text" "r" (list -0.02 (- (/ (log n)
(log 10.0)) 0.0125)) "0.025" "0" (rtos n 2 0))
)
;
(defun c:log ()
; x axis
(command ".line" "0,0" "0,1" "" )
(setq an "")
(scx 1)
(setq n 1.1)
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (4 of 14) [23/03/2005 05:48:44 p.m.]
(setq i 0.1)
(while (/= an "10")
(command ".line" (list (/ (log n) (log 10.0)) 0)
(list (/ (log n) (log 10.0)) 1) "")
(setq an (rtos n 2 2))
(cond ((= an "2") (scx n))
((= an "3") (scx n))
((= an "4") (scx n))
((= an "5") (scx n))
((= an "6") (scx n))
((= an "7") (scx n))
((= an "8") (scx n))
((= an "9") (scx n))
((= an "10") (scx n))
)
(if (< n 3.0) (setq i 0.1) (setq i 0.5))
(if (> n 5.0) (setq i 0.2))
(if (> n 7.0) (setq i 1.0))
(setq n (+ n i))
(prin1 an)
)
;
; y axis
(command ".line" "0,0" "1,0" "" )
(setq an "")
(scy 1)
(setq n 1.1)
(setq i 0.1)
(while (/= an "10")
(command ".line" (list 0 (/ (log n) (log 10.0)))
(list 1 (/ (log n) (log 10.0))) "")
(setq an (rtos n 2 2))
(cond ((= an "2") (scy n))
((= an "3") (scy n))
((= an "4") (scy n))
((= an "5") (scy n))
((= an "6") (scy n))
((= an "7") (scy n))
((= an "8") (scy n))
((= an "9") (scy n))
((= an "10") (scy n))
)
(if (< n 3.0) (setq i 0.1) (setq i 0.5))
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (5 of 14) [23/03/2005 05:48:44 p.m.]
(if (> n 5.0) (setq i 0.2))
(if (> n 7.0) (setq i 1.0))
(setq n (+ n i))
)
)
;CODING ENDS HERE
Two cows were grazing in a paddock. The sky was blue, the sun was shining,
there was a cool gentle breeze blowing and the grass was so fresh and green -
let's face it, it was a great day to be a cow. Suddenly, one of the cows
stopped grazing. She slowly raised her head and said... "Moooo".
Then, the other cow said... "Oh rats. I was going to say that!"
===============
Some times I find it very handy to be able to draw a leader line in the reverse direction.
That is, selecting points from, say a note, to the job (arrow end).
One of the drafters in our office only uses this method!
;CODING STARTS HERE
;rleader - Draw a leader line in the reverse direciton - C Green 3/10/2000
(defun c:rleader () (setq pts ()) (setq pt (getpoint "\nPoint: ")) (while (/= pt ())
(setq pts (cons pt pts))
(setq pt (getpoint pt "\nPoint: "))
)
(setq pts (reverse pts))
; Erase this line to draw forward leaders (apply 'command (cons ".leader" (reverse pts)))
(command "" "" "n")
)
;CODING ENDS HERE
I also have a requirement in a couple of my programs to produce a list of the layout
tabs that have been 'initialised'.
The lisp command "layoutlist" returns all layout tab names whether they have been
'initialised' or not.
I have written the code below to return only the 'initialised' layout tab names.
It seems to work fine.
My only trouble is that the entity data, in this case, is a little beyond my knowledge.
The program gets the entity list associated with each layout tab and checks item 40 to
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (6 of 14) [23/03/2005 05:48:51 p.m.]
see if it is 0,0. It seems to me, that if it is 0,0 then the particular layout has not
been initialised.
Do you think this is a 100% reliable check for an 'initialised' layout tab? Do you know
of a better way of doing this?
You may recognise some of the code - I stole it from the "Model Tab" code in the "lisp
tips" section on the Afralisp site.
(My coding additions may be a bit rough because it is a work in progress at the moment.)
; Coding starts here
; llist.lsp - C Green - 22/6/2004
; This function is like 'layoutlist' but it only returns names of layouts that
have been initialised.
; Note - functions returns nil of no layouts have been initialised.
;
(defun c:llist ( / a b f index laylist laylst)
(setq layList (dictsearch (namedobjdict) "ACAD_LAYOUT"))
(setq Index 0) (setq laylst '()) ; Initialise the layout list
(while (/= (nth Index layList) nil) ; Loop through layout list until end
(if (= (car (nth Index layList)) 3)
(progn
(setq a (cdr (nth Index layList)))
;; (if (= a "Model") ; Do not include model space
;; (setq a ())
;; )
(if (nth (+ Index 1) layList)
(progn
(setq b (entget (cdr (nth (+ Index 1) layList)))) ; Get the layout data
(setq f (cdr (assoc 40 b))) ; Get data associated with item 40
(if (= f 0.0)
(setq a ()) ; Clear layout name if item 40 = 0.0 <--<<< Is this always 100% valid
)
)
)
(if (/= a ())
(setq laylst (append laylst (list a)))
)
)
)
(setq Index (+ Index 1))
)
(setq laylst laylst)
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (7 of 14) [23/03/2005 05:48:51 p.m.]
)
; Coding ends here
The following is a short program I wrote to help solve a graphics conversion
problem at work. Our client supplied us with a drawing in Micrografx.
The only way we could get the drawing into AutoCAD was to load it in Corel
Draw and save it as a dxf. The drawing loaded into AutoCAD fine and it looked
great - until we realised that every single line was NOT a line but a SPLINE,
with hundreds of control points. Unfortunately, this made the drawing almost
useless to us, so one of our draftsman started drawing new lines over each and
every spline from the start point to the end point. I knew a program could be
written to automate the task but at that point, I didn't have the time. The
draftsman took about 2 hours to complete the task manually. That night I
wrote the program below just to prove it could be done. When I got to work
the next day, I run the code on the offending drawing just to see how long
it would take to do the same task automatically - less than 2 seconds.
Needless to say, the draftsman who did the job manually was not too happy.
At least now we are all set for the next Micrografx drawing.
Coding Starts Here
; Spline to line - C Green - 25/6/2004
; Draw a line from the start point to the end point of all splines
(defun c:s2l ( / el en ic index l n p p1 p2) (setvar "cmdecho" 0)
(command "layer" "m" "lines_new" "c" "yellow" "" "") ; Change layer name and color to suit
(setq p (ssget "x" '((0 . "SPLINE")))) ; Get ALL the splines
(setq l 0) (setq n (sslength p)) (setq ic 0) (while (< l n)
(setq en (ssname p ic))
(setq el (entget en))
(setq Index 0)
(while (/= 10 (car (nth Index el))) ; Look for start of sequence
(setq Index (1+ Index))
)
(setq p1 (cdr (nth Index el))) ; First point of spline
(setq Index (1+ Index))
(while (/= nil (car (nth Index el))) ; Loop through rest of list
(if (= 10 (car (nth Index el)))
(progn
(setq p2 (cdr (nth Index el))) ; Next (last point)
)
)
(setq Index (1+ Index))
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (8 of 14) [23/03/2005 05:48:51 p.m.]
)
(command "line" p1 p2 "") ; Draw new line from start pt to end pt
(setq ic (1+ ic))
(setq l (1+ l))
)
(princ)
)
Coding Ends Here
================
Craig Green
===========
Things Weird and Wonderful
========================
Hi Kenny,
I just wanted to drop you a line to tell you that I think your books Are excellent.
I have been a structural Draftie for the past 6 years, and recently completed a
degree in Computer Science.
I still do a bit of drafting and wanted to find out more about customising AutoCAD,
a few minutes of Googling later and I found AfraLISP.
I was originally born in Rhodesia and thought that finding a website in Africa
That had exactly what I was looking for was quite ironic.
I have only just embarked on my CAD customization skills but have found your
Books to be extremely useful and straight forward.
Thanks,
Antony Hall
===========
Hi, Kenny,
Wow. I just happened to bump into your web doing a search for Excel VBA.
Anyway, I just wanted to invite you over:
www.vbaexpress.com/forum
Thanks!!
~Anne Troy
===========
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (9 of 14) [23/03/2005 05:48:51 p.m.]
I went, I saw, I left
Ouch, stop it Kenny, you're getting grouchy again ===========
Miscellaneous Stuff that I almost Forgot ================================
Hello!
I use your vba application CalculatePolylineLength
(http://www.afralisp.com/lisp/polyarc.htm)
But when the polyline is closed, this function is wrong : the last point of the
polyligne must be the fisrt point !
I modify your function like this :
Private Function CalculatePolylineLength(ent As AcadEntity) As Double
Dim x1 As Double Dim y1 As Double Dim x2 As Double Dim y2 As Double
Dim bulge As Double Dim coords As Variant Dim i As Long
Dim Totaldist As Double Dim lb As Long Dim ub As Long
coords = ent.Coordinates
lb = LBound(coords)
ub = UBound(coords)
For i = lb To ub - 2 Step 2
bulge = ent.GetBulge(i / 2)
x1 = coords(i)
y1 = coords(i + 1)
x2 = coords(i + 2)
y2 = coords(i + 3)
If bulge = 0 Then
Totaldist = Totaldist + Calculate3DDistance(x1, y1, 0, x2, y2, 0)
Else:
Totaldist = Totaldist + CalculateArcLength(x1, y1, 0, x2, y2, 0, bulge)
End If
Next i
' if polyline is closed
If ent.Closed Then
x1 = coords(i)
y1 = coords(i + 1)
x2 = coords(0)
y2 = coords(1)
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (10 of 14) [23/03/2005 05:48:51 p.m.]
bulge = ent.GetBulge(i / 2)
If bulge = 0 Then
Totaldist = Totaldist + Calculate3DDistance(x1, y1, 0, x2, y2, 0)
Else:
Totaldist = Totaldist + CalculateArcLength(x1, y1, 0, x2, y2, 0, bulge)
End If
End If
CalculatePolylineLength = Totaldist
End Function
But, with the autocad 2004 polyline.length property, this beautiful job is
no more necessary ....
Ren Pralat
===========
Thanks Rene. (That's "Rene" with the little funny squiggle above the second "e".)
Bloody froggies!!!!
================
The Back Stoep
=============
I am American
=============
I like big cars, big boats, big motorcycles, big houses and big campfires.
I believe the money I make belongs to me and my family, not some governmental
stooge with a bad comb-over who wants to give it away to crack addicts for
squirting out babies.
Guns do not make you a killer. I think killing makes you a killer.
You can kill someone with a baseball bat or a car, but no one is trying to
ban you from driving to the ball game.
I believe they are called the Boy Scouts for a reason, that is why there are
no girls allowed. Girls belong in the Girl Scouts!
ARE YOU LISTENING MARTHA BURKE?
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (11 of 14) [23/03/2005 05:48:51 p.m.]
I think that if you feel homosexuality is wrong, it is not a phobia, it is an
opinion. I don't think being a minority makes you a victim of anything except
numbers.
The only things I can think of that are truly discriminatory are things like
the United Negro College Fund, Jet Magazine, Black Entertainment Television,
and Miss Black America. Try to have things like the United Caucasian College
Fund, Cloud Magazine, White Entertainment Television, or Miss White America;
and see what happens. Jesse Jackson will be knocking down your door.
I have the right "NOT" to be tolerant of others because they are different,
weird, or tick me off.
I believe that if you are selling me a milk shake, a pack of cigarettes, a
newspaper or a hotel room, you must do it in English! As a matter of fact,
if you want to be an American citizen, you should have to speak English!
My father and grandfather didn't die in vain so you can leave the countries
you were born in to come over and disrespect ours.
I think the police should have every right to shoot your sorry self if you
threaten them after they tell you to stop. If you can't understand the word
"freeze" or "stop" in English, see the above lines.
I don't think just because you were not born in this country, you are
qualified for any special loan programs, government sponsored bank loans
or tax breaks, etc., so you can open a hotel, coffee shop, trinket store,
or any other business.
We did not go to the aid of certain foreign countries and risk our lives in
wars to defend their freedoms, so that decades later they could come over
here and tell us our constitution is a living document; and open to their
interpretations.
I don't hate the rich. I don't pity the poor.
I know pro wrestling is fake, but so are movies and television. That doesn't
stop you from watching them.
I think Bill Gates has every right to keep every penny he made and continue
to make more. If it ticks you off, go invent the next operating system that's
better, and put your name on the building. Ask your buddy that invented the
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (12 of 14) [23/03/2005 05:48:51 p.m.]
Internet to help you.
It doesn't take a whole village to raise a child right, but it does take a
parent to stand up to the kid; and smack their little behinds when necessary,
and say "NO!"
"I think tattoos and piercing are fine if you want them, but please don't
pretend they are a political statement. And, please, stay home until that
new lip ring heals. I don't want to look at your ugly infected mouth as you
serve me french fries!
I don't go around saying I am a European-American because my great, great,
great, great, great, great grandfather was from Europe. I am proud to be
from America and nowhere else.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:afralisp@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
The AfraLisp Books and the Newsletter Collections are now available as one
downloadable installation file.
http://www.afralisp.com/zip2/AfraLisp_Books.zip ( 5227 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2004-18


http://www.afralisp.com/newsletter/2004/2004-18.htm (13 of 14) [23/03/2005 05:48:51 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-18
http://www.afralisp.com/newsletter/2004/2004-18.htm (14 of 14) [23/03/2005 05:48:51 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^
AfraLisp Newsletter No 2004-19
^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^
Tuesday 20th July 2004
=========================
http://www.afralisp.com
mailto:afralisp@iwynberg.com
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Just remember, if the world didn't suck, We'd all fall off.
=========================
The Front Stoep.
==============
The AfraLisp Newsletter is going through a change.
As from this weeks issue, the Newsletter will only be published on a two weekly basis.
On top of that, I've invited certain targeted people to participate in a whole new vision
of CAD related utterances. Why you may ask?
There are CAD forums around that do a sterling job of answering day to day questions
and many of you, like myself are very involved with them. But, I really believe that
there are some of you that would rather take a wee bit of time to put your thoughts on
paper and have them read and digested by a more discerning type of audience.
The people who have contributed in this issue have been threatened rather badly by myself,
my two sons, my three next door neighbours and my bank manager. I am though, eternally
grateful and would like to thank them profusely. I would also like to extend an open
invitation to anyone else who would like to submit an article. Any subject, it doesn't
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (1 of 19) [23/03/2005 05:48:54 p.m.]
particularly have to be about coding or CAD, it could be about anything that you feel
would be of interest to the readers.
Tell us about your job, a recent holiday, a funny thing that happened the other day,
etc, etc.
Of course this does not mean we won't be discussing CAD or coding, this I'm sure will
still be the main subject, I would just like to try and encourage other subject writers
to participate and hopefully we'll all learn something new.
Anyway, enough waffle from me and let's get on with the show.
Oh, one last thing, the next publication date will be Tuesday the 3rd of August, so I
will require all contributions by Monday the 2nd.
Kenny
======
Pearls of Wisdom
===============
When, where, how, and who discovered the exact time?
===============
Words of Wisdom
===============
The Cornfield
============
Col I.
=====
Hello and welcome to the first Cornfield column in the AfraLisp Newsletter.
Since this is the first one I will do a bit of introducing myself, and the column.
My name is Andy but everyone calls me Cornbread. I served for 8 years in the U.S.M.C
and my nickname comes from my time there. It stuck even after I left so I guess its
here to stay. I am a GIS developer for the worlds largest telecom and data provider.
Since my employer would rather not be mentioned Ill let you figure out for whom I work.
So since my background is largely GIS and Civil the articles in this column will be
heavily slanted in that direction. I suppose if you classify developers by their
language of choice I would be considered a C and C++ developer. I however enjoy using
many other types of languages from Lisp to Php. For most articles I will be using
Microsofts Visual C++ for the code and examples. If you dont have Visual Studio
the compiler and linker can be obtained for free here:
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (2 of 19) [23/03/2005 05:48:54 p.m.]
http://msdn.microsoft.com/visualc/vctoolkit2003/
That is a command line version of the one in Visual Studio.
I will be using VC++6 as that seems to be most prevalent in my industry as the compiler
of choice in the WIN32 environment. For all those already wondering, yes, you can write
arxs with that Free compiler listed above unlike other free compilers such as gcc due
to the fact that the ObjectArx static Lib format is not linkable directly from gcc
environments like Dec-Cpp. It is possible to port those static libs but it is more of a
pain than its worth given that you can get the above compiler for free.
I am a firm believer in Open Source solutions to real world corporate problems.
Thankfully my employer is very much so too. Since many of the countries to which this
newsletter is sent are developing countries Open Source solutions are particularly
attractive to this demographic too. Many of the things presented in this column will
show how to use Open Source solutions for GIS. This will save you a bundle and keep
your company from getting fleeced by large software corporations like ESRI, MapInfo
and AutoDesk.
The next few articles will be on how to read and write ESRI shape files from
within AutoCAD.
So first will be writing data out of drawings into shape files then after we are
done with that we will cover reading data into the drawing from shape files.
We will be covering simple geometry shape files first and then if there is enough
demand I will cover complex geometry files following that. If there isnt enough
demand for complex geometry files we will move directly into reading and writing
MapInfo .tab files. I will be using sample data, which was publicly available from
a South African web site. If you are from Africa and have some GIS data in a drawing
file that you want used in the demo apps please contact Kenny and we can go from there
as I do not have server space to host uploads. I would like to keep the examples in
African data sets preferably South Africa. So if you have some spatial data in drawing
files or have shape files please let Kenny and I know and I will take a look at them
and possibly use them in the demo. Shape files of streets in any well known African
city would be excellent as I could not find any on line.
This column was just a bit of an introduction. They next column will begin the tutorial.
The languages to be used will be C and C++. The project will be an .arx project done
in VC++6.
We will be using portions of the source from this library:
http://dl.maptools.org/dl/shapelib/
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (3 of 19) [23/03/2005 05:48:54 p.m.]
We will not be using the library itself. We will be recompiling portions of the source
into our project.So go to the above link and download the file shapelib-1.2.10.tar.gz .
We will be using that in the upcoming tutorials so please be proactive and get it
downloaded before hand.
I hope you all will enjoy my column,
Andy the Cornbread
=================
Boxed In.
=========
By Mr Randall Rath himself.
Occasionally Marie will decide that my office needs to be cleaned. She does this,
in her words, as a "favor" to me. I can think of no single other thing that I dread
more than a good "Marie"
cleaning of my office. You see, everything ends up in a box or, more accurately,
several unmarked boxes hidden deep within the bowels of our storage room.
Tax papers? Those are in the box with AC adapters and cables. Hard drives? Software CD's?
Checks? All in the same box, the one that was marked "Kitchen" but has since been
crossed out.
Of course, she doesn't know that they're in those boxes, I discover that later
when I need one of the aforementioned items. The conversation goes something like,
"What happened to the server discs?"
"Which discs?"
"The server discs, from Microsoft."
"What do they look like?"
"They are in a plastic case with 'Microsoft MSDN subscription' on the front"
"Oh, I put them in a box."
Damn, Damn, Damn the boxes.
The normal course of events from there involves several hours of me shouting things like,
"AH-HA! I found my razor!" from amidst a veritable sea of brown boxes and packing material
that I have simply dumped, dumping being the most expedient way to get to the bottom of
things, onto the floor while Marie watches on in, what I feel must be, total satisfaction.
You see, Marie thinks I hoard. Oh, she has never said it out loud, but I can see that
she thinks it.
She doesn't see the point behind keeping adapters, modems, old mother boards, well,
you get the idea.
One day she will thank me for keeping all of these items, when the world has finally
hit a shortage of AC adapters or modems became a valuable source of plastic.
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (4 of 19) [23/03/2005 05:48:54 p.m.]
And those motherboards? They contain GOLD fer cry'n out loud! Who throws gold away?
But really, the point is that it's Marie who fills our home with crap.
In our Kitchen she keeps a bag full of those ketchup packages you get from fast food
restaurants and we have a drawer full of plastic spoons with a napkin wrapped in little
plastic envelopes.
Old telephone directories? She keeps them. There's a whole stack of them next to her desk.
In the end I found my MSDN cases. Before she packed them away she reorganized them for me.
They are now all sorted by color. And yet, were I to run over her with my car, they would
call me the criminal.
===========
And now a few words from Marie:
To start with, I guess I should introduce myself.
My name is Marie Rath. I am the wife of Randall Rath whom administers CADVault.com.
Randall and I have been married going on 7 years. We started dating the first week I
started working for the Arizona Department of Corrections.
To start with the Department, we had to go to an academy called C.O.T.A., (Correctional
Officers Training Academy). It is kind of like being in boot camp, but not as strenuous.
We had to do push-ups, sit-ups and lots of running. The academy was 7 weeks long.
We also attended classes to show us how to do paperwork and more paperwork.
Not much hands on dealing with inmates. That didnt start until I was assigned to my
first unit.
My first unit was SMU I (Special Management Unit I) which housed, at the time, all
the really bad guys: rapist, murderers, child molesters and ones that could not get
along with the general population inmates, the trouble makers.
Being assigned to a lockdown unit my first year was a great challenge. The inmates are
lockdown 23 hours, 7 days a week. Learning to deal with the name calling, cat calls
and the nastiness of the male inmates was very hard.
Being a female officer in a male institution was even harder because most of the male
inmates hadnt seen a woman, besides in uniform, for years, so when new officers arrive,
they do their best to get whatever they can.
Randall has helped me deal with a lot of things when it comes to my job.
I dont think I would have lasted this long, going on 8 years, if it wasnt for him.
Marie Rath
=========
>From the Greenhouse
==================
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (5 of 19) [23/03/2005 05:48:54 p.m.]
Rotate with reference:
One of the shortest yet most useful lisp programs I have written automates the reference
option incorporated in the standard rotate command. (Who, like me, never even noticed the
reference option?) I often have the need to rotate one or more objects about a point by a
specific angle. After selecting the rotate command, and then selecting one or more objects
you are then promoted to "Specify base point:" followed by "Specify rotation angle or
[Reference]:". If you type "R", your are then required to "Specify the reference angle <0>:".
This is where it all gets a bit messy for me, and hence why I wrote this program:
;CODING STARTS HERE
; rot.lsp - Rotates selected objects about a reference point through a selected angle.
;C W Green 9/3/99
(defun c:rot ( / p1 p2)
(prompt "\nSelect objects to rotate: ")
(ssget)
(setq p1 (getpoint "\nCentre of rotation: "))
(setq p2 (getpoint p1 "\nReference point: "))
(command "rotate" "p" "" p1 "r" p1 p2 pause)
(princ)
);defun
(princ)
;CODING ENDS HERE
Load the program into AutoCAD and type "rot". Select the required object(s),
select the centre of rotation followed by the reference point
(normally the end point etc of one of the objects to be rotated) and
finally select the point you want the objects rotated to.
I think you will find the program saves a few steps and is a whole lot easier to use.
DOSLib:
I am a big fan of DOSLib. - Thanks Kenny for putting me on to it! If you haven't
heard of it before, it basically provides an extension to the AutoLISP command
language and provides Drive functions, Path functions, Directory functions,
File functions, Printer functions, Configuration functions, Process functions,
Graphical User Interface functions, String functions, AutoCAD Specific functions,
DOSLib functions and System and Other functions.
I have found the Graphical User Interface functions particularly useful as they
often remove the need to write DCL code. You can create quite professional looking
programs with the minimum of fuss. As far as I'm concerned, it is a 'MUST HAVE',
and it's FREE from Robert McNeel & Associates ( www.mcneel.com ). The current
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (6 of 19) [23/03/2005 05:48:54 p.m.]
version is DOSLib 6.1.
There are varieties of the program for the different versions of AutoCAD and a
very comprehensive manual is provided. There are a number of ways of loading
DOSLib (refer to the manual), but I just use AutoCAD's appload function to add the
required DOSLib .ARX file to the startup suit.
Having said all this, I did run into a small problem recently using DOSLib - and
please note, this is the only problem I have ever had using DOSLib. I developed a
reasonably large lisp program using many of the DOSLib 6.1 functions. The program
worked fine in AutoCAD2000, but 'crashed' when run in AutoCAD 2004. I tracked the
problem down to some sort of clash between the dos_splash command and the
dos_msgboxex command.
(dos_splash and dos_msgboxex are DOSLib functions.) The splash command displays
one of those annoying bit maps when you start a program and I used the msgboxex
command to display the opening option menu for my LISP program.
The offending code fragment is shown below - (Don't bother loading it, as it
is incomplete and the required bit map file is not provided):
(defun c:autorev ()
(dos_splash "c://autorev.bmp" 2) ; Display the bit map file for 2 seconds ;
(setq text "Drawing Revision Program")
(setq buttons (list "Define Revision" "AutoRev" "Test" "Exit")) ; Program options
(setq option (dos_msgboxex text "AutoRev:" buttons 4)) ; Run the required option
(cond ((= option 0) (revdef))) (cond ((= option 1) (revup1)))
(cond ((= option 2) (revdwg))) (cond ((= option 3) (exit)))
)
I emailed Robert McNeel & Associates seeking a resolution to this problem and
received an email the following day with a revised version of DOSLib for AutoCAD 2004.
I think you would have to agree this sort of support for any program, let alone a
free one, is not bad at all! Needless to say, the revised version fixed the
'crashing' problem.
Dale, from Robert McNeel & Associates, informed me that the culprit was the
splash function.
Apparently both dos_splash and dos_msgboxex are multi-threaded functions.
I have no idea what this means but he sure fixed the problem!
If you have any interesting lisp programs using DOSLib, please send them in to Kenny.
I know I would be interested in seeing them and they may give others (and me)
ideas for future programs.
Craig Green
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (7 of 19) [23/03/2005 05:48:54 p.m.]
========
Is Autodesks pricing policy paying off?
================================
By The Baker Man
Many years ago when I started using, and selling, AutoCAD the price was
very competitive.
About 20 years ago AutoCAD was a saviour to many designers when the only
other systems on the market were bundled with dedicated hardware and sold
for many times AutoCADs price.
In anticipation of AutoCAD coming out on something better than the IBM PCs
320 x 200 resolution 4-colour option, I bought a NCR DM5 PC running on its
own version of DOS.
This PC, the NCR DM5, gave a fantastic 640 x 480, 8 colour option, and
was a great improvement. It was not a long wait before AutoCAD was available
on many other platforms including the NCR DM5.
(Some of the other platforms that AutoCAD supported were Wang, Radio Shack,
Hewlett Packard and Olivetti and later on also Apple Mac, Unix in the form of
SCO and Sun Spark.)
What has this got to do with price? I hear you say. Well, it allowed
Autodesk to have a very wide user base, and the customers a very good
entry price. Over the years AutoCAD has improved enormously and Autodesk
have cut back to running only on Microsoft Windows, but the prices have increased
enormously.
I am not a marketing fundi and I do realise that the market determines the
price of any goods. As long as people are prepared to pay the asking price,
even if relatively high, then the product will sell. My argument however is
that there is a correlation between the price of a product and the sales volumes.
Simply put, if you sold twice the volume by halving the price you would still
realise the same turnover.
If you however sold 3 times as much by halving the price, then the price
reduction is justified.
You would also be better off strategically by gaining a larger market share.
After all, AutoCADs wide user base is a direct result of its affordability
when first launched, especially by the small one-man size businesses.
In my humble opinion I believe that Autodesk products are today generally
overpriced, and that this is affecting their sales volumes. When are Autodesk
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (8 of 19) [23/03/2005 05:48:54 p.m.]
going to do a proper market survey to determine what the correct price for
their products are?
When are Autodesk going to talk to the end user to see how they feel about
their products and prices? Sure Autodesk have great products, but so do their
competitors. I have spoken to many end users and I have yet to find one that
thinks Autodesks products are priced competitively priced. As a result Autodesk
are loosing market share, or at least not gaining the market share they would like to.
What do you think?
Please note that this is my personal opinion and is not the opinion of any other
person or company.
Terry Baker
==========
Daves Corner
===========
Here is a little something to get started. I have recently been playing around
with this lisp routine.
It was not originally written by myself.
It was originally a routine to write the co-ordinates of picked points to an
ASCII file.
I adapted it to create a table in AutoCAD. I have since modified it to add a
few more choices as to how the table is drawn, ie with or without labels and
levels and also to read the 3D info of the selected points. The most recent
modification made is to select a polyline and automatically number the
vertices and add the generated number along with the co-ordinates of the
vertex to the table. I have placed the routine in a zip file as the coding is
quite long.
You can download the program using this link:
http://www.afralisp.com/zip2/coordtbl.zip
I am currently preparing a "book" in pdf format of an alternative look at
some of the the more advanced commands in AutoCAD. This stemmed from a
request in my office for a dummies guide to AutoCAD for occasional CAD users.
I had intended to have it published in the hope of making a bit of money, but
the length of time it took me to write and the rapid advancement of AutoCAD,
has already outdated my efforts (it is written for AutoCAD 2000, but
hopefully it will still be of use to someone).
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (9 of 19) [23/03/2005 05:48:54 p.m.]
Will post it as soon as possible.
Lastly some sites that I find quite interesting:
For some useful Tips & Tricks
www.cadtutor.net
www.postalcad.com
For some useful routines to interconnect AutoCAD with MS Excel:
www.ikozmos.com
and for those interested in 3D and rendering resources, etc:
www.3dm-mc.com
www.accustudio.com
Dave Corral
==========
Images and AutoCAD
=================
By Stig Madsen
Kenny has been so kind as to ask me to contribute with a few writings in
his popular AfraLisp newsletter (well, actually he threatened to break my
legs if I didnt contribute but that's another story). So, seeing that he -
that'd be Kenny - made it a standing invitation to contribute on a regular
basis, I thought it might be in place with a tiny introduction - just to
get it over with. I'm a batchelor architect, 43 years old and live in the
capital of Denmark.
AutoCAD has been part of my field of activity for 14 years or so, and
AutoLISP for almost as long.
Currently I'm employed at a state institution where I mostly am involved in
structural maintenance.
Because AutoLISP is what I know best of the API's that AutoCAD has to offer,
any ramblings of mine here will be entangled with parantheses. However, while
being honored to contribute (and thankful for keeping my legs), I don't think
there are many subjects that haven't already been covered on the AfraLisp website
and that alone can make it a bit of a hurdle to come up with new topics. So,
if you have any ideas for future topics, please let me know - either via Kenny
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (10 of 19) [23/03/2005 05:48:54 p.m.]
or directly at intervision@wanadoo.dk
In this issue I thought we might have a look at how images are accessed via
AutoLISP.
We won't go deep into detail or write much code but it will be a rather long
rant, anyhow.
So itll be the only topic from my hand this time.
AutoCAD has plenty of commands to deal with images, the center of which is the
Image Manager. I don't think I've ever heard anyone complain about shortcomings
of the image facilities so why even bother to dig into the subject? Two reasons.
It can often be confusing to obtain information on how images are stored - and
the more information, the better. Number two reason is that some useful routines
can, after all, be written to extend the existing facilities.
Ever thought there should to be an IMAGEDETACH command like there is an IMAGEATTACH
command? It wouldn't be difficult to write one.
Images have much in common with blocks in the sense that multiple instances of the
same image can point to the same image attachment. To start explaining how this is
accomplished, try the following sequence:
- Open the Image Manager with command IMAGE and attach an image.
- Use COPY to make a few copies of the image in model space.
- Open the Image Manager again. Notice that there is only one image attached.
Click on Browse and select a different image. Exit the Image Manager by hitting OK.
- Back in model space, all images will change to the new image.
When an image is attached to a drawing, two things normally happen: 1. A non-graphical
image definition is created, and 2., a graphical entity that displays the image in
the drawing editor is created. The entity type of the image definition is IMAGEDEF.
It is stored in the main dictionary in the drawing. The entity type of the displayed
image is IMAGE. It is stored in the drawing database just like lines, circles and
other graphical entities.
Image definitions hold very little but crucial information. First and foremost, it
contains the name of the image file and the path, if specified. Other pieces of
information kept by the image definition are: Image size in pixels, units of a pixel,
load/unload status and resolution units.
As we would expect, the definition doesn't keep information about insertion point,
rotation, scale factor and other things that are specific to the onscreen representation.
Those properties are related to the image entity.
You may have noticed that each image is given a name by the Image Manager. The default
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (11 of 19) [23/03/2005 05:48:54 p.m.]
name is simply the image file with the extension cut off but it can be renamed arbitrarily,
following standard naming conventions. However, the name is not part of the image definition
entity list because it doesnt need to be, due to the way dictionary entries are built.
Lets try and insert an image and see how its put together. For the sake of this virtual
test, lets say we have an image with the filename and path C:\Images\house.jpg.
Let the size be 640x380 pixels and the resolution 96 dpi.
We now attach the image - via the Image Manager - at WCS 0,0,0 in model space.
Scale factor is 1.0 and rotation is zero (we take it that the path is saved with the image).
After completing the attachment, the image will be named house, which is simply the
base file name. Using ENTGET and ENTLAST we can get an entity list similar to this:
Command: (setq imgEnt (entget (entlast)))
((-1 . <Entity name: 7ef710e0>)(0 . "IMAGE")(330 . <Entity name: 7ef5ccf8>)
(5 . "10C") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0")
(100 . "AcDbRasterImage")(90 . 0)(10 0.0 0.0 0.0)(11 0.264583 0.0 0.0)
(12 0.0 0.264583 0.0)(13 640.0 380.0 0.0)(340 .
<Entity name: 7ef710d0>) (70 . 7)(280 . 0)(281 . 50)(282 . 50)(283 . 0)
(360 . <Entity name: 7ef710d8>)(71 . 1)(91 . 2)
(14 -0.5 -0.5 0.0) (14 639.5 379.5 0.0))
This is the IMAGE entity that is saved in the drawing database along with all
other graphical entities. The image definition resides in the main dictionary
in an entry called ACAD_IMAGE_DICT.
Lets try to do a search for our image:
Command: (dictsearch (namedobjdict) "ACAD_IMAGE_DICT")
((-1 . <Entity name: 7ef5cf70>)(0 . "DICTIONARY")(5 . "E6")
(102 . "{ACAD_REACTORS")(330 . <Entity name: 7ef5cc60>)(102 . "}") (330 .
<Entity name: 7ef5cc60>)(100 . "AcDbDictionary")(280 . 0)(281 . 1)
(3 . "house")(350 . <Entity name: 7ef710d0>))
There it is at the bottom. Each entry consists of a name (code 3) and an
entity name (code 350) that holds the actual data. Thats the only place
where the name occurs. If you change the name of an image, it will affect the entry name.
Notice that the entity name of the dictionary entry, <Entity name: 7ef710d0>,
is the same as the entity name in code 340 of the IMAGE entity. Thats the only
immediate link between the image entity and the image definition (there are
other links but we won't go there this time). Whether we get hold of the image
definition by image entity or by dictionary is almost indifferent, 'almost'
because in the case where all image entities have been deleted, i.e. in the
case of an unreferenced image definition, the only way is to tap into the dictionary.
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (12 of 19) [23/03/2005 05:48:54 p.m.]
Lets dig further into the image definition:
(setq imgDict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
(setq imgDef (dictsearch (cdr (assoc -1 imgDict)) "house"))
The returned entity will look similar to this (with the reactor stuff cut out):
((-1 . <Entity name: 7ef710d0>)(0 . "IMAGEDEF")(5 . "10A") ...
(330 . <Entity name: 7ef5cf70>) (100 . "AcDbRasterImageDef") (90 . 0)
(1 . "C:\\Images\\house.jpg")(10 640.0 380.0 0.0)(11 0.264583 0.264583 0.0) (280 . 1) (281 . 5))
Code 10 is not an insertion point; its the dimensions of the image in pixels.
Code 11 is a unit vector that describes the number of units per pixel and code 281
is the resolution unit.
These data remain static until the image definition is deleted or changed by
referencing another file. From it we can calculate image dimensions in
drawing units: X_units = width * U, where U is the X-portion of the unit vector.
The calculation is similar for the Y direction.
So with a resolution unit of millimeters, the image width and height will be:
(setq x_units (* (car (cdr (assoc 10 imgDef)))(car (cdr (assoc 11 imgDef)))))
-> 169.333 units
(setq y_units (* (cadr (cdr (assoc 10 imgDef)))(cadr (cdr (assoc 11 imgDef)))))
-> 100.542 units
The dimensions depend on the resolution units in code 281, which initially depends on
information in the graphics file or the system variable INSUNITS. Either way,
the image definition unit vector is unitless in the sense that it always is
expressed in units per pixel.
It's only when creating an image entity that the resolution unit is used,
hence the need for keeping the information separate in code 281
(and using INSUNITS).
For example, if the image is attached using inches as the resolution unit,
the image is scaled by a factor of 25.4 in proportion to metric units.
To convert manually, simply divide by 25.4 (or multiply if you're in inches a
nd want millimeters):
(setq x_units (/ x_units 25.4)) -> 6.6667 (setq y_units (/ y_units 25.4)) -> 3.9583
>From the unit vector, you can extract the resolution of the image. If
>you want it in dpi, simply
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (13 of 19) [23/03/2005 05:48:54 p.m.]
divide 25.4 with the unit vector:
(setq x_res (/ 25.4 (car (cdr (assoc 11 imgDef))))) -> 96.0 dpi
(setq y_res (/ 25.4 (cadr (cdr (assoc 11 imgDef))))) -> 96.0 dpi
When the image is inserted into the drawing, it can be scaled and rotated arbitrarily.
This will not affect the image definition values. As implied above, the
image definition needs to keep the parameters intact so that multiple image
entities can be created without affecting each other. Changing INSUNITS between
attachments will affect the scaling factors of existing images but it will not
affect the physical size because it's in a given relation to the unit vector of
the image definition.
The image entity holds alot more info than the definition. Naturally, it holds the
insertion point but it has no need of an explicit rotation angle or scaling factor
because it has its own set of unit vectors from which to calculate both angle and
scale. Unit vectors are given for both X and Y directions, or in terms of image mapping,
in U and V directions. This means that there can actually be separate rotations and
scale factors for any given image (as a funny side effect it also means that it is
possible to skew an image). But AutoCAD always uses the U vector for rotation and scale.
To calculate the rotation of the image, extract the U vector in code 11 and make use of ATAN:
(setq u_vec (cdr (assoc 11 imgEnt)))
(if (equal (cadr u_vec) 0.0 1e-6)
0.0
(atan (/ (car u_vec)(cadr u_vec)))
)
The scale factor is a little more complicated because it depends on the current
setting of INSUNITS.
It's always possible to get hold of the scale factor between an image entity and
the corresponding image defintion by comparing the X-portions of unit vectors.
(setq u_vec (cdr (assoc 11 imgEnt)))
(setq def_vec (cdr (assoc 11 imgDef)))
(setq scale (/ (car def_vec)(car u_vec)))
If you ever need the scale relationship between multiple instances of the same
images you can do the same but with image entity vectors (it will give the
difference between INSUNITS at the time of attachments).
Other properties in the image entity are the brightness, contrast and fade values.
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (14 of 19) [23/03/2005 05:48:54 p.m.]
They can be interesting from a programming point of view because changes can be
applied to multiple images in one go.
Clipping coordinates are embedded directly within the image entity. When an image
is inserted, it has two diagonally clipping points set by default. They don't
affect clipping but can be adjusted to whatever you want. If you add clipping
point to make a polygonal clipping then remember to provide the correct number
of vertices in code 91.
Before Kenny starts to edit this submission because it starts to take up an
obscene amount of space in his newsletter, let's stop it here.
On the other hand, there wasn't much code to go with so here's a take on
writing an IMAGEDETACH command. It simply uses the fact that image definitions
are dictionary entries that can be referenced by name, so it runs through each
that matches the users search pattern and deletes the entry.
However, in release 2004 and below it might leave invisible image entities in
the drawing so, if you decide to use this code, it comes with the home assignment
to figure out how to remove both the image definitions and the image entities :)
;; CODING STARTS HERE
(defun getImgList (aDict / alist)
(while (setq aDict (member (assoc 3 aDict) aDict))
(setq alist (cons (cdar aDict) alist)
aDict (cdr aDict)
)
)
alist
)
(defun C:IMAGEDETACH (/ imgDict imgDefs imgList imgEnt searchStr tmp a b cmd)
(vl-load-com)
(setq cmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "UNDO" "Begin")
(cond
((setq imgDict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
(setq imgList (getImgList imgDict))
(foreach n imgList
(setq imgEnt (cdr (assoc -1 (dictsearch (cdr (assoc -1 imgDict)) n)))
imgDefs (cons (cons n imgEnt) imgDefs)))
(if imgList
(cond
((/= (setq searchStr (getstring "Images to search for: ")) "")
(setq a 1)
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (15 of 19) [23/03/2005 05:48:54 p.m.]
(cond ((vl-string-position 44 searchStr)
(while (setq b (vl-string-position 44 searchStr))
(setq tmp (cons (strcase (substr searchStr a b)) tmp))
(setq searchStr (substr searchStr (+ 2 b)) a 1)
)
(setq tmp (reverse (cons (strcase searchStr) tmp)))
)
(T (setq tmp (list (strcase searchStr))))
)
(foreach n imgDefs
(cond ((or (member (car n) tmp)
(wcmatch (strcase (car n))
(apply 'strcat
(mapcar '(lambda (n) (strcat n ",")) tmp)
))
)
(initget "Yes No")
(cond ((/= (getkword
(strcat "\nDelete image " (car n) "? <Yes>/No: ")
) "No")
(entdel (dictremove (cdr (assoc -1 imgDict)) (car n))))
)
)
)
)
)
)
)
)
)
(command "UNDO" "End")
(setvar "CMDECHO" cmd)
(princ)
)
;;; CODING ENDS HERE
Stig Madsen
===========
Things Weird and Wonderful
========================
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (16 of 19) [23/03/2005 05:48:54 p.m.]
New from McAfee:
WiScan. It removes all Windows programs.
==========
Miscellaneous Stuff that I almost Forgot ================================
We use AutoCAD Mechanical and have chosen to stay at version 6 for right now
(its AutoCAD 2002). Well it seems that some of our customers use Mechanical 2004,
that seems okay, we just tell them to save down to AutoCAD 2000.
Well, that works for plain AutoCAD but not the Mechanical version, it crashes
version 6 whenever you open the "saved to 2000 version".
We fix it by opening it in 2004 (we carry one seat for compatibility issues),
wblocking the entities (in modelspace only, its a wblock thing) and then
reopening it in 2004 and then saving to 2000...
stupid. I got on the Autodesk forum and asked about it, the rep said we
should install 2004 across the board and the problem would go away.
Wrong answer.
I realize you cannot support older software forever, but when you say
you save to an older version, it should able to be opened in that older version.
Wow, glad I got that off my chest. Thanks and keep up the good work.
John Walker
===========
The Back Stoep
=============
HANGOVERS
===========
One Star Hangover (*)
No pain. No real feeling of illness. You're able to function relatively well.
However, you are still parched. You can drink
5 sodas and still feel this way. For some reason, you are craving a steak & fries.
Two Star Hangover (**)
No pain, but something is definitely amiss. You may look okay, but you have the
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (17 of 19) [23/03/2005 05:48:54 p.m.]
mental capacity of a staple gun. The coffee you are chugging is only increasing
your rumbling gut, which is still tossing around the fruity pancake from the
3:00 AM Curry House excursion. There is some definite havoc being wreaked upon your bowels.
Three Star Hangover (***)
Slight headache. Stomach feels crappy. You are definitely not productive.
Anytime a girl walks by you gag because her perfume reminds you of the
flavored schnapps shots your alcoholic friends dared you to drink.
Life would be better right now if you were home in your bed watching Lucy reruns.
You've had 4 cups of coffee, a gallon of water, 3 iced teas and a diet Coke ---
yet you haven't peed once.
Four Star Hangover (****)
Life sucks. Your head is throbbing. You can't speak too quickly or else you might puke.
Your boss has already lambasted you for being late and has given you a lecture for
reeking of booze. You wore nice clothes, but that can't hide the fact that you
only shaved one side of your face. (For the ladies, it looks like you put your
makeup on while riding the bumper cars.) Your eyes look like one big red vein,
and even your hair hurts. Your sphincter is in perpetual spasm, and the first
of about five shits you take during the day brings water to the eyes of everyone
who enters the bathroom.
Five Star Hangover, (*****)
You have a second heartbeat in your head, which is actually annoying the employee
who sits in the next cube. Vodka vapor is seeping out of every pore and making you
dizzy. You still have toothpaste crust in the corners of your mouth from brushing
your teeth in an attempt to get the remnants of the poop fairy out. Your body has
lost the ability to generate saliva so your tongue is suffocating you. You don't
have the foggiest idea who the hell the stranger was passed out in your bed this
morning. Any attempt to defecate results in a fire hose like discharge of
alcohol-scented fluid with a rare 'floater' thrown in. The sole purpose of this
'floater' seems to be to splash the toilet water all over your ass. Death sounds
pretty good right about now....
^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-^-.,.-
Tara the noo,
Kenny Ramage Q.B.E.
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (18 of 19) [23/03/2005 05:48:54 p.m.]
---------------------------------------------------------
AfraLisp :
http://www.afralisp.com
mailto:afralisp@iwynberg.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
The AfraLisp Books and the Newsletter Collections are now available as one
downloadable installation file.
http://www.afralisp.com/zip2/AfraLisp_Books.zip ( 5227 kb )
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2004-19
http://www.afralisp.com/newsletter/2004/2004-19.htm (19 of 19) [23/03/2005 05:48:54 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-01
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
This space left blank 'cos the paint is still drying.
=========================
The Front Stoep.
==============
Welcome to the very first 2003 issue of the "AfraLisp Newsletter".
("Happy Days are here again........")
If you've got any sense and would like to make a couple of dollars or two, I would suggest that you
archive this email somewhere very safe 'cos in a couple of years it will become quite collectable.
Why? Don't ask me, I'm just the bleedin' pencil jockey who gets forced into writing this Newsletter,
never gets paid and basically does it for the love of his fellow homo-sapien. (Go on, groan, I don't
care, I can take it).
Anyway, where was I, oh yeah, I was about to tell you all about the "AfraLisp Newsletter", it's ideals
and desires, it's wish for peace for all mankind, the hope that all children through out the world will
have an education and live a happy and fulfilled life, the expectancy that you all will think that I'm
witty and funny and will send me vast quantities of beer from your home countries. And that folks
is just my aim for this first issue!!!
=========
"What the heck are you waffling on about Kenny?"
Okay, here's the deal. Dead simple.
The idea of this Newsletter is basically to allow me, and you of course, to have your say
concerning AutoLisp/Visual Lisp/VBA or VB. It could be a coding snippet that you would like the
world to see, or a good coding site that you've just come across, or maybe just a bitch at AutoDesk
for charging you too much for their product. In fact, anything - the juicier and more gossip ridden
the better!!
Then again, you might even come across a site or some article that is SO GOOD but has nothing to
do with coding but you feel, deep down in your heart, that we all should know about it. That's also
fine and in fact will be encouraged.
I'd also like this Newsletter to be a place where AutoCAD coders who are maybe a wee bit busy to
spend time on-line, or have a problem getting on-line, can catch up on what is going on, and can
still participate without incuring the wrath of their IT departments, wives, girlfriends,
bit-on-the-side, etc.
I will, and now I give you all plenty of notice, be "borrowing" all sorts of things from all sorts of
places - such as emails that I may happen to receive- so please, watch your language. I will also,
on top of all that, be letting you know about any other sort of weird and wondeful subject that I
may happen to stumble across.
===========
What have I got for you in this issue?
Let's have a wee look................
Pearls of Wisdom
===============
"Beauty is in the eye of the beer holder"
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (1 of 6) [23/03/2005 05:48:57 p.m.]
===============
Coding
=======
{this is where your input is required)
The AfraLisp Custo Menu
======================
The AfraLisp 2002 Custom Menu is the result of many hours of late night planning and innovative
co-ordination of the lateral type which resulted in the decision to "steal" as much as possible from
other AutoLisp coders and stuff the consequences. The result? Well you only have to have a look
at the AutoCAD menu to see where most of their routines originate from. So if they can do it, why
can't I?
To be honest (sic), the menu is basically an accumulation of AutoLisp routines that I've written,
re-written, stolen, been given, gathered and modified over the years. Each routine, well most, have
been used extensively within a professional drawing office over the past 10 to 12 years and are still
being used in a production environment to this day.
I'd also like to let you know that the AfraLisp 2002 Custom Menu has been extensively tested (well
sort off) on AutoCAD 2002 and an old 1968 Ford Escort with a re-engineered carburetor. The
AfraLisp 2002 Custom Menu should work on AutoCAD 2000 and 2000i and maybe (???) even on
AutoCAD R14 although I haven't performed any testing on any of them. (and don't intend too
either.)
The AfraLisp 2002 Custom Menu consists of 15 main sections and numerous sub-sections named
1 to 15. The menu has cunningly been divided into subject related work areas that have been
chosen and designed to confuse you as much as possible.
Download your copy now - http://www.afralisp.com/
Hey, it's free.......
====================
And on a similar note, David Stein writes :
DSX Tools 2004.04.26.03 released
Besides some pesky little bug-fixes, this also includes a new menu resource DLL thanks to John
Raiten. The bug fix is a doozy. Get this: I pound my feeble chest with the updated stuff in the
Visual LISP book regarding changes in AutoCAD 2004 Vlisp, and I end up eating my own mess.
In particular, the issue of (vlax-put) not working on certain objects.
For those of you doing VLISP programming, you must now use (vlax-put-property) instead. If
you're using 2004.03.21, try the DSL command on an associative dimension and you'll see what I
mean. That's fixed now. I should follow my own advise, huh?
--------------------------------------------------
DSX Tools 2004.04.26.03 Posted in English, German only
In addition to language limitations, I've added a download for a Microsoft SMS package file for use
with SMS 2.0 or 2003. This allows you folks using SMS to easily build a package to deploy this
around your network.
I'm not planning to post installers for Spanish, Italian or French unless I get requests to do so.
------------
DSX Tools - Freeware for AutoCAD
http://www.dsxcad.com/
===============
Want to delete all Rtext in your drawing?
(command ".erase" (ssget "x" '((0 . "RTEXT"))) "")
===============
Here's a replacement for the Split function under VB4 and VB5.
Note that the return value is a Variant that contains an array of strings
'CODING STARTS HERE
Function Split(ByVal Text As String, Optional ByVal Delimiter As String = " ", _
Optional ByVal Limit As Long = -1, Optional CompareMethod As _
VbCompareMethod = vbBinaryCompare) As Variant
ReDim res(0 To 100) As String
Dim resCount As Long
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (2 of 6) [23/03/2005 05:48:57 p.m.]
Dim length As Long
Dim startIndex As Long
Dim endIndex As Long
length = Len(Text)
startIndex = 1
Do While startIndex <= length And resCount <> Limit
' get the next delimiter
endIndex = InStr(startIndex, Text, Delimiter, CompareMethod)
If endIndex = 0 Then endIndex = length + 1
' make room in the array, if necessary
If resCount > UBound(res) Then
ReDim Preserve res(0 To resCount + 99) As String
End If
' store the new element
res(resCount) = Mid$(Text, startIndex, endIndex - startIndex)
resCount = resCount + 1
startIndex = endIndex + Len(Delimiter)
Loop
' trim unused values
ReDim Preserve res(0 To resCount - 1) As String
' return the array inside a Variant
Split = res()
End Function
'CODING ENDS HERE
==============
Kenny,
Just wanted to drop you a line and say thanks for all of the tid-bits of lisp codes and humor. I'm
designing some software for the millwork industry and if I ever get it off the ground I'll be glad to
donate a few ducketts towards the beer fund.
I'm also a musician and like to drink beer (the music helps me get women. The beer makes them
look better!!)
Q: Are all programmers insane?
Thanx again
John Michael Hivatal
===========
Hello,
I was just told about this web site and I must tell ya I really like it.
Here is a little trick that I did to my osnap cursor menu.I come across a lot of users who are not
aware of this function, 'Cal - Mee.
I'm sure you know what it does, so I won't waste time.
I used to use a 12 button puck & tablet and had this programmed on button #4. Now, in the modern
world of the InteliMouse, I have given up my beloved tablet,
so here is what i have done the my Acad menu.
[&Object Snap Cursor Menu]
ID_Tracking [Temporary trac&k point]_tt
ID_From [&From]_from
ID_MnPointFi [->Poin&t Filters]
ID_PointFilx [.X].X
ID_PointFily [.Y].Y
ID_PointFilz [.Z].Z
[--]
ID_PointFixy [.XY].XY
ID_PointFixz [.XZ].XZ
ID_PointFiyz [<-.YZ].YZ
[--]
ID_OsnapEndp [&Endpoint]_endp
ID_OsnapMidp [&Midpoint]_mid
ID_OsnapInte [&Intersection]_int
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (3 of 6) [23/03/2005 05:48:57 p.m.]
ID_OsnapAppa [&Apparent Intersect]_appint
ID_OsnapExte [E&xtension]_ext
[--]
ID_OsnapCent [&Center]_cen
ID_OsnapQuad [&Quadrant]_qua
ID_OsnapTang [Tan&gent]_tan
[--]
ID_OsnapPerp [&Perpendicular]_per
ID_OsnapPara [Para&llel]_par
ID_OsnapNode [No&de]_nod
ID_OsnapInse [In&sert]_ins
ID_OsnapNear [Nea&rest]_nea
ID_OsnapNone [&None]_non
[--]
ID_Osnap [&Osnap Settings...]'_+dsettings 2
[--]
[Cal-Mee Expression]'cal;mee;
Perhaps you might agree that this is a pretty handy tip, or maybe not. In any case, thanks for the
informative web site.
John Lauer
Things Weird and Wondeful
========================
Want to meet the inventor of the Internet?
Introducing Mr Tim Berners-Lee
http://www.ibiblio.org/pioneers/lee.html
And I hope you all notice that he is British!!
==========
Have look at this :
http://kevan.org/brain.cgi?Kenny%20Ramage
Miscellaneous Rubbish that I almost Forgot
===================================
AutoCAD 2004.
I just received my upgrade a couple of weeks ago.
Because of the Easter hols, I've only had a chance to have a wee look.
The Jury is Still Out.
More in the next issue.
Oh, and talking about AutoCAD, have you seen my write up on Autocad VV-Light?
You'll find it under the "Rubbish" section at http://www.afralisp.com
==================
Next week I'll also be having a look at some AutoCad Coding sites and listing them hereupon. So,
if you have or know about a site, just let me know.
Here's a wee taste :
CAD Encoding - The Journal is focused on helping you to improve your work environment with
tutorials and working code examples written in, and for, the most popular customizing languages
for the major CAD software programs and Microsoft Office products - Visual Basic for
Applications, Visual Basic, Visual C++, AutoLisp, Visual Lisp, and DCL.
http://www.cadencoding.com
The Back Stoep
=============
If you feel that you would also like to become a lowly unpaid hack. or have visions of grandeur by
seeing your name in print, then drop me a line at this address:
mailto:afralisp@mweb.com.na
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (4 of 6) [23/03/2005 05:48:57 p.m.]
Please, no BIG attachments.
Oh, I reserve the right to edit as I deem fit, change your phrasing to make me look good, correct
spelling mistakes, improve on your English and remove all swear words. Are you not happy with
that? Hey, lifes tough......
==================
Ever Wonder........
...why the sun lightens our hair, but darkens our skin?
...why women can't put on mascara with their mouth closed?
...why you don't ever see the headline Psychic Wins Lottery?
...why abbreviated is such a long word?
...why doctors call what they do practice?
...why you have to click on Start to stop Windows?
...why lemon juice is made with artificial flavor, while dishwashing liquid is made with real lemons?
...why the man who invests all your money is called a broker?
...why there isn't mouse-flavored cat food?
...who tastes dog food when it has a new & improved flavor?
...why Noah didn't swat those two mosquitoes?
...why they sterilize the needle for lethal injections?
...why they don't make the whole plane out of the material used for the indestructible black box ?
...why sheep don't shrink when it rains?
...why they are called apartments when they are all stuck together?
...if con is the opposite of pro, is
Congress the opposite of progress?
...why they call the airport the terminal if flying is so safe?
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com
Look under the "Newsletter" section.
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
(The drunker you are, the better we sound!!)
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (5 of 6) [23/03/2005 05:48:57 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-01
http://www.afralisp.com/newsletter/2003/2003-01.htm (6 of 6) [23/03/2005 05:48:57 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-02
=========================
8th May 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Free Gift to be inserted here.
=========================
The Front Stoep.
==============
Well another week has passed us by and Christmas is getting closer. Have you started shopping
yet? Talking about Christmas reminds me to tell you that my band BedRock has released their
third CD "SO Where's The Party Now?" Aptly named for a Christmas or Birthday present I would
say! You'll find further details towards the end of this letter.
I've had quite a lot of emails from people saying that it's nice to see the Newsletter back. I must say
that it's nice to be writing the Newsletter again as I enjoy insulting people and I enjoy it even more
that they seem to enjoy it!!
A few questions this week that need answering so please, take a few minutes and give me hand.
Thanks to everyone who has contributed so far, and please keep them coming.
And, on a totally different subject, have you ever felt like being the next James Bond? If so, try this
out : http://www.secretservicetest.co.uk
Pearls of Wisdom
===============
Drink wet cement, and get completely stoned.
===============
Coding
=======
Here is a quick little snippet to load, run then unload a vba routine. also
included are my basic error handling routines.
to run: (vba-run "Filename" "Routine name")
;CODING STARTS HERE
(defun vba-run (file cmd)
(set_err) ;start error handling function
(if (null (findfile file)) ;check if file exists within support search paths
(exit) ;exit if file not found
)
(vl-vbaload (findfile file)) ;load vba file
(vl-vbarun cmd) ;run routine
(command "vbaunload" file) ;unload vba macro when finished
(reset_err) ;start function to reset settings
(princ) ;exit quietly
)
(defun set_err () ;redfine error function, save existing values of system
variables and set current values
(setq old_err *error*) ;save existing error function
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (1 of 7) [23/03/2005 05:48:58 p.m.]
(setq sys_vars (list (getvar "osmode") (getvar "cmdecho"))) ;save current
osmode and cmdecho variables
(setvar "osmode" 0) ;turn of osnaps
(setvar "cmdecho" 0) ;turn of command echoing
(setq *error* err_fun) ;set error function to user defined function
(princ) ;exit quitely
)
(defun err_fun (msg) ;user defined error function
(if (listp sys_vars) ;check to see if saved values exist
(progn
(setvar "osmode" (nth 0 sys_vars)) ;reset osnaps
(setvar "cmdecho" (nth 1 sys_vars)) ;reset command echoing
)
(progn ;if saved values not found use default values
(setvar "osmode" 35) ;set osnap to end,mid and int
(setvar "cmdecho" 1) ;turn command echoing on
)
)
(princ msg) ;display error message
(if olderr
(setq *error* old_err) ;reset saved error function
)
(princ) ;exit quitely
)
(defun reset_err () ;reset error function and system variables back to
previos state
(if (listp sys_vars) ;check for saved settings
(progn
(setvar "osmode" (nth 0 sys_vars)) ;reset osnaps
(setvar "cmdecho" (nth 1 sys_vars)) ;reset command echoing
)
(progn ;if saved values not found use default values
(setvar "osmode" 35) ;set osnap to end,mid and int
(setvar "cmdecho" 1) ;turn command echoing on
)
)
(if olderr
(setq *error* old_err) ;reset saved error function
)
(princ) ;exit quietly
)
;CODING ENDS HERE
I have the routines saved in the mnl file associated with the menu I use to
run most of my routines, although the ACAd.mnl file would do just as well.
Regards
Michel Loftus
============
Play .avi files in your program. Use this code to create a simple AVI player of your own, or use one
line of it to just run a avi file. (VB6 required)
Declarations: none
On your form, place a CommonDialog, a CommandButton and a Animation
(called : commondialog1, command1 and animation1)
Animation, and Common Dialog can be found in the tool bar, if you have
Professional+ Form controls, if not look through the Components menu, (right
click tool bar) and look for them there.
'CODING STARTS HERE
'Code:
Private Sub Command1_Click()
On Error GoTo cancel
CommonDialog1.ShowOpen ' brings up the Open screen
On Error GoTo error
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (2 of 7) [23/03/2005 05:48:58 p.m.]
Animation1.open CommonDialog1.FileName
' opens the selected file, and begins to play it - note, if you wish to only run an avi during 'an event,
like file copy, only this line is needed, just replace "CommonDialog1.FileName" 'with your avi, like
"c:\myavi.avi"
Exit Sub
error: MsgBox Err.Description, vbCritical, "Error Number " & Err.Number
cancel:
' if the user clicks cancel, the program does not open, it just leaves the sub
End Sub
Private Sub Form_Load()
Command1.Caption = "Load AVI" ' makes your button label correct
Animation1.AutoPlay = True ' ensures the selected avi plays when it is opened
CommonDialog1.CancelError = True
' makes the program follow the error goto if the user clicks cancel
End Sub
'CODING ENDS HERE
Sam Witney
============
> Here is a little trick that I did to my osnap cursor menu.I
> come across a lot of users who are not aware of this
> function, 'Cal - Mee.
> John Lauer
John's correct that most people forget about the calculator function. While John's code works, it is
too limiting for me - MEE only uses endpoints, so this is a step better :
'cal;(cur + cur)/2;
where CUR is short for any point selection within the confines of the calculator routine.
MikeTuersley
=============
I saw your tip in adding "CAL -> MEE" into the cursor menu. I've had that little diddy in mine for
some time now. Here's some others I added to make life simpler:
[->Calculator]
[GeomCal]'cal;
[Midway]'cal;(cur+cur)/2;
[Int+Int / 2]'cal;(int+int)/2;
[End+End / 2]'cal;(end+end)/2;
[End-End Dist]'cal;dist(end,end);
[<-Line Int]'cal;ill(end,end,end,end);
I also added another section that allows OSNAP combinations like END -> END so you can do them
in one pick instead of having to keep going back to the cursor menu again. Here's the section from
my cursor menu:
[->Multiple]
[End - End]_endp;\_endp;
[End - Int]_endp;\_int;
[End - Mid]_endp;\_mid;
[End - Perp]_endp;\_perp;
[Int - Int]_int;\_int;
[Int - End]_int;\_end;
[Cen - Cen]_center;\_center;
[Mid - Int]_mid;\_int;
[Mid - Perp]_mid;\_perp;
[Near - End]_near;\_endp;
[Near - Int]_near;\_int;
[<-Near - Perp]_near;\_perp;
<raising a chilled mug> Keep up the good work.
Jim Fisher
===========
Kenny,
Is there any way to code the basic input for civil polylines?
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (3 of 7) [23/03/2005 05:48:58 p.m.]
For example:
Start here (pick point or enter data)
to here (N47'@60D15'30"E)
to here (same yadayadayada as above....)
and so on
and so forth....
then close
.....shouldn't be too hard....or is it?
P.S. I wouldn't be asking if I thought it was easy.
Thanks,
Garry
=======
Dear Sir,
We have a network and I want to attatch an XREF drawing from the server, when doing so I want all
the layers to be turned to the color red in order to differentiate between my work and the attached
layers from other departments.
Best Regards
Maged
========
Hey Kenny,
Have you ever wished that you could embed a LISP macro into a drawing for distribution that
would automatically load upon opening of the drawing, and wouldn't require any programs to
reside on the desination computer?
This routine will do that.
I thought it was pretty cool.
Just embed the vba macro into a drawing, and then you run The lisp macro routine inside that
drawing.
Then load the lispmacro.lsp and lispmacro.dcl files into the dialog box. (to help unload and reload
the routines).
Then load any lisp routine or dcl file you want into the dialog box.
Save the drawing and then send it to anyone!
The dvb file will unpack the lisp routines, load them and unpack any dcl files (or ascii files) upon
drawing opening.
Later
Peter Jamtgaard
==============
You can download this application here :
http://www.afralisp.com/zip1/lispmacro1.zip
You will find other similar routines such as this at :
http://www.augi.com/empower/exchange/searchdownloads.asp
==============
Hi. Gotta question. I work for a company that runs fiber optic cable from city to city. On my
Autocad prints, I will list the total footage between poles and then, total the footage the for the
entire sheet.
Question: Is there a way in Autocad to have Autocad extract these values and add
them automatically to avoid human error?
Keith
=====
Things Weird and Wondeful
========================
As promised, a listing of some interesting and informative CAD related sites :
I have a few VBA freeware routines on http://www.CADmechanic.com if you
would like to share them with your readers - Andrew
===
AUGI Exchange
http://www.augi.com/empower/exchange/searchdownloads.asp
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (4 of 7) [23/03/2005 05:48:58 p.m.]
Some good stuff here and more to come.........
===
Most versions of DosLib can be found here :
ftp://ftp.mcneel.com/pub/doslib
===
I would like to point your interest to a very handy little stand-alone utility that color-codes each
pair of parentheses in your lisp code. This helps in quickly and easily pin-point the exact location
where the mismatch occurs. The utility can also optionally color-code any lisp keywords and
quoted text found in the code.
This utility is my independent personal work, and I would like to share it with all lisp coders out
there. It will work under any version of Windows (95/98/ME/XP). You can easily hot-link it from your
favorite lisp editor.
Please check out http://www.truetrans.com/paren.htm for a detailed explanation of this utility,
which also includes a link to download it.
Al Moledin
mailto:amoledin@telusplanet.net
===
DWGicon is a utility that modifies the icon for AutoCAD drawings in Explorer as well as from within
AutoCAD to reflect the version that a drawing was last saved in
http://www7.brinkster.com/haugh/fw/di/
it gives the AutoCAD version number as an icon in your Explorer and FileOpen windows. ===
Have you read : "Seven Habits of Highly Effective AutoLispers?"
Or "How to Spot a real AutoCAD user?"
http://www.geocities.com/cadgurucool/seven.htm
===
And, some LISP for AutoCAD and IntelliCAD :
http://www.cogosoftware.com/downl.html
===
Looking for the Visual Basic Run-time Files?
http://support.microsoft.com/default.aspx?scid=FH;[LN];vbruntime&
===
And last but not least, would you like to have a look at me (Kenny) as a seventeen year old
wannabe rockstar : http://www.bedrockband.com/kenny/paperlace.htm
Miscellaneous Rubbish that I almost Forgot
===================================
I must also say thanks to those of you for your support in getting BedRocks track, "Crowd
Invasion", into the Top 20 of South African music mp3's. Hey, you can still download it here if you
wish : http://www.bedrockband.com/Crowd_Invasion.mp3
Now I'm gonna ask you to do it all again as another track from BedRocks latest CD, "So Where's
The Party Tonight?", has been made available on the SA mp3 site at http://www.samp3.com So, if
you've got a few minutes to spare, please pop along. You'll find our song "What Crap is That"
under the NEW column on the right of the page - each download registers a "hit" for us so please
spread the word to friends, co-workers, priests, policemen, shrinks, strangers in the
street...whosoever!
Oh, we now have a distribution deal in the States. You can order your copy of "So Where's The
Party?" from CDBaby: http://www.cdbaby.com/bedrock
Hey $10 a shot - not bad I would say.
The Back Stoep
=============
Whenever your children are out of control, you can take comfort from the thought that even God's
omnipotence did not extend to his own children.
After creating heaven and earth, God created Adam and Eve. And the first thing he said was
'DON'T!'
'Don't what?' Adam replied.
'Don't eat the forbidden fruit.' God said.
'Forbidden fruit? We have forbidden fruit? Hey Eve ... we have forbidden fruit!.'
'No way!'
'Yes way!'
'Do NOT eat the fuit!' said God.
'Why?'
'Because I am your father and I said so!' God replied, wondering why he hadn't stopped creation
after making the elephants.
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (5 of 7) [23/03/2005 05:48:58 p.m.]
A few minutes later, God saw his children having an apple break and he was ticked!
'Didn't I tell you not to eat the fruit?' God asked.
'Uh huh' Adam replied.
'Then why did you?' asked the father.
'I don't know' said Eve.
'She started it!' Adam said.
'Did not!'
'Did too!'
'DID NOT'
Having had it with the two of them, God's punishment was that Adam and Eve should have
children of their own. Thus the pattern was set and it has never changed.
BUT THERE IS REASSURANCE IN THE STORY:
If you have persistently and lovingly tried to give children wisdom and they haven't taken it, don't
be hard on yourself. If God had trouble raising children, what makes you think it would be a piece
of cake for you?
THINGS TO THINK ABOUT:
1. You spend the first two years of their life teaching them to walk and talk. Then you spend the
next sixteen telling them to sit down and shut up.
2. Grandchildren are God's reward for not killing your own children.
3. Mothers of teens now know why some animals eat their young.
4. Children seldom mis-quote you. In fact, they usually repeat word for word what you shouldn't
have said.
5. The main purpose of holding children's parties is to remind yourself that there are children more
awful than your own.
6. We child-proofed our homes, but they are still getting in.
ADVICE FOR THE DAY:
Be nice to your kids. They will choose your nursing home.
AND FINALLY:
IF YOU HAVE A LOT OF TENSION AND YOU GET A HEADACHE, DO WHAT IT SAYS
ON THE ASPIRIN BOTTLE: 'TAKE TWO ASPIRIN' AND 'KEEP AWAY FROM
CHILDREN'
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
(The drunker you are, the better we sound!!)
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2003-02


http://www.afralisp.com/newsletter/2003/2003-02.htm (6 of 7) [23/03/2005 05:48:58 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-02
http://www.afralisp.com/newsletter/2003/2003-02.htm (7 of 7) [23/03/2005 05:48:58 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-03
=========================
15th May 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Wet Paint - Do NOT Touch!!
=========================
The Front Stoep.
==============
Firstly, I must apologise for a number of grammar errors that slipped through the proverbial net in last weeks
Newsletter. And no, it wasn't too many beers in fact, quite the reverse.
There I was in a mad rush to go out, and without thinking, I pressed the "Send" button. I then suddenly
remembered that I hadn't proof read the bleedin' thing. That's what happens when you try and do important
things whilst sober!! I should have waited until I wobbled home later that night.
Question?
How do you set up your AutoCAD workstations? Do you just use vanilla AutoCAD on a stand alone PC, or
have you got multiple workstations to deal with? I'm not talking about your drawing office standards or
layering standards, I'm talking about your AutoCAD System Setup itself. Are all your drawings, menus and
custom support files on the Network, or do you keep all support files on the users local drive and the drawings
on the Network?
Do you deal with multiple configurations for various disciplines? Do you make use of Profiles or Template
drawings? Or do you have a super dooper "AutoCAD Multiple Configuration Application" written by a team
of expert C++ programmers?
If if the answer is "Yes" to any of the above, I'd be interested in hearing from you.

Pearls of Wisdom
===============
Black holes suck.
===============

Coding
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (1 of 7) [23/03/2005 05:49:00 p.m.]
=======
Would you like to set up custom support paths?
;CODING STARTS HERE
;set the path to your custom subdirectory.
(setq netpath "C:\\Custom")
;uncomment the next line if you want to clear all paths
;and set the support paths back to the AutoCAD default.
;(setenv "ACAD" "")
;store the existing support paths
(setq defpath (getenv "ACAD"))
;append your custom paths.
(setenv "ACAD" (strcat
defpath ";"
netpath ";"
netpath "\\" "Menu;"
netpath "\\" "Lisp;"
netpath "\\" "VBA;"
netpath "\\" "Blocks;"
))
;CODING ENDS HERE
===================
Hi Kenny
Whazzup, Whasappening??
I was starting to get withdrawal symptoms! I missed your Afralisp newsletter. Oh well I survived. Here is a
collection of some of my lisp routines that I use very frequently on a daily basis and are also often used by
others in the office. They are very rough and ready, but they do the job quite nicely. I have quite a few ideas to
beef them up, but I'm sure there are many other coders out there that will also enjoy toying around with them
and tidying them up.
Cheers,
Dave
========
You can download DCTools here :
http://www.afralisp.com/lisp/dctools.htm
========
Want to convert a list to a string?
;CODING STARTS HERE
;Function to turn a list into a string
(defun ltos (lst / gfile)
;open a file on disk
(setq gfile (open "temp.txt" "w"))
;print list to file
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (2 of 7) [23/03/2005 05:49:00 p.m.]
(prin1 lst gfile)
;close file
(close gfile)
;open file
(setq gfile (open "temp.txt" "r"))
;read list from file
(setq strname (read-line gfile))
;close file
(close gfile)
;return converted list
strname
);defun
;CODING ENDS HERE
===========
Kenny,
Hi there, my name is Michael. Cool site, love the humour. I am just getting back into some CAD programming
- stopped about 6 years ago before VLISP. I am bouncing between VLISP and VBA. My forehead is getting
sore from banging the computer monitor. I am stumped!
I am trying to find a point on a surface - not necessarily at a convienient vertex of course - have x,y get z from
surface kind of thing.
Simple, right? It started out promising and has been spiralling downhill.
My biggest block is accessing the surface data.
For example, none of the surfaces I get seem to be standard, but either "AcDbBody" (exploded solid) or
"AcAsSurfBody" (IGES import surface).
If I could access the vertices, I could dust of my old algebra texts and calculate the Coons patches between
points - very ugly prospect.
I should think that there would be an easier way.
The IntersectWith method looks good, but it either is not implemented yet, or its ARX is not loaded. AutoCAD
has to use the surface info to process HIDE and RENDER and so on, so it has to be in the realm of the
possible. But I can't find it.
Any help that you can give would be greatly appreciated.
Michael Richmond
P.S. Oh ya, is there anyway to access the mouse coords in real time without "clicking" - possibly accessing the
"status bar" COORDS
==============
Control Template :
Ever get tired of making an exit button over and over? Do you use the same set up for multi page (or any
control) over and over? Save time, save effort. Make a control template!
1) Start with a New VBA Project in AutoCAD (or any VBA enabled application)
2) Add a UserForm to the project
3) Draw a command button on the form
4) If the properties window is not visible, click properties on the View Menu
5) Make sure that the properties for the command button are being listed in the properties window, then
change the following items:
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (3 of 7) [23/03/2005 05:49:00 p.m.]
6) Caption = Exit
7) Font = Arial (example, use your favorite font)
8) From the file menu choose close and return to AutoCAD (or whatever application you are setting up).
9) Close AutoCad, when prompted to save the changes to Global1 say "yes" (save it under any name, you will
open it right back up).
10) Restart AutoCAD and load the dvb file saved in step 7.
11) Drag the command button you customized in step 5 onto the controls tab of the Toolbox.
===========
Another type of snap:
;CODING STARTS HERE
(defun c:between ( / x y)
(setq x (getpoint "\nEnter first point : ")
y (getpoint x "\nEnter second point : "))
(command "_non")
(setq x (polar x (angle x y) (/ (distance x y) 2)))
(command "line" x pause)
);defun
(princ)
;CODING ENDS HERE
==================
Kenny,
Your Unload all function on your site won't run in MAP5, this will in case you ever need it.
;CODING STARTS HERE
(defun C:CORNLOAD( / acadapp vbe vbp actVbp vbpFileName)
(vl-load-com)
(setq acadapp(vlax-get-acad-object))
(setq vbe(vla-get-vbe acadapp))
(setq vbp(vlax-get vbe "VBProjects"))
(While (setq actVbp(vlax-get vbe "ActiveVBProject"))
(setq vbpFileName(vlax-get actVbp "FileName"))
(vla-UnloadDVB acadapp vbpFileName)
)
)
;CODING ENDS HERE
Andy Canfield
============

Things Weird and Wondeful


========================
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (4 of 7) [23/03/2005 05:49:00 p.m.]
I thought you might be interested in the price of AutoCAD in Southern Africa.
(Prices can vary due to exchange rates.)
AUTOCAD LT 2004
Full Commercial R 11,065 (US$1510)
Upgrade from 2000/i/2002 R 2,400 (US$328)
AUTOCAD 2004 (Stand Alone)
Full Commercial R 33,600 (US$4584)
Upgrade from 2002 R 4,080 (US$557)
Upgrade from 2000/2000i R 8,160 (US$1113)
Prices also exclude VAT of approx 15%
================
Want to see what hardware and software is installed on your PC?
http://www.belarc.com/
Just select the "Free Download" link and download the software. (about 660kb)
Displays a web page listing of all the hardware and software on your PC.
====================
Miscellaneous Rubbish that I almost Forgot
===================================
As a general rule: always reset any system variables that were changed
during a routine, unless it is the specific purpose of the routine to change
them. A system variable should NOT be "reset" to any specific value, but it
should be reset to the value it had before changes were made.
This means grabbing the current value with GETVAR, saving it and setting it
later with SETVAR.
Where a system variable should be reset depends on the code and the system
variable. For example, OSMODE could be changed just before picking a point
and reset immediately after if required by the following actions.
In the case of CMDECHO, there's no need to change it unless you write code
that can echo back to the screen. If you do have echos and you don't want to
clutter the screen with it, you can save/change it in the beginning and
reset it (to its former value!) in the end.
Even if you are only writing code for yourself, it is well advised to follow
this rule or maybe someday you will be cursing at your own routines.
Stig Madsen
==============

The Back Stoep


=============
A Dog's Prayer.
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (5 of 7) [23/03/2005 05:49:00 p.m.]
Why do humans smell the flowers, but seldom, if ever, smell one another? Where are their priorities?
When we get to heaven can we sit on your couch? Or is it the same old story?
Why are there cars named after the jaguar, the cougar, the mustang, the colt, the stingray and the rabbit, but
not ONE named for a dog? How Often do you see a cougar riding around?
We dogs love a nice ride! Would it be so hard to rename the Chrysler Eagle the Chrysler Beagle?
If a dog barks his head off in the forest and no human hears him, is he still a bad dog?
If we come back as humans is that good or bad?
More meatballs, less spaghetti, please.
When we get to the Pearly Gates, do we have to shake hands to get in?
Are there dogs on other planets or are we alone? I have been howling at the moon and stars for a long time,
but all I ever hear back is the Schnauzer across the street.
Are there mailmen in Heaven? If there are, will I have to apologize?
We dogs can understand human verbal instructions, hand signals, whistles, horns, clickers, beepers, scent
ID's, electromagnetic energy fields, and Frisbee flight paths. What do humans understand?
May I please have my testicles back?
These are just some of the things I must remember (in order to keep my present living arrangements)
The garbage collector is not stealing our stuff.
I do not need to suddenly stand straight up when I'm lying under the coffee table.
I will not roll my toys behind the fridge, behind the sofa or under the bed.
I must shake the rainwater out of my fur before entering the house.
I will not eat the cats' food before they eat it or after they throw it up.
I will stop trying to find the few remaining pieces of clean carpet in the house when I am about to get sick.
I will not throw up in the car.
I will not roll on dead seagulls, fish, crabs, possums, etc. just because I like the way they smell.
I will not munch on "leftovers" in the kitty litter box; although they are tasty, they are not food.
I will not eat any more Kleenex or napkins and then redeposit them in the backyard after processing.
The diaper pail is not a cookie jar.
I will not chew my humans' toothbrushes and not tell them.
I will not chew crayons or pens, especially not the red ones, or my people will think I am hemorrhaging.
When in the car, I will not insist on having the window rolled down when it's raining outside.
We do not have a doorbell. I will not bark each time I hear one on television.
I will not steal my mom's underwear and dance all over the back yard with them.
The sofa is not a face towel; neither are Mom and Dad's laps.
My head does not belong in the refrigerator.
I will not bite the officer's hand when he reaches in for Mom's driver's license and registration.
I will not play tug of war with dad's underwear when he's on the toilet.
I will not roll around in the dirt right after getting a bath.
Sticking my nose into someone's crotch is not an acceptable way of saying hello.
I will not come in from outside and immediately drag my butt across the carpet.
The toilet bowl is not a never ending water supply and, just because t the water is blue, that doesn't mean it's
cleaner.
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (6 of 7) [23/03/2005 05:49:00 p.m.]
I will not sit in the middle of the living room and lick my crotch when company is over.
I will remember that suddenly turning around and smelling my rear end can quickly clear a room.
The cat is not a squeaky toy so when I play with him and he makes that noise, it's usually not a good thing.
Love,
The Dog
=========
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
(If we're too loud, you're too old!)
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-03
http://www.afralisp.com/newsletter/2003/2003-03.htm (7 of 7) [23/03/2005 05:49:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
Stats VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD

=========================
AfraLisp Newsletter No 2003-04
=========================
28th May 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
This is an air conditioned environment.
Do not open Windows.
=========================
The Front Stoep.
==============
A bit late this week I'm afraid. In fact about a week late!!
Sorry about that that, but in this part of the world it's been two long weekends in a row and I've been off to
Luderitz on a mini-tour with the band.
Other than that, I must warn you that I'm messing around with PHP at the moment. So, if you see AfraLisp
looking a bit weird every now and again, don't worry, be happy. Normal service will be resumed as soon as
possible. Hey, you're lucky, unlike AutoDesk I don't charge you for upgrades.
Pearls of Wisdom
===============
A belly button is for salt when you eat celery in bed.
===============
Here's a couple of answers I received in regards to the AutoCAD Configuration question I asked in the last
issue :
My configurations are pretty standard, and I feel 'common sensical', but I decided to reply in case you're short
on obvious replies....
I work as a CAD manager in a small Structural Engineering office in Australia. We have been using AutoCAD
since v1.7b in 1983. At work we only have 3 Acad seats which are configure (almost) identically. One seat is
LT+DRC-Toolkit, which can emulate our full seats. They are on a network, but each seat is self sufficient,
however, we do use shortcuts to shared block libraries and have one global library/backup area on the
network. We still like to only turn one machine on if there is only one person in the office ;-)
At home I moonlight for some Architectural designers and NEED four different CAD configurations.
- One vanilla for development and testing.
- One Structural Engineering (for overtime work)
- Two separate Architectural environments.
I simply have four icons on my desktop which launch each environment using profiles. I have a simple LISP
routine to control it and confirm that I am dropping in to the correct environment. Each has it's own Folder
with LISP routines, custom menus, fonts, linetypes, patterns and all relevant blocks that are used in that
environment.
AutoCAD itself gets installed as pure vanilla. The only customisation is to add my 'acaddoc.lsp' within its
support path. Each environment has it's Search File Paths and other options defined and saved as a named
profile in IT'S Folder.
Works for me ;-)
Rob Jackson
============
Ed Note : Rob did supply an example of his "bootstrap" routine, but unfortunately space is limited and I had
to exclude it. I will be talking to Rob in regards to publishing this section at a later date as it is quite
interesting.
============
Just a real quick one on the config front. The company I work for uses a program called Autosys to control
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (1 of 6) [23/03/2005 05:49:03 p.m.]
client driven layers and linetypes.
Within this program is a package called apploader, which gives you the ability to load and unload addon
packages for autocad within one session, without having to swap profiles all the time. Ther is also batch p[lot
utilities and a host of Autocad tools (a lot are obsolete as
they were written back in r10 days). If your keen for further info, let me know.
Regards
Dennis
=======
Coding
=======
Is it possible to record a list of the commands that I use during a session of AutoCAD in to a text file? I would
like it to be similar to the list of commands that you find under "Recent Commands" on the text line.
Peter
=====
Peter, you could not just switch on "Maintain a Log File" or try this out :
"Allclear Macro Recorder"
http://www.dczaland.com/
======================
Are you aware that the Visual LISP IDE can help you in finding erroneous code?
Check the item "Break On Error" in the DEBUG menu.
Load and run the LISP code with an error.
As expected, your program fails.
Now pick the item "Last Break Source" in the DEBUG menu.
The cursor takes you to the point of failure in the LISP code.
(Note: This may not work for complex errors - especially in any of my programs!!)
========
In response to Stig Madesens words of wisdom in regards to resetting system variables in last weeks
Newsletter, if you want to set many system variables programmatically, instead of using individual expressions
use these efficient and easily maintainable AutoLisp expressions to set and reset AutoCAD system variables.
;; store default values
(setq defvars (mapcar 'getvar '(cmdecho highlight osmode)))
;; set values to your need
(mapcar 'setvar '(cmdecho highlight osmode) '(0 0 0)))
;; reset them back once you are done
(mapcar 'setvar '(cmdecho highlight osmode) defvars)))
Big Ed
=========
I wrote something similar a while back if anyone is interested.
You can find it on this page :
"Saving and Restoring System Variables".
http://www.afralisp.com/tips.htm
And here's something in the same vein :
"Efficient Variables"
http://www.afralisp.com/lispa/lisp55.htm
===========================
Hey Kenny,
I want to point to a directory on the network F:\\ctb, w/o having to make this change in tools/options and to
force the change if someone changes it to some place else. Is this possible?
Zain
=======
I "borrowed" this from somewhere.
;CODING STARTS HERE
;;; Save and loads support paths to a text file
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (2 of 6) [23/03/2005 05:49:03 p.m.]
(defun C:saveSupportPaths (/ files paths f)
(vl-load-com)
(setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(setq paths (vla-get-supportpath files))
(setq f (open "thepaths.txt" "w"))
(write-line paths f)
(close f)
(princ)
)
(defun C:loadSupportPaths (/ files paths f)
(vl-load-com)
(setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(setq f (open "thepaths.txt" "r"))
(setq paths (read-line f))
(close f)
(vla-put-supportpath files paths)
(princ)
)
(princ)
;CODING ENDS HERE
==========
Hi Kenny,
Is it possible through AutoLISP or other to change an attribute of a batch of drawings without manually doing
each one. Such as the revision in the title block.
Cheers,
Ryan
==========
And here's a couple of answers to a couple of questions compliments of Stig Madsen :
From last weeks Newsletter:
Is there anyway to access the mouse coords in real time without "clicking" - possibly accessing the "status
bar" COORDS?
Accessing mouse coordinates in real time can be done with GRREAD. You can do
all sorts of cool device tracking with GRREAD; find out if the mouse has
been moved, where it's been moved, if the mouse has been pressed, what key
has been pressed or if a pulldown menu has been accessed.
Here are two small commands to rattle on mouse locations. The first reports
the current location of the cursor and the second reports running movements
of the cursor until a key or the mouse is pressed:
;CODING STARTS HERE
(defun C:LOC (/ pt)
(setq pt (cadr (grread T 1)))
(mapcar 'princ (list "\n" (car pt) "," (cadr pt) "," (caddr pt)))
(princ)
)
(defun C:RUNC (/ pt)
(while (= 5 (car (setq pt (grread T 1))))
(mapcar 'princ (list "X: " (caadr pt) " Y: " (cadadr pt) "\n"))
)
(princ)
)
;CODING ENDS HERE
And from Issue No 2:
We have a network and I want to attatch an XREF drawing from the server, when doing so I want all the
layers to be turned to the color red in order to differentiate between my work and the attached layers from
other departments.
To ensure that changes made to XREF's layers in the current drawing don't
get reset or, actually, reloaded next time the drawing is opened, set the
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (3 of 6) [23/03/2005 05:49:03 p.m.]
system variable VISRETAIN to 1. The setting is saved with the drawing
containing the XREF's and also has the effect that paths are saved with the
drawing.
If entities in the reference drawings are created with a color property
other than Bylayer, it is not directly possible to assign new colors to them
in the host drawing, but if they are of color Bylayer it is possible to make
a shortcut that both sets VISRETAIN to 1 and changes all XREF-based layers
to a color.
;CODING STARTS HERE
(defun C:xrefcolor (/ cnt color lyr layer llst off)
(setq cnt 0)
;; get a color from the pretty color dialog
(cond ((setq color (acad_colordlg 1 nil))
(while (setq lyr (tblnext "LAYER" (not lyr)))
;; run through all layers and pick up those that
;; come from reference drawings
(cond ((= (logand (cdr (assoc 70 lyr)) 16) 16)
(setq layer (tblobjname "LAYER" (cdr (assoc 2 lyr)))
llst (entget layer)
;; save the layers on/off state so we don't turn
;; it on by accident
off (if (< (cdr (assoc 62 lyr)) 0) -1 1)
)
;; change the layers color to the pick of the day
(if (entmod (subst (cons 62 (* color off)) (assoc 62 llst)
llst))
(setq cnt (1+ cnt)))
)
)
)
)
)
;; be nice and only set VISRETAIN if any xref layers were changed
(if (> cnt 0)(setvar "VISRETAIN" 1))
(princ)
)
;CODING ENDS HERE
==============
Things Weird and Wondeful
========================
Try this link:
http://www.bigswamp.org/Se7en/
AND, you've all seen Urban Legends such as these :
"Entering a phone number into the Google search engine will return a home address and a map with
directions to that address."
Or :
"Microsoft is marketing the iLoo, an Internet-capable portable toilet."
Interested in Urban Legends are we?
Then pop along here and have a good root around :
http://www.snopes.com/
====================
Miscellaneous Rubbish that I almost Forgot
===================================
Would you like to convert your AutoLisp/VBA Coding into HTML?
Would you like to colour code it and add line numbers?
Try this :
http://www.vbdesign.net/language.htm
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (4 of 6) [23/03/2005 05:49:03 p.m.]
AND, would you like to know more about Lisp?
(Lisp NOT AutoLisp)
http://grimpeur.tamu.edu/~colin/lp/
==============
The Back Stoep
=============
The following are actual letters that Abigail Van Buren (Dear Abby) herself admitted she was at a loss to
answer:
Dear Abby,
A couple of women moved in across the hall from me. One is a middle-aged gym teacher, and the other is a
social worker in her mid-twenties. These twowomen go everywhere together, and I've never seen a man go into
their apartment or come out. Do you think they could be Lebanese?
Dear Abby,
What can I do about all the sex, nudity,language and violence on my VCR?
Dear Abby,
I have a man I never could trust. He cheats so much I'm not even sure this baby I'm carrying is his.
Dear Abby,
I am a twenty-three-year-old liberated woman who has been on the pill for two years. It's getting expensive,
and I think my boyfriend should share half the cost, but I don't know him well enough to discuss money with
him.
Dear Abby,
I suspected that my husband had been fooling around, and when I confronted him with the evidence he denied
everything and said it would never happen again.
Dear Abby,
Our son writes that he is taking Judo. Why would a boy who was raised in a good Christian home turn against
his own?
Dear Abby,
I joined the Navy to see the world. I've seen it. Now, how do I get out?
Dear Abby,
My forty-year-old son has been paying a psychiatrist $50 an hour every week for two-and-a-half years. He
must be crazy.
Dear Abby,
I was married to Bill for three months, and I didn't know he drank until one night he came home sober.
Dear Abby,
Do you think it would be all right if I gave my doctor a little gift? I tried for years to get pregnant and
couldn't, and he did it.
Dear Abby,
My mother is mean and short-tempered. I think she is going through her mental pause.
Dear Abby,
You told some woman whose husband had lost all interest in sex to send him to a doctor. Well, my husband
lost all interest in sex years ago and he is a doctor.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (5 of 6) [23/03/2005 05:49:03 p.m.]
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-04
http://www.afralisp.com/newsletter/2003/2003-04.HTM (6 of 6) [23/03/2005 05:49:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-05
=========================
4th June 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Important :
Press all the keys on your keyboard at the same time to continue...
=========================
The Front Stoep.
==============
If you've popped into AfraLisp lately, you might be forgiven for thinking that not much is going on.
The reason being is that I'm busy with one of my major site updates and cleanups.
I should be finished by this weekend so, please be patient and don't yell at me as I can promise
you lot's of new content and maybe one or two surprises.
In fact, here's the first one..........
==============
++++SPECIAL++++
For one week only!!!
"The AfraLisp Visual Lisp Tutorials"
A collection of all the Visual Lisp Tutorials found on AfraLisp in PDF format.
http://www.afralisp.com/books/VL.zip (Download size: 1566 Kb)
===============
Pearls of Wisdom
===============
"Mr. Worf, scan that ship." "Aye Captain. 300 dpi?"
===============
Coding
=======
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (1 of 9) [23/03/2005 05:49:06 p.m.]
Hi Kenny,
I'm a beginner at AutoLISP and right now I'm stuck, so I thought I'd seek help from a guru.
If (setq s3 (cdr (assoc 2 s2))) returns the value "circ" and (ssget '((2 . "circ"))) creates a selection
set comprising all the blocks named "circ" within my selection, why doesn't (ssget '((2 . s3))) do
the same thing?
If !s3 returns "circ", doesn't that make (ssget '((2 . "circ"))) the same thing as (ssget '((2 . s3)))?
I have been typing ALL at the 'select objects' prompt to make sure I am always selecting the same
objects.
When I use (ssget '((2 . s3))) I get the following error message - ; error: bad SSGET list value.
I don't get it.
Lara Aigoro
==========
If both the DXF code and the desired value are know, the list may be quoted as you tried. BUT, if
either is specified by a variable, the list must be constructed using the "list" and the "cons"
functions.
This code snippet should help you:
(setq layername "STEEL")
(setq ss1 (ssget "X" (list (cons 8 layername))))
This creates a selection set of all objects on the layer "STEEL" which is referenced in the variable
"layername".
===========
With this Math.lsp you can change any text or Mtext entites in preseted sequence , using basic
math operators via dialog box. For example H=1m H=2m H=3m ....
Zeev
=====
//DCL CODING STARTS HERE
//TextMath.dcl_13.3.3
//
tm : dialog {
label = "Math for text";
:column {
:row {
:edit_box {
label = "To start with : ";
edit_width =4;
key="tpre";
}
:edit_box {
edit_width =4;
key="num";
}
:edit_box {
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (2 of 9) [23/03/2005 05:49:06 p.m.]
edit_width =4;
key="tend";
}
}
:row {
:edit_box {
label = "Function [+ - * / ] : ";
edit_width =1;
key="func";
}
:edit_box {
edit_width =4;
key="inc";
}
}
}
ok_only;
}
//DCL CODING ENDS HERE
Save this as TextMath.dcl
;AUTOLISP CODING STARTS HERE
(defun c:math ()
(setq dimzin-old (getvar "dimzin"))
(setvar "dimzin" 8)
(if (not pre)(setq pre "prefix" num "1"
ending "ending" func "+" inc "1"))
(if (< (setq dialog_in (load_dialog "TextMath")) 0)(exit))
(new_dialog "tm" dialog_in)
(set_tile "tpre" pre)
(set_tile "num" num )
(set_tile "tend" ending)
(set_tile "func" func)
(set_tile "inc" inc )
(action_tile "accept"
(strcat "(setq pre (get_tile \"tpre\")
ending (get_tile \"tend\")
num (get_tile \"num\")
func (get_tile \"func\")
inc (get_tile \"inc\")
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (3 of 9) [23/03/2005 05:49:06 p.m.]
)"
"(done_dialog)"))
(start_dialog)
(princ "\nSelect text [In order]->")
(setq fact 1 lim 8)
(setq tset
(ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>")))
counter 0 )
(while (< counter (sslength tset))
(setq tel (ssname tset counter))
(setq counter (+ 1 counter))
(setq tent (entget tel))
(setq tent
(subst (cons 1 (strcat pre num ending))
(assoc 1 tent) tent))
(entmod tent)
(setq num (eval (read (strcat
"(" func " " num " " inc")"))))
(if (= (type num) 'INT) (setq num (itoa num))
(setq num (rtos num)))
);end while ssget
(setvar "dimzin" dimzin-old)
(command "regen")
(princ)
);end defun
(princ "\nType : MATH")
;AUTOLISP CODING ENDS HERE
=============
Save this as Math.lsp
=============
Have you got Express Tool installed?
If so try this at the AutoCAD command prompt :
(acet-setvar (list "Afralisp" "TestData" 1))
Now save the drawing and then close AutoCAD and re-open the drawing.
Now type this at the command prompt:
(acet-getvar (list "Afralisp" 1))
The string "TestData" should be returned.
The (acet-setvar) and (acet-getvar) pair of functions are a great resource for storing and retrieving
data in various places. These functions work particularly well for storing custom command
settings and information across editing sessions. You can store values with the current drawing,
the current profile, or in a general section of the registry.
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (4 of 9) [23/03/2005 05:49:06 p.m.]
The syntax for the acet-setvar is as follows:
(acet-setvar (list <varname> <value> [location]))
Where:
<varname> is a string representation of the variable name.
<value> is a real, int, string, list, or entity name.
[location] is an optional integer bit coded value. Location is the sum of one or more of the
following values:
1 = Store the value in the DWG
2 = Store the value with the current AutoCAD profile
4 = Store in the fixed profile section of the registry
NOTES:
i) If the location value is not provided then 2 is used as a default, resulting in the value being
stored with the current profile.
ii) List data and entity name data can only be stored in the dwg. Do not attempt to store list data or
an entity name using the current profile or fixed profile location flags.
iii) Some lists with nested dotted pairs cannot be stored using acet-setvar.

The syntax for acet-getvar is as follows:

(acet-getvar (list <varname> [location]))


Where <varname> is the string name of the variable and [location] is the sum of one or more of the
bit coded values described above. If the optional location argument is omitted, the drawing will be
searched first, and then the current profile and then finally the fixed profile. The first location that
has the specified variable stored there will be used for the return value.
============
Trying to process objects on Locked layers is a common mistake.
You should either unlock them or stop users from selecting objects on locked layers in the first
place. Try this :
(ssget ":L")
":L" stops users from selecting objects on locked layers.
=============
By setting OSMODE to 0 you simply turn off each individual object snap (end point, middle, center
and so on). When you use F3, the bit code 16384 is added to turn the object snap FUNCTION off,
not the individual object snap's. By adding and removing this value you can turn on and off
running object snap without loosing your settings.
(setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384))
Turns running object snap off
(setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384))
Turns running object snap on
==============
Want a good demonstration of an active image tile?
Try this :
//DCL CODING STARTS HERE
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (5 of 9) [23/03/2005 05:49:06 p.m.]
cur : dialog {
label = "Cursor" ;
: image_button {
width = 40 ;
height = 12 ;
color = -15 ;
key = "cur_img" ;
}
spacer_1;
: text {
label="Click at different places in the image";
width=10;
alignment=centered;
}
spacer_1;
ok_only ;
}
//DCL CODING ENDS HERE
==========
Save this as cur.dcl
==========
;;;AUTOLISP CODING STARTS HERE
(defun c:cur()
(setq cur_id (load_dialog "cur"))
(if (not (new_dialog "cur" cur_id)) (exit))
(action_tile "cur_img" "(cur_it $x $y)")
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog cur_id)
(princ)
);defun
;==========================
(defun cur_it (xval yval)
(setq xv xval yv yval)
(start_image "cur_img")
(setq xx (dimx_tile "cur_img"))
(setq yy (dimy_tile "cur_img"))
(fill_image 0 0 xv yv 5)
(fill_image xv 0 xx yv 1)
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (6 of 9) [23/03/2005 05:49:06 p.m.]
(fill_image xv yv xx yy 3)
(fill_image 0 yv xv yy 2)
(vector_image 0 yv xx yv 8)
(vector_image xv 0 xv yy 8)
(end_image)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
============
Save this as Cur.lsp
============
Kenny,
I am using LT2002 with LT-Extender (lisp enabler) but previously used full version 2000 and 2002
where I became almost reliant on the Extension osnap. LT 2002 does not have the extension osnap
as standard therefore my question is whether it would be possible to invoke this osnap (osmode
4096) in LT2002 using a lisp or arx routine in conjunction with the LT-Extender lisp generator?
Simon A. Baines
==============

Things Weird and Wondeful


========================
Hi Kenny,
Thanks for the newsletter and love the link to snopes.
The following has got to be my latest favorite!
http://www.snopes.com/humor/iftrue/chess.htm
While it didn't really happen playing chess, I am sure it will happen soon somewhere when
programming in .NET!
Thanks
Bill H
=====
Have fun with "MTJIGSTRING" and set it in a startup lisp to the name of the user or anything else.
Put (setvar "mtjigstring" (strcase (getvar "loginname"))) in your acaddoc.lsp.
It will show the first 10 characters in the MText edit box.

Miscellaneous Rubbish that I almost Forgot


===================================
To help you build global-friendly AutoLisp routines, have a look at the (undocumented) system
variable GLOBCHECK which is set off (= 0) by default. If you enable it (= 1), it will reject any
command or keyword input from scripts, menus or application sources that fails to use the
underscore prefix.
Set GLOBCHECK=1 while developing and debugging your program to make sure you catch all of
the pertinent strings.
If you set GLOBCHECK=3, it will display the size of a dialog box at the command line when
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (7 of 9) [23/03/2005 05:49:06 p.m.]
displayed.
=========
A Chinese AutoLisp site!!!
http://www.adi-xz.com.cn/study/user/dev/user04.htm

The Back Stoep


=============
I met a Dutch girl with inflatable shoes last week, phoned her up to arrange a date but
unfortunately she'd popped her clogs.
Two Eskimos sitting in a kayak were chilly; but when they lit a fire in the craft, it sank, proving
once and for all that you can't have your kayak and heat it.
But I'll tell you what I love doing more than anything: trying to pack myself in a small suitcase. I
can hardly contain myself.
But I'm in great mood tonight because the other day I entered a competition and I won a years
supply of Marmite.........one jar.
Now did you know all male tennis players are witches, for example Goran, even he's a witch.
So a lorry-load of tortoises crashed into a train-load of terrapins, I thought "That's a turtle
disaster".
A priest, a rabbi and a vicar walk into a bar. The barman says, "Is this some kind of joke?"
Dyslexic man walks into a bra.
A seal walks into a club...
A three-legged dog walks into a saloon in the Old West. He slides up to the bar and announces:
"I'm looking for the man who shot my paw."
A group of chess enthusiasts checked into a hotel and were standing in the lobby discussing their
recent tournament victories. After about an hour, the manager came out of the office and asked
them to disperse. "But why?" they asked, as they moved off. "Because," he said "I can't stand
chess nuts boasting in an open foyer."
There was a man who entered a local paper's pun contest. He sent in ten different puns, in the
hope that at least one of the puns would win. Unfortunately, no pun in ten did.
A woman has twins, and gives them up for adoption. One of them goes to a family in Egypt and is
named "Amal." The other goes to a family in Spain, they name him Juan". Years later, Juan sends
a picture of himself to his mum. Upon receiving the picture, she tells her husband that she wished
she also had a picture of Amal. Her husband responds, "But they are twins. If you've seen Juan,
you've seen Amal."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (8 of 9) [23/03/2005 05:49:06 p.m.]
Also known, unkindly I may say, as "BedLam".
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-05
http://www.afralisp.com/newsletter/2003/2003-05.htm (9 of 9) [23/03/2005 05:49:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-06
=========================
11th June 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
All wiyht. Rho sritched mg kegtops awound?
=========================
The Front Stoep.
==============
Hey, guess what!!
AfraLisp now has it's very own "Knowledge Base".
http://www.afralisp.com/disc6_toc.htm
Please note though, that this forum is not intended to be a
question and answer forum, but rather a place for you to share
interesting nuggets and snippets of AutoCAD coding with everybody
who reads the Newsletter and visits AfraLisp.
So pop along, and do your thing............
==============
++++SPECIAL++++
For one week only!!!
"The AfraLisp DCL Tutorials"
A collection of all the DCL Tutorials found on AfraLisp in PDF format.
http://www.afralisp.com/books/DCL.zip (Download size: 1566 Kb)
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (1 of 8) [23/03/2005 05:49:07 p.m.]
Pearls of Wisdom
===============
A chicken is an egg's way of producing more eggs.
===============
Coding
=======
And to follow on from last week in regards to Express Tools acetutils :
The acetutil modules provide a number of utility functions which can be
called from LISP.
For a listing, pop along to here :
http://www.afralisp.com/lisp/acet-utils.htm
If anyone has any more information in regards
to these functions, please feel free to drop me a line.
==========
Express Bonus Tools 2002 - FREE
Download and install the bonus tools from
http://www.contractcaddgroup.com/download/ExpressBonusTools.zip
The bonus tools are a collection of productivity tools (from Autodesk)
that can radically change the way you work with layers, text, dimensions,
layouts, and file properties information.
================
Want to erase all Points in your drawing?
;AUTOLISP CODING STARTS HERE
(defun c:epts ( / ss ename etype elist sslen counter)
(setq ss (ssget "x")
sslen (sslength ss)
counter 0
)
(repeat sslen
(setq ename (ssname ss counter)
elist (entget ename)
etype (cdr (assoc 0 elist))
counter (1+ counter)
)
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (2 of 8) [23/03/2005 05:49:07 p.m.]
(if (= etype "POINT") (entdel ename))
)
(princ)
)
(princ)
;AUTOLISP CODING ENDS HERE
===========
I just read your tip on setting defaults. I'd like to submit what
I feel is a simpler version. It's what I've been doing for years.
;CODING STARTS HERE
(defun c:prog1 (/ a)
(if (= gv nil)
(setq gv 1.0)
);end if
(setq a (getdist (strcat "\nEnter Distance <" (rtos gv) ">: ")))
(if (= a nil)
(setq a gv)
);end if
(setq gv a)
(princ "\nThe Distance is ")
(princ a)
(princ)
);defun
;CODING ENDS HERE
Don Ireland
==========
Hello again Kenny.
I was just reading your issue 2003-1 that you recently sent and the routine
for using 'cal;mee written by John Lauer. I have been using 'cal;mee after
ver2000 when the following routine no longer worked. (coding was published
in Cadalyst when it was an Autocad magazine) Can it be made to work in ver2004?
I had it installed on my snap menu and it was very convenient.
;CODING STARTS HERE
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (3 of 8) [23/03/2005 05:49:07 p.m.]
; TIP1137.LSP: BTWN.LSP Point Between (c)1995, Larry Twilley
(defun btwn (/ PT1 PT2)
(setq PT1
(getpoint "\nEnter first point:")
)
(setq PT2
(getpoint "\nEnter second point:")
)
(polar PT1
(angle PT1 PT2)
(/ (distance PT1 PT2) 2)
)
); end btwn.lsp
;CODING ENDS HERE
Regards,
Bill Storey
=========
It works for me. Try this at the command line :
Command: line
Specify first point: (btwn)
Then just choose your two points and the line will start from the
mid point between the two.
================
Things Weird and Wonderful
========================
Here is a little more. Boy you can eat.....
So, we have this lisp sub-program that we want our user to use (run)
when moving from one titlemode to another. This program pull from the
variables set by "DDS" (You know the user variables like "userr1,2 and so on").
I have made a quick key "TT" to toggle between titlmodes. I
made this so that the user never have to worry about (ltscale or dimscale
and tell them which scale in set in model space)
But, like you know, some user just will not change their ways.
They like those little tab at the bottom. OK.... here is what I did.
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (4 of 8) [23/03/2005 05:49:07 p.m.]
;*****Code begin here*****
(vl-load-com) ; Load ActiveX reactor module
(defun DoThisAfterLayoutSwitch (Caller CmdSet)
(prompt (strcat "\nDMJM Design Tool TT: " (getvar "ctab")))
(vl-cmdf "tt")
(if (= (getvar "ctab") "Model")
(vl-cmdf "tt")
)
(princ)
)
(setq MyReactor1
(vlr-miscellaneous-reactor
nil
'((:vlr-layoutSwitched . DoThisAfterLayoutSwitch)
)
)
)
(defun Clear_My_Reactors ()
(if (and MyReactor1 (vlr-added-p MyReactor1))
(vlr-remove MyReactor1)
)
)
(defun Clear_All_Reactors ( / TMP)
(vlr-remove-all :vlr-dwg-reactor)
)
;*****code ends here*****
I place this on the acaddoc.lsp and I got them.... ha ha All of them....
There are my.... ha ha ha ha
So now they can type in TT on the command line or use those tab.....
Just some more fuel your buddy
Jesse
That DJ Guy
===========
CAD Encoding - The Journal is focused on helping you to improve your work
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (5 of 8) [23/03/2005 05:49:07 p.m.]
environment with tutorials and working code examples written in, and for,
the most popular customizing languages for the major CAD software programs
and Microsoft Office products - Visual Basic for Applications, Visual Basic,
Visual C++, AutoLisp, Visual Lisp, and DCL :
http://www.cadencoding.com
Miscellaneous Rubbish that I almost Forgot
===================================
*_toolpalettepath is an undocumented system variable to set the tool palette path.
Use semicolon as a delimiter between multiple paths.
=============
Coming Soon!! Mouse Support for Edlin!!
=========
Are you based in Africa?
Would you like to join the African AutoCAD Users Group?
Then pop along here:
http://www.augafrica.com
The Back Stoep
=============
And the following was sent with compliments from Mike Perry:
Two Aerials met on a roof, fell in love, & got married.
The ceremony was rubbish but the reception was brilliant.

Two cannibals were eating a clown. One says to the other:
'Does this taste funny to you?'

Man goes to the doc, with a strawberry growing out of his head.
Doc says 'I'll give you some cream to put on it'

"Doc, I can't stop singing "the green green grass of home."
"That sounds like Tom Jones syndrome."
"Is it common?"
"It's not unusual."

Two cows standing next to each other in a field, Daisy said to Dolly
"I was artificially inseminated this morning."
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (6 of 8) [23/03/2005 05:49:07 p.m.]
"I don't believe you," said Dolly
"It's true, straight up, no bull!"

A guy walks into the psychiatrist wearing only cling film for shorts.
The shrink says, "Well, I can clearly see you're nuts."

A man takes his Rottweiler to the vet.
"My dog's cross-eyed, is there anything you can do for him?"
"Well," says the vet, "let's have a look at him."
So he picks the dog up and examines his eyes, then checks his teeth.
Finally, he says "I'm going to have to put him down."
"What? Because he's cross-eyed?"
"No, because he's bloody heavy."

A neutron walks into a bar.
"I'd like a beer" he says. The bartender promptly serves up a beer.
"How much will that be?" asks the neutron.
"For you?" replies the bartender, "no charge."

Two hydrogen atoms walk into a bar. One says,
'I think I've lost an electron.'
The other says 'Are you sure?'
The first says, 'Yes, I'm positive...'

Guy goes into the doctor's.
"Doc, I've got a cricket ball stuck up my bum"
"How's that?"
"Don't you start"

What's got 4 legs and an arm ?
A happy Rottweiler !!

"So I got home, and the phone was ringing. I picked it up, and said
'Who's speaking please?'
And a voice said 'You are."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (7 of 8) [23/03/2005 05:49:07 p.m.]
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Some People Will Listen to Anything!!
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-06
http://www.afralisp.com/newsletter/2003/2003-06.htm (8 of 8) [23/03/2005 05:49:07 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-07
=========================
18th June 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
No Parking!!
=========================
The Front Stoep.
==============
Just to warn you, that as I'm away on business to Johannesburg
and Cape Town for most of next week, there will not be an issue
of the Newsletter. Sorry about that, but I'll try and make it up
to you with a bumper issue the following week. Please keep the letters
coming though as I do have access to my email whilst I'm travelling
and it will give me something to do in the evenings other than drinking
and picking fights with strangers.
Pearls of Wisdom
===============
Half of the people in the world are below average.
===============
==============
++++SPECIAL++++
For one week only!!!
"The AfraLisp AutoLisp Tutorials"
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (1 of 11) [23/03/2005 05:49:08 p.m.]
A collection of all the AutoLisp Tutorials found on AfraLisp in PDF format.
http://www.afralisp.com/books/AutoLisp.zip (Download size: 785 Kb)
Coding
=======
HERE IS ONE FOR Ryan
COMMAND LINE INPUT CH [ENTER]
ATT-TAGNAME [ENTER]
ATT-NEW-VALUE [ENTER]
PUT IT IN A SCIPT AND YOU CAD DO A BATCH OF DRAWINGS.
(I ALSO HAVE A SCRIPT GENERATOR BUT IT's IN DUTCH )
Rob
====
;CODING STARTS HERE
;Edistring routine
;
(defun editstring (VRAAG text / ltxt rtxt P L keyhit)
(textscr)
(setq P (strlen text))
(setq ltxt text)
(setq rtxt "")
(setq keyhit 1)
(prompt vraag)
(while (not (= keyhit 13))
(setq text (strcat ltxt rtxt))
(setq L (+ (strlen ltxt) (strlen rtxt)))
(setq ltxt (substr text 1 P))
(setq rtxt (substr text (1+ P) (- L P)))
(setq keyhit (cadr (grread)))
(if (and (> keyhit 31)(< keyhit 127))
(progn
(setq P (1+ P))
(if (not (= keyhit 8))
(progn
(setq ltxt (strcat ltxt (chr keyhit)))
(princ (chr keyhit))
)
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (2 of 11) [23/03/2005 05:49:08 p.m.]
)
)
)
)
; (prompt VRAAG)
(princ (strcat ltxt))
)
(defun c:INPUT ()
(SETQ OT "")
(setq NT (editstring OT))
)
(DEFUN C:CH ()
; (SETQ BLOCKNAAM (GETSTRING "BLOCK - NAAM : "))
(SETQ TAG (GETSTRING "ATTRIBUTE TAG : "))
(SETQ OT "")
; (SETQ VRAAG "NIEUWE TEKST : ")
(SETQ NEWDATA (GETSTRING T "NIEUWTEXT : "))
(SETQ INDEX 0)
; VERSCHIL TOV CHATTR.LSP IS DAT DE EERST VOLGENDE REGEL KIJKT OF HET
; JUISTE BLOCK IS GEKOZEN, NU NIET NODIG, OOK DE VRAAG HIERNA WORDT DUS
; OVERGESLAGEN.
; (SETQ SSET (SSGET "X" (LIST (CONS 0 "INSERT") (CONS 2 BLOCKNAAM))))
(SETQ SSET (SSGET "X" (LIST (CONS 0 "INSERT") )))
;
(SETQ BLOCKTEL (SSLENGTH SSET))
(WHILE (>= BLOCKTEL 0)
(SETQ ENTT (SSNAME SSET INDEX))
(IF (/= ENTT NIL)
(ZOEKATTR ENTT TAG )
)
(IF (/= ENTTL NIL)
(PROGN
; (SETQ DATA (CDR (ASSOC 1 ENTTL)))
; (SETQ DATA NEWDATA)
(SETQ enttl (SUBST (CONS 1 newdata) (ASSOC 1 enttl) enttl))
(ENTMOD enttl)
; (ENTUPD entt)
)
(PROGN
(TEXTSCR)
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (3 of 11) [23/03/2005 05:49:08 p.m.]
;; (PROMPT (STRCAT "RESTERENDE BLOKKEN = " (ITOA BLOCKTEL)))
)
)
(SETQ BLOCKTEL (- BLOCKTEL 1))
(SETQ INDEX (1+ INDEX))
)
(PRINC)
)
;----------------------------------------------------------------------
;
; (ZOEKATTR )
;
; Onderzoekt of entiteit een attribuut met de tag tagnaam heeft, en of
; de waarde daarvan gelijk is aan veldwaarde. Als de veldwaarde een lege
; string is wordt er niet op die waarde gecontroleerd.
;
; RETURN: Entity-list van het attribuut, als tagnaam en waarde kloppen
; Anders wordt een nil-list teruggegeven.
; ENTTL
; 22-3-90
;
;----------------------------------------------------------------------
(defun zoekattr (entt tag / gevonden test)
(setq
ENTTL (entget entt)
gevonden nil
)
(if
(and
(= (cdr (assoc 0 ENTTL)) "INSERT")
(= (cdr (assoc 66 ENTTL)) 1)
) ; als het een blok met attributen is
(setq
entt (entnext entt)
ENTTL (entget entt)
test (/= (cdr (assoc 0 ENTTL)) "SEQEND" )
)
(setq test nil)
)
(while TEST
; (if (and (= (cdr (assoc 0 ENTTL)) "ATTRIB")
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (4 of 11) [23/03/2005 05:49:08 p.m.]
(= (cdr (assoc 2 ENTTL)) tag))
(if (and (= (cdr (assoc 0 ENTTL)) "ATTRIB")
(= (STRCASE (cdr (assoc 2 ENTTL))) (STRCASE tag)))
(setq gevonden T)
)
(if gevonden
(setq test nil)
(setq
entt (entnext entt)
ENTTL (entget entt)
test (/= (cdr (assoc 0 ENTTL)) "SEQEND")
)
)
)
(IF (= (cdr (assoc 0 ENTTL)) "SEQEND")
(SETQ ENTTL NIL)
)
ENTTL
)
;CODING ENDS HERE
=================
Hi, I have a question.
I am trying to change the scale of a hatch pattern
(made with the BHATCH command, not HATCH, if it makes a difference)
through its entity data. I am able to change the list (associative code #41 )
to the scale I want and it will even update the entity list in AutoCAD.
The new scale shows up in the properties window. The only thing is that
the actual geometry on the screen doesn't change, even after a REGEN.
Thank you for you time,
Brian
======
Hi Kenny,
In your last newsletter there was a LISP code to delete all points from a drawing.
Here is a shorter solution:
;Code starts here
(defun c:ept (/)
(command "erase" (ssget "X" (list(cons 0 "POINT"))) "" )
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (5 of 11) [23/03/2005 05:49:08 p.m.]
(princ)
)
;Code ends here
OR
;AUTOLISP CODING STARTS HERE
(defun c:epts ( / ss ename etype elist sslen counter)
(setq ss (ssget "X" (list(cons 0 "POINT")))
sslen (sslength ss)
counter 0
)
(repeat sslen
(setq ename (ssname ss counter)
counter (1+ counter)
)
(entdel ename)
)
(princ)
)
(princ)
;AUTOLISP CODING ENDS HERE
With kind regards
Sherko
========
Hi Kenny,
I read the last newsletter and there was something
about having an extra osnap for locating a point between
two other points. 'cal;mee works fine for two endpoints
but what'll you do when you want a point between an
intersection and a center?
The solution is acually quite simple :

'cal;(cur+cur)/2

the "cur" keyword lets you select a point by CURsor,
and thus lets the user decide what kind of osnap he/she wants.
the "/2" divides the distance in two equal parts. Neat huh !!
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (6 of 11) [23/03/2005 05:49:08 p.m.]
A limitation is that if you want to divide in anything more than 2; for example:

'cal:(cur+cur)/3 or 'cal:(cur+cur)/4

You can't influence the point from where 1/3rd or 1/4th will be taken,
even if you pick the two points the other way round, you'll always get
the same result. For this purpose you'd better use

'cal;plt(cur,cur,0.333333) or
'cal;plt(cur,cur,0.25).

But with non-harmonic fractions like 1/3rd you'd introduce a roundoff error.
(the problems of the CAD-user are pretty huge huh?? LOL ;-))
I saw that a reader posted a LISP code to divide in 2, but that
routine only works in 2D and takes the Z-value of the first point.
The "'cal;(cur+cur)/2" thingie works in three dimensions.

Best regards,
Georges Bolssens
================
Is there a limitation on the number of characters a multi-select listbox will return?
I have found that mine will only read from 0 - 253. Does this sound right?
Can you give any insight? If this is correct how can I work around this to
allow for a bigger selection return?
Will Deloach
===========
Hi Kenny ...
Here is a contribution to your methods enterprise
http://www.afralisp.com/methods/methods_ref.htm#H
;CODING STARTS HERE
;;HatchMaKeR takes a selset ss comprised of lwpoly entity names,
;;applies an ANSI31 hatch to each member, always associative
;;and resets scale to dimscale value. There is no error checking (ferinstance,
;;assumes all members of ss are closed lwpolylines).
;;
(DEFUN hmkr ( / autocadobj thisdrawing htchobj nxtpl_en outrlp sslen ssct )
(VL-LOAD-COM)

(SETQ outrlp (Vlax-make-safearray vlax-vbObject '(0 . 0))
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (7 of 11) [23/03/2005 05:49:08 p.m.]
; note array is single dim, unit length
autocadobj (VLAX-GET-ACAD-OBJECT)
thisdrawing (VLA-GET-ACTIVEDOCUMENT autocadobj)
sslen (SSLENGTH ss)
ssct 0
) ;_ end of setq
(IF (= "Model" (GETVAR "ctab"))
(SETQ cspace (VLAX-GET-PROPERTY thisdrawing 'modelspace))
; hatch will be added to current space
(SETQ cspace (VLAX-GET-PROPERTY thisdrawing 'paperspace))
) ;_ end of if
(WHILE (< ssct sslen)
(SETQ nxtpl_en (SSNAME ss ssct)
nxtpl_en (VLAX-ENAME->VLA-OBJECT nxtpl_en)
;; bdry pline as vb obj
outrlp (vlax-safearray-fill outrlp (list nxtpl_en))
;; loops must be in an array, safearray-fill needs as many lists as array dims
htchobj (vla-addhatch cspace 0 "ANSI31" T)
;; add hatch obj to cspace
ssct (1+ ssct)
) ;_ end of setq
(vla-appendouterloop htchobj outrlp)
;; note that outrlp must be an array
(vlax-put-property htchobj 'patternscale (getvar "dimscale"))
(vla-evaluate htchobj)
) ;_ end of while
(vla-regen thisdrawing acactiveviewport)
;; another example of regen this time in current vp
(vlax-release-object autocadobj)
;; ALWAYS RELEASE OBJECTS .. or else
(vlax-release-object thisdrawing)
(vlax-release-object cspace)
(vlax-release-object nxtpl_en)
(princ);_ clean exit
) ;_ end of defun
;CODING ENDS HERE
Rob Kish
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (8 of 11) [23/03/2005 05:49:08 p.m.]
=========
Things Weird and Wonderful
========================
Can you post the following in your newsletter and/or website:
The 4th Annual New Jersey Autodesk Summertime CAD Show is now the
Northeast Regional Autodesk User Group Show. Two days of training,
vendor showcase and guest speakers (Lynn Allen of Autodesk, Ed Goldberg,
AIA and Jeanne Aahus).
The NRAUG Show will be held on August 6th and 7th at the Parsippany Hilton
in Parsippany, New Jersey. You don't want to miss this.
http://www.njaug.org/nraug.htm
Thomas E. Maleski
mailto:tmaleski@njaug.org
Program Director
New Jersey Autodesk User Group
http:\\www.njaug.org
Miscellaneous Rubbish that I almost Forgot
===================================
To end any selected command without having to write code for every
possible option, just repeat (command PAUSE) until the command is ended.

(command "_ARC")
(while (= 1 (logand (getvar "CMDACTIVE") 1)) (command PAUSE))
The Back Stoep
=============
And some more from Mike Perry :
Difficult/Impossible words to say when you are drunk -
* Innovative
* Preliminary
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (9 of 11) [23/03/2005 05:49:08 p.m.]
* Proliferation
Impossible words to say when you are drunk
* Thanks, but I don't want sex
* No, I don't want another drink
* No Kebab for me thanks
* Sorry, but you are not quite good looking enough for me
* Good evening officer
And one from me :
The Manchester United soccer players are in the dressing room on Saturday,
just before the game, when Roy Keane walks in.
"Boss," he says, "there's a problem.
I'm not playing unless I get a cortisone injection."
"Hey," says David Beckham. "If he's having a new car,
so am I."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Some People Will Listen to Anything!!
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (10 of 11) [23/03/2005 05:49:08 p.m.]
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-07
http://www.afralisp.com/newsletter/2003/2003-07.htm (11 of 11) [23/03/2005 05:49:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-08
=========================
3rd July 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
This line is invisible to anyone with a higher IQ than me.
=========================
The Front Stoep.
==============
Phew, finally made it back!!! I tell you what, these big cities
really freak me out these days. I'm not used to taking half an
hour to cover about 200m in the traffic. And having to wait in
a queue for a drink?? Well that is not on!! Other than that, I
only managed to get into two fist fights this time. The first
fight involved a nun and she should know better than to discuss
religion in a pub. Okay, I put some money in her collection box
after helping her up off the floor and stopping the bleeding,
but I thought she was trying to jump the queue at the bar??
The next fight though was a real cracker!! This was the hardest
fight of my life and I'm not joking. Two against twelve it was.
I tell you what, the twelve of us only stuffed up those two guys.
===============
Would you like to publish your AutoLisp/VBA code on the web?
Have a wee look at this :
http://www.afralisp.com/html/publishing_coding_I.htm
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (1 of 12) [23/03/2005 05:49:10 p.m.]
Pearls of Wisdom
===============
Want a taste of religion? Bite a nun.
===============
The AfraLisp Tutorial Books
=======================
These three books contain most of the AutoLisp/Visual Lisp/DCL
Tutorials published on AfraLisp. They are in a special PDF format
in the sense that they will self destruct within one week and
reformat your hard drive unless you make a large donation to AfraLisp.
"The AutoLisp Tutorials"
"The DCL Tutorials"
"The Visual Lisp Tutorials"
+PLUS+
"The Extras"
http://www.afralisp.com/books.htm
=============================
Don't say I'm not nice to y'all
=============================
And don't forget that AfraLisp now has it's very own "Knowledge Base".
http://www.afralisp.com/disc6_toc.htm
Coding
=======
Hi Kenny,
Georges Bolssens wrote that when using the 'CAL' function 'plt'
"non-harmonic fractions like 1/3rd ... introduce a roundoff error".
While this is true the way he has used it, you can easily overcome
that problem by simply using a fraction (actually division) as the
third argument

'cal;plt(cur,cur,1/3);

It still works in 3D, and avoids any roundoff error.
Jim Fisher
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (2 of 12) [23/03/2005 05:49:10 p.m.]
=========
Kenny,
I was reading one of the Newsletters and read where someone was having
problems with a midpoint routine. I got some help on the one I use so
I will include it freely to help someone else. This routine works even
if you have osnaps set. I set mine to work in my osnap popup menu.
;CODING STARTS HERE
(defun C:mid3d (/ pt1 pt2)
(setq pt1 (getpoint "\nPick first point: ")
pt2 (getpoint "\nPick second point: ")
)
(setvar
"lastpoint"
(mapcar '+
pt1
(mapcar '/ (mapcar '- pt2 pt1) '(2.0 2.0 2.0))
)
)
"@"
)
;CODING ENDS HERE
Will Deloach
===========
Hi Kenny

Great to see your newsletter back on the air. (I don't know how I
survived without it - it was a dark period!)

Before I get to my main point, thanks for your tip about the lisp
editing program Lisplink from www.caelink.com - I don't know how I
lived without it! Also, your readers may like to know that DOSLib
6.1 is now available.

Your tip to end any selected command without having to write code
for every possible option reminded me of something I discovered many
years ago. I wanted my lisp program to insert a drawing (which
contained a library of blocks) into my current drawing without
actually placing it on the drawing so that the blocks contained within
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (3 of 12) [23/03/2005 05:49:10 p.m.]
the inserted drawing would be available in the current drawing.
That is, I wanted the "insert" command to terminate at the point at
which an insertion point was requested by AutoCAD. I used \r to
terminate the command. (I don't know if this is widely known.)
This process can be demonstrated with the following code fragment
(assuming the chroma.dwg drawing is in the current search path):

(command "insert" "chroma" \r)

The drawing "chroma" is added to the block table without it being
inserted into the drawing file.

More recently, I wanted a lisp program to delete any exiting Xclip
boundaries associated with all the Xrefs in a drawing.
If the boundaries exist, they can easily be deleted with the "d"
option in the "xclip" command and the command will terminate.
The trouble is, if there are no boundaries, AutoCAD reports
"No clip boundary found" and the command wants you to enter another
option. Once again, I used \r to get around this problem with the
following code fragment:

(command "xclip" (xsfind) "" "d" \r)

(xsfind is a function which returns a selection set of all the inserted Xrefs.)

If there are any Xclip boundaries, they are deleted.
If there are none, the xclip command terminates and the lisp program can continue.

Your readers may be interested in the xsfind function I have written:

Craig Green

;CODING STARTS HERE
(defun xsfind ( / blk blkn l n xin xset)
(setq xset (ssadd))
; Create blank selection set
(setq blk (tblnext "block" t))
; Retrieve 1st block in block table
(while (/= blk nil)
; Loop through all blocks in block table
(if (/= (assoc 1 blk) nil)
; Process if block is an xref
(progn
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (4 of 12) [23/03/2005 05:49:10 p.m.]
(setq blkn (assoc -2 blk))
; Get entity name
; Now check drawing to see if xref has been inserted.
;(Program checks of multiple insertions)
(setq xin (ssget "x" (list (cons 0 "INSERT")
(cons 2 (cdr (assoc 2 blk))))))
;Now loop through xin and add inserted xrefs to selection set xset
(if xin
; If any inserted xrefs
(progn
(setq l 0)
; l = selection set pointer for xin
(setq n (sslength xin))
; n = number of inserted xrefs of given name
(while (< l n)
; For each inserted xref
(ssadd (ssname xin l) xset)
; Add inserted xref to selection set xset
(setq l (1+ l))
; point to next xref name
) ; end while
) ; end progn
) ; end if
) ; end progn
) ; end if
(setq blk (tblnext "block"))
; Retrieve next block in block table
) ; end while
(if (= 0 (sslength xset)) (setq xset ()))
(setq xset xset)
) ; end xsfind
;CODING ENDS HERE
=================
Hi... Mr Kenny i have a litle question.
Could be a create cursor in autolisp like a hand cursor ......?
thank you for u time
Haris
=====
Any electrical darfties out there? have some simple AutoLISP routines
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (5 of 12) [23/03/2005 05:49:10 p.m.]
that might help you... Nested blocks & attributes.
Not many of us out there so would be nice to get in touch and grow and learn.
Oh Kenny... Oh! Kenny... Brilliant site
Timmo
mailto:cadtech@mweb.co.za
========================
Hello,
I am very novice at programming, having done only a little bit of C++
programming in college. Using your site, I have written my first AutoLISP
file, mind you it is quite simplistic and will hopefully undergo several
changes, but it is working up to a point now. Unfortunately I have
encountered a problem at the very end of the program.
The program I constructed is to display aerial photography of the city
I work for by taking user's input as far as coordinates, and then
displaying the correct image (our aerial photography is split into tiles,
or 2500ftx2500ft divisions of the city) at the corrrect coordinates.
I have all the conditionals and looping for input within the correct
boundaries worked out, but; when it comes to displaying the image I
have a problem. The only command I know to use for attaching images to
a drawing is the "imageattach" function, so I put the command "imageattach"
line in my program. Still using the command function I put the path name
in (by strcat multiple strings from variables defined by user input).
The problem is here. When you call the "imageattach" function an autocad
dialog box opens up, for finding the image. Unfortunately using the
command and the prompt function doesn't seem to work for filling in the
file name in the dialog box. Do you know how one would fill in this box
automating it in an autoLISP routine? Or is there another function that
I am unaware of that will allow a user to do this from the command line?
Nate
=====
Hello,
I love your web site. It's a great resource!
I have a question that I'm sure you can answer:
I have a list that has several elements, but 2 are the same.
(Each element is enclosed in "<>"):
(<BUILDING TITLE> <" "> <SCALE: 1/2" = 1'-0"> <AAA> <DRAFTER>
<CHECKER> <A> <6> <14><AAA>)
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (6 of 12) [23/03/2005 05:49:10 p.m.]
I only want to replace the first instance of "AAA" with the BBB variable.
This first instance can be anywhere in the list.
I tried using the SUBST function, but it replaces all occurrences of the element.
Do you know of a method that will replace any one element, even when there
is multiple occurrences?
Thanks,
Kelley
======
Have a look at the "member" function Kelley.
This function searches a list for an occurrence of an expression
and returns the remainder of the list, starting with the first
occurrence of the expression.
=========
Hi there,
I am starting to learn Visual Lisp. Couple days ago I done my
first rectangle. Now I am trying to make some 3D based objects
like wedge or quad. Can you help me here with some tips or tricks?
Regards,
Edin
mailto:helez@web.de
===================
Things Weird and Wonderful
========================
Would you like to strip all the white space out of your AutoLisp coding?
Open a new file in Notepad and add these lines :
<HTML>
<HEAD>
<TITLE>Strip White Space</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (7 of 12) [23/03/2005 05:49:10 p.m.]
Now add you code between the <BODY> and </BODY> tags :
<HTML>
<HEAD>
<TITLE>Strip White Space</TITLE>
</HEAD>
<BODY>
(defun c:al-move ( / util BP PT2)
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)
</BODY>
</HTML>
Save this file as "STRIP.HTML".
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (8 of 12) [23/03/2005 05:49:10 p.m.]
Now open this file in your browser.
Copy the text that appears in your browser and paste it into Notepad.
All the white space has been stripped from your coding.
The above coding will now look like this :
(defun c:al-move ( / util BP PT2) (vl-load-com) ;get a reference to the
Utilities Object : (setq util (vla-get-utility (vla-get-activedocument
(vlax-get-acad-object)))) ;select the object (vla-getentity util 'theobj
'ip "\nSelect Object: ") ;get the base point (setq BP (vla-getpoint util
nil "\nSpecify base point or displacement: ")) ;get the displacement
(setq PT2 (vla-getpoint util BP "\nSpecify second point of displacement:
")) ;move the object (vla-move theobj BP PT2) (princ) );defun (princ)
============
Nice web site. If you are interested you can link to my unofficial AutoCAD
history site and also the command and system variables documents.
http://betaprograms.autodesk.com/history/autocad_release_history.htm
Shaan Hurley
mailto:shaan@autodesk.com
Miscellaneous Rubbish that I almost Forgot
===================================
"Vmyths"
The Truth About Computer Virus Myths & Hoaxes
http://vmyths.com/
The Back Stoep
=============
The following is dedicated to all draughtsmen/draughtsladies/draughtspersons :
The "Five Stages of Drunkeness".
===========================
Stage 1 - CLEVER
This is when you suddenly become an expert on every subject in the known universe.
You know you know everything and you want to pass on your knowledge to anyone
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (9 of 12) [23/03/2005 05:49:10 p.m.]
who will listen. At this stage you are always right. And, of course, the person
you are talking to is very wrong.This makes for an interesting argument when
both parties are CLEVER.
Stage 2 - ATTRACTIVE
This is when you realise that you are the most ATTRACTIVE person in the entire
bar and that everyone fancies you. You can go up to a perfect stranger knowing
that they fancy you and really want to talk to you. Bear in mind that you are
still CLEVER, so you can talk to this person about any subject under the sun.
Stage 3 - RICH
This is when you suddenly become the RICHEST person in the room.
You can buy drinks for the entire bar because you have a bottomless wallet.
You can also make bets at this stage, because of course you are still CLEVER so,
naturally, you will always win. Anyway, it doesn't matter how much you bet
because you are RICH. You will also buy drinks for everyone that you fancy,
in the knowledge that you are clearly the most ATTRACTIVE person present.
Stage 4 - INVINCIBLE
You are now ready to pick fights with anyone and everyone, especially those
with whom you have been betting or arguing. This is because you are now INVINCIBLE.
At this point you can also go up to the partners of the people who you fancy and
challenge them to a battle of wits or strength. You have no fear of losing this
battle, because as well as being INVINCIBLE you are CLEVER, you're RICH and
you're more ATTRACTIVE than they are anyway.
Stage 5 - INVISIBLE
This is the final stage of drunkenness. At this point you can do anything,
because you are now INVISIBLE. You can dance on a table to impress the people
who you fancy because the rest of the people in the room cannot see you.
You can also snog the face off them for the same reason. You are also INVISIBLE
to the people who want to fight you. You can walk through the street singing at
the top of your lungs because no one can see or hear you , and because you're
still CLEVER you know all the words.
THE FIVE STAGES OF SOBERING UP
Stage 1 - STUPID
As you regain consciousness and begin to enjoy the headache, the churning
stomach and the cold sweats, you realise that you have lost not only several
hours of your life but also the ability to concentrate on anything whatsoever.
You are now STUPID and will remain so for a minimum of 12 hours.
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (10 of 12) [23/03/2005 05:49:10 p.m.]
Stage 2 - UGLY
Never entirely happy with the effects of the bathroom mirror first thing you
are horrified to discover that you have now become even UGLIER than you
previously thought possible. Not only have you bloodshot eyes and a glorious
collection of spots but you are shaking so much that your grandfather probably
looks healthier. Unfortunately you are still too stupid to know better than to
try and shave whilst shaking.
Stage 3 - POOR
Having crawled out of bed and got dressed you are about to shamble out the
door when you discover that the money that was to last you the week is now
missing from your wallet. Being STUPID, you have no idea what happened to it
but the traces of curry on your clothes allow the possibility that you might
have treated everyone to a takeaway at some point. Alternatively your pocket
could have been picked or you might have given the taxi driver 150 by mistake.
Rationalising that you couldn't possibly have been that STUPID and that you
would remember being robbed, you come to believe that you were the only one
who bought any food or drinks all night and start to loathe all your friends.
Stage 4 - FRAGILE
As you are now STUPID, UGLY and POOR, your consequently FRAGILE self-esteem,
plummets. Your already FRAGILE physical condition ensures that you feel liable
to shatter if anyone even speaks to you.
Stage 5 - CONSPICUOUS
This is the final stage of sobering up. Unfortunately, everyone can spot this
CONSPICUOUS condition and its cause from a great distance. Even worse, they
know that they can complete your misery by making fun of you, and that you
are too STUPID to retaliate, too FRAGILE to hit them, too POOR to bribe them
and too UGLY to hide.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (11 of 12) [23/03/2005 05:49:10 p.m.]
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-08
http://www.afralisp.com/newsletter/2003/2003-08.htm (12 of 12) [23/03/2005 05:49:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-09
=========================
Wednesday 9th July 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Meow... SPLAT...
Ruff... SPLAT...
Hey, it's raining cats and dogs.
=========================
The Front Stoep.
==============
Okay, I've given up and finally succumbed to your numerous requests.
AfraLisp now has it's very own question and answer Forum.
You can find it here :
http://www.afralisp.com/theforum_toc.htm
Do with it what you will.........
=========================
The AfraLisp books are flying off the shelves.
http://www.afralisp.com/books.htm
If you downloaded them, please give me feedback so I can plan for future updates.
Here's wee note I received from one grateful customer :
Thanks very much for those books mate.
I am new to this and it looks quite easy due to your easy books you have made.
They are really good.
Sorry mate as I don't have a donation (poor student) but I will keep you in mind.
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (1 of 9) [23/03/2005 05:49:11 p.m.]
Cheers,
Harry
New Zealand
===========
Funnily enough, he lives in the same town in New Zealand as my brother does. So,
Eddie will be popping around to :
1) Make sure he's a student, and
2) Make sure that he keeps me in mind when he qualifies and starts to earn money.
Although, being a New Zealander, I should be about 90 when that occurs!!!
===========
Kenny's Ridiculous AutoCAD Wishlist
==============================
1) Cost - $5-00 but free to all coders.
2) All commands work from voice recognition.
3) Automatic updating of paths when Xrefs and other dependent files are moved.
4) Hell of a big screen - about the size of the old A0 drawing boards should be fine.
5) Porn pull down menu.
6) Sports pull down menu.
7) Drawing Office Manager detector and warning system.
8) Free subscription to the AutoDesk Developers Network.
9) Free entry and free drinks in the AutoDesk bar.
10) An AutoCAD command named after me, something like "The Kennyizer" or "The Ramagedoodler".
If you have any wishlist items that you would like to suggest, just send them to
me written on the back of a $10 note.
Pearls of Wisdom
===============
Gather 'round like cattle and ye shall be herd.
===============
Metric Steel Section Tool Palettes.
===================================
For use with AutoCAD 2004 and AutoCAD LT 2004.
Contents :
C_PFC - Parallel Flange Channels PFC
C_RSC - Tapered Flange Channels RSC
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (2 of 9) [23/03/2005 05:49:11 p.m.]
E_Angle - Equal Angle Legs EA
U_Angle - Unequal Angle Legs UA
U_Beam - Universal Beams UB
U_Col - Universal Columns UC
Joist - Tapered Flange Joists RSJ
H_Sect_C - Circular Hollow Sections CHS
H_Sect_R - Rectangular Hollow Sections RHS
Form_C - Formed Channels FC
Form_CL - Formed Lipped Channels FLC
Form_A - Formed Angles FA
Form_AL - Formed Lipped Angles FLA
http://www.afralisp.com/mylisp.htm
Coding
=======
Kenny
With regard to Nate's image problem in Newsletter No 2003-08:
I would suggest that Nate try...
(COMMAND "IMAGE" "a" "c:/path/image.tif" "0,0" "1" "0")
Where:
c:/path/ = the required drive and search path
image.tif = is the required image to load (could be tif, bmp, jpg etc)
0,0 = location to insert on drawing
1 = scale
0 = rotation
At the command prompt you can type: -image
to simulate this process.
Regards
Craig Green
===========
Hello Kenny,
I have written a routine in Visual Lisp and saved it as a .lsp file.
When I load it into AutoCAD and type the command, it works fine.
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (3 of 9) [23/03/2005 05:49:11 p.m.]
However, when I add an autoload function for this file in acad200doc.lsp
and include the command in the S::STARTUP function, at startup, I get an
error message that looks like this :
Invalid attempt to access a compiled function definition. You may want to
define it using defun-q: #
I have tried replacing defun C: with defun-q: but it doesn't work. I made
sure I included (vl-load-com). The file wasn't compiled. I simply typed
the code in a text editor and saved it as an lsp file as I would with standard Autolisp.
What am I doing wrong?
Thanks
Lara
=====
The defun-q function is provided strictly for backward-compatibility
with previous versions of AutoLISP, and should not be used for other
purposes. You can use defun-q in situations where you need to access a
function definition as a list structure, which is the way defun was
implemented in previous, non-compiled versions of AutoLISP.
Example from my AcadDoc.lsp :

;AcadDoc functions start here

(defun-q MYSTARTUP ()

;My startup function is defined here
);defun-q

(setq S::STARTUP (append S::STARTUP MYSTARTUP))

;AcadDoc functions end here
=========================
Mr. Kenny Ramage,
My name is Ezer Urpia, cartograph engineer.
Id like how can i copy a layer from one drawing to another drawing in vba code
I use autocad map 2000.
Ezer
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (4 of 9) [23/03/2005 05:49:11 p.m.]
=====
Ok, Here is my dilemma.
I have developed a routine to draw leaders and piece bubbles on drawings
and under certain conditions, I need the leader end to be either an "arrow"
or a "dot". Basically, when pointing to surface of plates and shapes we use
a dot but when pointing to the edge of the plate or shape, we use an arrow.
In the past, when we drew strictly in model space, I used a "getpoint"
statement along with an ssget statement.
(setq pt1 (getpoint "\nLeader Start:"))
(if (ssget pt1) etc,.....
If the result was a selection set, if anything was selected, I could use an
if statement to draw a leader with either an arrow or dot. Now that we are
converting over to Model Space/Paper Space it does not work. The ssget
function filters out any information not in the "current" space not allowing
the selection of items in model space and vice versa. Hence my term
"transpacial". I need a way to determine if I am pointing to the edge of
the surface of the item. My fix is to ask the user which type of leader end
to use. I do not like this method because it could lead to errors and I
like the reduce the choices required of the user. Too may choices seems
cumbersome. Any suggestions? We are not using 3D here and this PS/MS is
new to me.
Thanks,
Andrew C. Millard
===============
Kenny
The line spacing for mtext appears to always default to "At least". Is
there a way to force the default to "Exactly"?
Regards
Craig Green
===========
I have a question about the order TYPE.
I wish to import a ASCII file of points. Each line consist of the file
"number " (not neccesarily a integer; it can also be a real number or a string),
followed by the X and Y coordinates.
For example :
1 32.3 33.4
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (5 of 9) [23/03/2005 05:49:11 p.m.]
1A 35.0 56.7
B 28 45
It is easy to extract the first element of each line, but I need then to
identify it as a integer, a real or a string, in order to apply ITOA or RTOS
in the first two cases to convert it to a string, and then use PRINT.
I have tried to use TYPE to identify the class of each element ; for
example, with the variable xx
(if
(= INT (TYPE xx))
(print "\nxx is an integer")
)
but somehow it does not seem to work.
Any idea about how to identify an element as an integer, a real or a
string?
Thanks
Rogelio Bravo
============
Rogelio,
Given the following assignments:
(setq a 123 r 3.45 s "Hello!" x '(a b c))
(setq f (open "name" "r"))
then
(type 'a) returns SYM
(type a) returns INT
(type f) returns FILE
(type r) returns REAL
(type s) returns STR
(type x) returns LIST
(type +) returns SUBR
(type nil) returns nil
The following code example uses the type function on the argument passed to it:
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (6 of 9) [23/03/2005 05:49:11 p.m.]
(defun isint (a)
(if (= (type a) 'INT) ;is TYPE integer?
T ;yes, return T
nil ;no, return nil
)
)
============
Things Weird and Wonderful
========================
Thank's for the first newsletter, please read more :
http://www.btlsp2000.com/page502.html.
BT
====
Where is the Easter egg hidden in AutoCAD 2004?
Start the Color dialog (e.g. with the _COLOR command).
On the Index tab, Ctrl+Left click on the color box 152.
Voila - the Autodesk team presentation will run.
You can control it interactively with your mouse :
L=rotate
M=pan
R=zoom
and keyboard :
space=pause
enter=restart
Y=cheers
4=geyser.
Miscellaneous Rubbish that I almost Forgot
===================================
If you need to run the dialog version of the PLOTSTAMP command even
in your script files, menus and LISP applications, use its undocumented
version _DDPLOTSTAMP.
================
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (7 of 9) [23/03/2005 05:49:11 p.m.]
Do you want to have a textual list of current Xrefs used in your drawing?
Use the RTEXT command (Express Tools) and enter the Diesel expression:

List of Xrefs : $(xrefs,3)
When you attach or detach a Xref, just regen your drawing to update the list.
The Back Stoep
=============
The tribal wisdom of the Dakota Indians, passed on from one generation to the
next, says that when you discover you are riding a dead horse, the best strategy
is to dismount.....
However, in modern business, because of the heavy investment factors to be taken
into consideration, often other strategies have to be tried with dead horses,
including the following:
- Buying a stronger whip.
- Changing riders.
- Threatening the horse with termination.
- Appointing a committee to study the horse.
- Arranging to visit other sites to see how they ride dead horses.
- Lowering the standards so that dead horses can be included.
- Appointing an intervention team to reanimate the dead horse.
- Creating a training session to increase the riders load share.
- Reclassifying the dead horse as living-impaired.
- Change the form so that it reads: "This horse is not dead."
- Hire outside contractors to ride the dead horse.
- Harness several dead horses together for increased speed.
- Donate the dead horse to a recognized charity, thereby deducting
its full original cost.
- Providing additional funding to increase the horse's performance.
- Do a time management study to see if the lighter riders would
improve productivity.
- Purchase an after-market product to make dead horses run faster.
- Declare that a dead horse has lower overhead and therefore performs better.
- Form a quality focus group to find profitable uses for dead horses.
- Rewrite the expected performance requirements for horses.
- Promote the dead horse to a supervisory position.
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (8 of 9) [23/03/2005 05:49:11 p.m.]
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-09
http://www.afralisp.com/newsletter/2003/2003-09.htm (9 of 9) [23/03/2005 05:49:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-10
=========================
Wednesday 16th July 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
.sdrawkcab daer osla nac uoy ,hhA
=========================
The Front Stoep.
==============
Hello and Welcome to Issue No 10.
Is this a milestone?
Naw, it's just another day of another week of another year.
Every week I send off the Newsletter and immediately say to myself,
"Kenny", 'cos that's my name, "What are you going to put into next weeks
Newsletter? You've got nothing. Ziltch!! You haven't written anything,
You've produced no tutorial, nobody even sends you hate mail anymore".
Somehow though, I keep on struggling through and coming up with material
- albeit stolen - that other people should have more sense than to leave
lying around all over the web. I'm just tidying up!
Anyway, want I meant to say was, yes, please feel free to send me any
material that you feel should be published to a bunch of discombobulated,
in the mental sense, readers. You are never too old, or too young,
to try something new.
Remember, old draughtsmen don't die, they just draw too an end!!!
To change the subject, here's some feedback from my AutoCAD WishList
that was published last week.............
Hi Kenny
Liked your AutoCAD WishList, especially enjoyed No 10 :)
May I suggest a System Variable would be more appropriate.
*KennyMode*, when set to 1 (One) it will Quit AutoCAD immediately
at 12:30 (lunchtime) and not allow you back-in until 13:30; then
at 17:00 it will Quit permanently for the day and display a message
suggesting that you go to the *Pub* for serious alcohol abuse.
Cheers, Mike
===========
I must also mention that we had slight problems with the AfraLisp site towards
the end of last week and over the weekend whilst changing over to new servers.
I apologise for any inconvenience. Everything now seems to be up and running
and working well - fingers and toes crossed!! Thanks Frank.
Pearls of Wisdom
===============
I Xeroxed a mirror, now I have an extra copier.
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (1 of 9) [23/03/2005 05:49:13 p.m.]
And have you noticed that Xerox never comes up with
anything original anymore.
===============
The "AfraLisp Forum" is now up and running :
http://www.afralisp.com/theforum_toc.htm
And don't forget the AfraLisp "Knowledge Base" :
http://www.afralisp.com/disc6_toc.htm
Coding
=======
Hi Kenny,
Re: The line spacing for mtext appears to always default to "At least".
Is there a way to force the default to "Exactly"?
The System Variable "TSpaceType" controls this behaviour -
1 = At Least
2 = Exactly
Also take a look at the System Variable "TSpaceFac", which controls
the line-spacing of MText Entities/Objects measured as a factor of
Text Height.
Valid Range 0.25 to 4.0
Cheers, Mike
===========
Would you like a simple way of obtaining a listing of all your
system variable settings?
At the command prompt type this :
"LogFileOn"
Then type :
"Setvar" following by "?" then "*"
Keep on selecting "Enter" until the variable listing is complete.
Then type :
"LogFileOff"
You will now have a complete listing of your system variables stored
in the log file which should be in the same directory as your drawing.
Hint: This is wide open for automation.
================================
In reference to Rogelio Bravo's question in newsletter 2003-09.
I think the main problem is that he is importing an ASCI file that
contains a random mix of numbers and strings - therefore, all imported
values will have to be initially treated as strings and because of this,
the lisp function TYPE will always return STR. The trick is to work out
whether the string can be a valid number like "1" "-123.0" etc or whether
it can only be a string like "1A" "B" etc.
I have written a function called "sri" which returns "STR" "INT" or "REAL"
depending upon whether the argument passed to the function is a string,
an integer or a real number.
As noted in the code, the method I have used for checking whether a number
is a real or an integer, is a bit crude because it will report numbers like
1.0 as integers. Others can improve on this if they like.
To test the code, load it into AutoCAD and type:
(sri "1")
(sri "1A")
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (2 of 9) [23/03/2005 05:49:13 p.m.]
(sri "123.456")
etc

Regards
Craig Green

;CODING STARTS HERE
; Numeric test
(defun ntest (s / a af c df n s)
(setq n (strlen s))
(setq c 1)
(setq af nil)
(setq df 0)
(setq a (ascii (substr s c 1)))
(if (= s "") ; Check for blank string
(setq af T)
)
(if (= a 45) ; Check for "-" at begining of sting
(progn
(setq c (+ c 1))
(setq a (ascii (substr s c 1)))
)
)
(while (<= c n)
(if (or (and (>= a 48) (<= a 57)) (= a 46))
; Check for 0 to 9 or "."
()
(setq af T)
)
(if (= a 46) ; Check for more than 1 "."
(setq df (+ df 1))
)
(if (> df 1)
(setq af T)
)
(setq c (+ c 1))
(setq a (ascii (substr s c 1)))
)
(if (or (= s ".") (= s "-") (= s "-."))
; Check for single ".", single "-" or "-."
(setq af T)
)
(= af nil) ; Return T if s is numeric
) ; End ntest
;
(defun sri (s / memtyp n)
(if (= (ntest s) nil)
(setq memtyp "STR") ; Must have been a string
(progn
(setq n (atof s))
(if (= (float (fix n)) n) ; Crude check for integer
(setq memtyp "INT")
(setq memtyp "REAL")
)
)
)
memtyp
)
;CODING ENDS HERE
=================
I'm looking for some help. How can I change the width factor
of text (via VBA) that has been added to a drawing? Can that
property be set prior to adding the text or would I need to
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (3 of 9) [23/03/2005 05:49:13 p.m.]
somehow selected the text, then change the property.
Keith Whitfield
=============
If you can use text instead of mtext then you could do the following:
Sub TextWidth()
Dim MyText As AcadText
Dim InsertionPoint As Variant
Dim Height As Double
Dim Text As String
Height = 5
Text = "Thickness = Width Factor"
InsertionPoint = ThisDrawing.Utility.GetPoint
Set MyText = ThisDrawing.ModelSpace.AddText(Text, InsertionPoint, Height)
MyText.ScaleFactor = 5
MyText.Update
End Sub
Mtext, however, is generally controlled by textstyle so you could
presumably change the text to a textstyle of the desired width factor
in a similar fashion.
Joe
====
How does one obtain the secrets to the acetutil2,3 and 4.fas files.
I have acetutil.lsp, but I am looking for explanations and/or coding
for the following commands:
acet-ucs-cmd
acet-viewport-next-pickable
acet-currentviewport-ename
I am guessing that they are located in the above mentioned "fas" files.
Any help?
Thanks,
Andrew C. Millard
===================
How can I translate coordinates in VBA CAD2000,
like Visual Lisp TRANS keywords?
Please advice me

manjula
=======
Dear Sir,
Could you please tell if there is a way of joining two autocad arcs,
or two polylynes into one polyline, through vb, not by lsp.
Thank you
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (4 of 9) [23/03/2005 05:49:13 p.m.]
Upasena
========
Dear Mr Kenny Ramage
My name is Solom Cornel and I am naval emgineer in
Romania.
I start to learn Visual Lisp from some time and
I found on web pages some Lisp source files written by
you which were very useful for me.
Could you tell me another web pages where I'll find
good Lisp files. I am interested especially for a Lisp
file that read a DXF files and transform it in a file
for Numerical Cutting Machines.
Best regards,
Solom Cornel
=============
Often menu macros should act differently depending on the active command.
The CMDNAMES variable can be used to detect the running command, if any.
This macro checks whether any command is active. If not, it turns the
running osnap off. If a command is active, the running osnap is
overwritten by "none" for the next input only:
[OSnap off]+
$M=$(if,$(eq,,$(getvar,cmdnames)),+
'osmode;0,_none)
In a similar way you can turn on or override any running object snap mode.
Use the and and xor functions to evaluate the OSMODE system variable:
[$(if,$(and,1,$(getvar,osmode)),!.)Endpoint snap]+
$M=$(if,$(eq,,$(getvar,cmdnames)),+
'osmode;$(xor,1,$(getvar,osmode)),_end)
[$(if,$(and,2,$(getvar,osmode)),!.)Midpoint snap]+
$M=$(if,$(eq,,$(getvar,cmdnames)),+
'osmode;$(xor,2,$(getvar,osmode)),_mid)
[$(if,$(and,4,$(getvar,osmode)),!.)Center snap]+
$M=$(if,$(eq,,$(getvar,cmdnames)),+
'osmode;$(xor,4,$(getvar,osmode)),_cen)
Just a thought!!!
=============
Do you know that you can store a string in the registry?
Try this at the command prompt :
(setenv "Temp" "Kenny is handsome")
To retrieve it type :
(getenv "Temp")
Start a new drawing and try and retrieve it again. Still there!
Close and re-open AutoCAD and retrieve it again. Still there!!!!!
(setenv "variablename" "myvalue") will create the string key
"variablename" in the System Registry and assign it the value
of "myvalue".
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (5 of 9) [23/03/2005 05:49:13 p.m.]
(getenv "variablename" can then be used to retrieve the value of
"variablename".
Just another thought!!!!!
=====================
Things Weird and Wonderful
========================
Would you like your fortune told?
Try the "AfraLisp Fortune Teller"
http://www.afralisp.com/fortunet.htm
Some useful downloads :
The "American Structural Steel Handbook".
http://www.augafrica.com/docs/shpbook.zip
Engineering Tools
http://www.augafrica.com/docs/softech_engtools.exe
AutoCAD 2000 Bitmaps
http://www.augafrica.com/docs/AutoCADBitmaps2000.zip
AutoCAD 2002 Bitmaps
http://www.augafrica.com/docs/AutoCADBitmaps2002.zip
P.S. If you have problems downloading, please be patient
and try again a bit later.
(The Gremlins Are All Over Us).
Miscellaneous Rubbish that I almost Forgot
===================================
Rtext is a handy little application that can be used for
numerous things.
In this tutorial, I have a look at how Rtext can come in
useful as a Drawing Setup tool. Remember, that you will
need to have Express Tools installed to make use,
and sense, of this tutorial :
http://www.afralisp.com/lisp/rtext.htm
And some "Utter Rubbish"
http://www.afralisp.com/utterrubbish.htm
The Back Stoep
=============
Understanding Engineers
=====================
Submitted by Michael Perry
Understanding Engineers - Take One:
Two engineering students were walking across campus when one said,
"Where did you get such a great bike?"
The second engineer replied, "Well, I was walking along yesterday
minding my own business when a beautiful woman rode up on this bike.
She threw the bike to the ground, took off all her clothes and said,
"Take what you want."
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (6 of 9) [23/03/2005 05:49:13 p.m.]
"The second engineer nodded approvingly, "Good choice. The clothes
probably wouldn't have fit ."
************
Understanding Engineers - Take Two:
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.
************
Understanding Engineers - Take Three:
A pastor, a doctor and an engineer were waiting one morning for a
particularly slow group of golfers. The engineer fumed,
"What's with these guys? We must have been waiting for 15 minutes!"
The doctor chimed in, "I don't know, but I've never seen such ineptitude!"
The pastor said, "Hey, here comes the greens keeper. Let's have a word
with him." "Hi George! Say, what's with that group ahead of us?
They're rather slow, aren't they?"
The greens keeper replied, "Oh, yes, that's a group of blind firefighters.
They lost their sight saving our clubhouse from a fire last year, so we
always let them play for free anytime."
he group was silent for a moment. The pastor said, "That's so sad. I
think I'll say a special prayer for them tonight."
The doctor said, "Good idea. And I'm going to contact my ophthalmologist
buddy and see if there's anything he can do for them."
The engineer said, "Why can't these guys play at night?"
************
Understanding Engineers - Take Four:
What is the difference between Mechanical Engineers and Civil Engineers?
Mechanical Engineers build weapons and Civil Engineers build targets.
************
Understanding Engineers - Take Five:
The graduate with a Science degree asks, "Why does it work?"
The graduate with an Engineering degree asks, "How does it work?"
The graduate with an Accounting degree asks, "How much will it cost?"
The graduate with an Arts degree asks, "Do you want fries with that?"
************
Understanding Engineers - Take Six
Three engineering students were gathered together discussing the
possible designers of the human body. One said, "It was a mechanical
engineer. Just look at all the joints."
Another said, "No, it was an electrical engineer. The nervous system
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (7 of 9) [23/03/2005 05:49:13 p.m.]
has many thousands of electrical connections."
The last one said, "Actually it was a civil engineer. Who else would
run a toxic waste pipeline through a recreational area?"
************
Understanding Engineers - Take Seven:
Normal people believe that if it ain't broke, don't fix it.
Engineers believe that if it ain't broke, it doesn't have enough
features yet.
************
Understanding Engineers - Take Eight:
An architect, an artist and an engineer were discussing whether it was
better to spend time with the wife or a mistress.
The architect said he enjoyed time with his wife, building a solid
foundation for an enduring relationship.
The artist said he enjoyed time with his mistress, because of the
passion and mystery he found there.
The engineer said, "I like both."
Both?
"Yeah. If you have a wife and a mistress, they will each assume you are
spending time with the other woman, and you can go to the lab and get
some work done."
************
Understanding Engineers - Take Nine:
An engineer was crossing a road one day when a frog called out to him
and said, "If you kiss me, I'll turn into a beautiful princess."
He bent over, picked up the frog and put it in his pocket. The frog spoke
up again and said, "If you kiss me and turn me back into a beautiful
princess, I will stay with you for one week."
The engineer took the frog out of his pocket, smiled at it and returned
it to the pocket. The frog then cried out, "If you kiss me and turn me back
into a princess, I'll stay with you and do ANYTHING you want."
Again the engineer took the frog out, smiled at it and put it back into
his pocket. Finally, the frog asked, "What is the matter? I've told you
I'm a beautiful princess, and that I'll stay with you for a week and do
anything you want. Why won't you kiss me?" The engineer said,
"Look, I'm an engineer. I don't have time for a girlfriend,
but a talking frog, now that's cool.
************
Understanding Engineers - Take Ten:
There is a half glass of scotch on a table.
The Arts student says that it symbolises unfulfilled emotions.
The Science student starts calculating the exact percentage full.
Kenny, the Engineering student, goes up to the glass, drinks the
scotch and asks, "Hic, What's the question?"
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (8 of 9) [23/03/2005 05:49:13 p.m.]
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Some People Will Listen to anything.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-10
http://www.afralisp.com/newsletter/2003/2003-10.htm (9 of 9) [23/03/2005 05:49:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-11
=========================
Wednesday 23rd July 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Slippery when wet.
(so is mine!!)
=========================
The Front Stoep.
==============
It's been bleedin' cold here in the desert.
15 degrees C during the day and down to 5 degrees C at night.
I had to switch over from beer to whisky 'cos the beer bottles
were too cold to hold!! We're out of winter now though and heading
towards spring so things should warm up very soon. In fact,
I've got a pair of Cape sparrows busy building a nest just outside
of my window - a sure sign that spring is on it's way.
If you keep quiet you should be able to hear them.
Couple of new things I've been working on for AfraLisp that
I should have up and running in the next week or so.
One is an HTML tutorial that I've been nagged to produce for
a long time now. Another is a drawing setup routine but using
dictionaries. Watch the site for details.
I'm also busy converting the AfraLisp Tutorials to HTML Help format.
Anyone interested? If you are, drop me a line and I'll send you the
download link.
On a slightly different note, are you look for a simple Document
Management System geared up for AutoCAD, with a file viewer that
views most file types including AutoCAD AND Microstation drawings,
AND is also FREE?
If you are, have a look at this application from Oasys Columbus :
http://www.oasys-software.com/product/dm/columbus/
Well worth the download time.......
==========================
Pearls of Wisdom
===============
Above all else -- sky.
===============
***New on AfraLisp***
AutoCAD and Binaries
===================
By Stig Madsen
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (1 of 7) [23/03/2005 05:49:14 p.m.]
This document will try to shed some light on binaries,
bitcoded values in AutoCAD and the functions provided
by AutoLISP: logand, logior, lsh and boole.
http://www.afralisp.com/lisp/binary_I.htm
Absolutely brilliant. Thanks Stig!
===================================
Coding
=======
Would you like a different type of screen menu?
Load and run this wee routine.
8 boxes will appear on your screen, each box corresponding
to Layers and Colours 1 to 8.
Select any box and see what happens.
;CODING STARTS HERE
;MENUPOP - based on coding by Ed Batson
(defun C:MENUPOP (/ pt y sz ct ndex npnt nlist lc
vh32 vh16 vctr vht vwd lstr lp vh cnt)
;-----------------------------------------------------
; Polar functions.
(defun @r (lp dst)(polar lp (* pi 2.0) dst))
(defun @l (lp dst)(polar lp (* pi 1.0) dst))
(defun @u (lp dst)(polar lp (* pi 0.5) dst))
(defun @d (lp dst)(polar lp (* pi 1.5) dst))
(defun @lr (lp dst)(polar lp (* pi 1.75) dst))
(defun @ur (lp dst)(polar lp (* pi 0.25) dst))
(defun @ul (lp dst)(polar lp (* pi 0.75) dst))
(defun @ll (lp dst)(polar lp (* pi 1.25) dst))
;---------------------------------------------
(setq old_blip (getvar "blipmode"))
(setvar "blipmode" 0)
(setq vctr (getvar "viewctr")
vht (getvar "viewsize")
vwd (* vht 1.30)
lctr (polar vctr pi (/ vwd 2))
lp (polar lctr (* pi 1.5) (/ vht 2))
lc lp
vh (/ vht 8)
vh16 (/ vht 16); 1/16 of view height
vh32 (/ vht 32); 1/32 of view height
)

(setq cnt 1)
(repeat 8
(setq lp lc)
(setq lp (@r lp vh32))
(grdraw lp (setq lp (@u lp vh16)) cnt)
(grdraw lp (setq lp (@r lp vh16)) cnt)
(grdraw lp (setq lp (@d lp vh16)) cnt)
(grdraw lp (setq lp (@l lp vh16)) cnt)
(setq lc (@u lc vh))
(setq cnt (1+ cnt))
)
(setq y (getvar "viewsize")
sz (getvar "screensize")
ct (getvar "viewctr")
pt (getpoint "\nSelect Layer : ")
nlist (- (cadr ct) (/ y 2.0))
npnt (- (cadr pt) nlist)
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (2 of 7) [23/03/2005 05:49:14 p.m.]
ndex (fix (/ npnt (/ y 8)))
)
(command "LAYER" "M" (itoa (1+ ndex)) "")
;----------------------------------------
(redraw)
(setvar "blipmode" old_blip)
(princ)
);defun
(princ)
;CODING ENDS HERE
==================
If you activate a command and that command has command line options, you can
right click and have those options appear on screen. Where is this info
being pulled from? I know how to modify the various POP menus inside of the
acad.mnu file for context sensitive objects, but I can't find where these
non-object menus live. I am specifically trying to locate where the right
click menus for real time pan/zoom live. Any help would be greatly
appreciated.
Jeff
====
Load and run this :
;CODING STARTS HERE
(defun c:rclick ( / result)
(initget 1 "C R L")
(setq result (getkword "Choose Shape to Draw : [Circle/Rectangle/Line]:"))
(cond ((= result "C")(command "CIRCLE" pause pause))
((= result "R")(command "RECTANG" pause pause))
((= result "L")(command "LINE" pause pause""))
);cond
(princ)
);defun
(princ)
;CODING ENDS HERE
When the command line prompts you for a "Circle/Rectangle/Line",
then is the time to "right click".
Did anything happen?
How did it happen?
Notice the "[" and the "]" surrounding the right click selections :
[Circle/Rectangle/Line]
You could also just "design" your own right click menu :
http://www.afralisp.com/vba/vbamenu2.htm
Happy??
========
Kenny
=======
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (3 of 7) [23/03/2005 05:49:14 p.m.]
Some right-click menu options like zoom orbit,zoom window,etc..
are stored in the Acadres.dll file as menu resources.
therefore are not customizable.
If you REALLY need to remove orbit option, take a look in
http://www.users.on.net/johnson/resourcehacker/
You can edit inside DLL's as shown in Kenny's article:
http://www.afralisp.com/vbaa/vbadll.htm
(in this article Kenny deals with BITMAP resources)
I tried to edit the MENU resources inside Acadres.dll
and it worked.(I just removed orbit option)
Obviously, first make a backup of the file.
Bye!
Andrea Costamagna
=================
Great newsletter, this week, Kenny, please read, more,
http://www.btlsp2000.com/page503.html.
...Bill
=====
Also from Bill.........
Thank's for the help with polyline vertices,
http://www.afralisp.com/lispa/lisp20.htm,
did the trick, although it took, some study.
Well worth it.
I fixed my "Txb". It takes a rectangular polyline
and constructs, another, of different dimensions
and equal area.
See "Txb", at, http://www.btlsp2000.com/page9.html.

Now, if you will help me with Complex Numbers,
so I can start creating fractals.

...Bill
======
In AutoCAD Release 14, every AutoLISP print function
(for example, print, princ) was automatically echoed
to the AutoCAD command line and was immediately visible.
In AutoCAD 2000 and later releases, the display driver
is buffering print messages until a return (/n or /r)
is encountered. As a result, messages may not be displayed
until a function completes. For example, in Release 14 the
following code issued the message "Wait. Program is busy..."
as soon as the princ statement was encountered:
(defun test()
(setq count 0)
(princ "\nWait. Program is busy...")
(while (< count 100000)
(setq count (1+ count)))
(princ "\nCounted: ")
(princ count)
(princ)
)
In AutoCAD 2000 and later releases, the "Program is busy"
message does not display until the next \n is reached,
following the while loop (and thus after the wait has already
occurred). To ensure that your message is displayed immediately,
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (4 of 7) [23/03/2005 05:49:14 p.m.]
add a \n or \r to the end of your print function calls. For example:
(princ "\nWait. Program is busy...\n")
===============================
Things Weird and Wonderful
========================
Would you like to open Explorer in the AutoCAD current Directory?
Try this :
(startapp "Explorer" (strcat "/n,/e,/root," (getvar "DWGPREFIX")))
Using Explorer Command Switches
==============================
As with many Windows applications, Explorer supports command-line
switches--optional parameters you include on the command line to
start Explorer set with certain options.
The easiest way to apply switches is to create a shortcut to Explorer
and include the switches on the shortcut command line.
The syntax for the Explorer command line follows:
explorer [/n] [/e][,/root,object][[,/select],subobject]
The command-line switches in this syntax example are as follows:
/n. Explorer always opens a new window, even if the specified folder
is already open (see the /root switch).

/e. Explorer uses Windows Explorer view.
If you specify a folder with the /root option and do not specify the
/e option, Explorer opens a standard folder window rather than the
Explorer window.

/root,object. This specifies the object to use as the root in the Tree pane.
By default, the desktop is the root object. To open an explorer view of only
one folder on a disk, specify the drive letter and folder path in place of
object.
To open Explorer with only the Windows directory displayed, for example, use
/root,c:\windows for this option.

/select. This option specifies that the parent folder specified by the
/root option is opened. If you also include the subobject option, Explorer
selects the specified object in the Contents pane but does not open the object.
To open \Windows as the root with the Command folder selected but not opened,
use the command line :
Explorer /e,/root,c:\windows,/select,Command.

subobject. Specifies the object to open in the Contents pane.
To open the Command folder, for example, use the command line :
Explorer /e,/root,c:\windows,Command.
Miscellaneous Rubbish that I almost Forgot
===================================
At times, your code may encounter character input that contains
leading zeros--especially when dealing with CSV or legacy
databases. To quickly strip these zeros while maintaining the
string's status as a string, try using the Format$() function,
like so:
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (5 of 7) [23/03/2005 05:49:14 p.m.]
Dim strNums As String
strNums = "012345"
strNums = Format$(strNums, "#")
The number symbol (#) tells VB to reformat the number without
any leading zeros.
================
A couple of sites with lot's of AutoLisp files,
all a bit dated but still useful :
PIRS On Line
http://www.insa.com/files.shtml
File Library
http://www.cadresource.com/library/index.html
=====================
The Back Stoep
=============
A woman was shopping at her local supermarket where she selected
a litre of milk, a carton of eggs, a litre of orange juice, a head
of romaine lettuce, a 5 kg can of coffee, and a 1 kg package of bacon.

As she was unloading her items on the conveyor belt to check out,
a drunk standing behind her watched as she placed the items in
front of the cashier.

He said, "You must be single."
The woman, a bit startled but intrigued by the derelict's intuition,
looked at her six items on the belt. Seeing nothing particularly
unusual about her selections she said, "Well, you know what,
you're absolutely correct. But how on earth did you know that?"

The drunk replied, "'Cause you're ugly."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Some People Will Listen to anything.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (6 of 7) [23/03/2005 05:49:14 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-11
http://www.afralisp.com/newsletter/2003/2003-11.htm (7 of 7) [23/03/2005 05:49:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-12
=========================
Wednesday 30th July 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
H lp! S m b d st l ll th v w ls fr m m k yb rd!
=========================
The Front Stoep.
==============
What a magnificent view from the platform.
I was in the process of composing a picture when I looked down.
I'm not sure what made me look down but what I saw almost "froze" me.
Three guys had appeared from nowhere, out of the bush and were approaching
the car with Hilary still sitting in it. My first thought was that they were
going to beg for food or something but then they approached directly and fast,
with the first guy pushing his head into the drivers window which was open
and the others going around to Hilary's side. I shouted at them but I could
see they meant business.
I found myself on the ground shouting to Hilary to get out of the car.
Hilary sprang out with my cell phone in her hand and the leader,
who a few moments ago had his head in the driver's window, came around to our
side and threatened us with a large what looked like a "home made" knife.
He threatened to kill us with the knife if we tried to stop them and also
demanded the cell phone that Hilary was still holding.
I told Hilary to give him the phone and move away from the vehicle.
We stood watching them load all they could carry into plastic boxes which
we had brought along to carry food and clothes in.
After what seemed forever the leader came back to face us and demanded
money. I told him we had none on us and that it was at the "hotel"
------------
Have you ever wondered what Africa is really like?
Have you ever wandered about Africa without a 4 x 4?
Terry Baker gives us an interesting, amusing and sometimes
sad and frightening insight into Southern Africa as he regales
us with his travel stories.
Pop into "Out of Africa" and have a great read :
http://www.augafrica.com/out_of_africa.htm
There are also some nice photographs.
=====================================
Pearls of Wisdom
===============
Thesaurus: ancient reptile with an excellent vocabulary.
===============
Bit of a busy week on AfraLisp.
Polyline Bulges
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (1 of 9) [23/03/2005 05:49:16 p.m.]
=============
By Stig Madsen.
"Bulges are something that women have (mostly to please the opposite
sex it seems) and something that guys try to get by placing socks
in strategic places. At least until they get older. Which is the time
they tend to develop bulges in not so strategic places.
In other words: bulges are all about curvature.
In AutoCAD, bulges are used in shapes and in arc segments of polylines.
This article only deals with polyline bulges, and because polyline bulges
are describing circular arcs, let's first look at the geometry of a
circular arc."
Read more on this fascinating subject here :
http://www.afralisp.com/lisp/Bulges1.htm
Thanks Stig, you are a Scholar and a Gentleman.
=============
And, I've finally managed to catch up on a bit of my back log :
"Set and Setq"
http://www.afralisp.com/lisp/set.htm
A closer look at two of the most "basic" Lisp functions.
"Controlling Complex LineTypes"
http://www.afralisp.com/lisp/ltype2.htm
Sometimes the text just doesn't fit right!!!
"Visual Lisp Sample Files"
http://www.afralisp.com/vl/addoc.htm
Additional documentation regarding the
Visual Lisp Sample files.
"Preserving Custom Toobars"
http://www.afralisp.com/lisp/ptools.htm
One day my custom toolbars are there.
The next, they're gone!!!!
In AutoCAD 2004, Express Tools are again part of the standard
AutoCAD installation. For some reason though, certain of the
Express Tools functions are only accessible through the command
line and are not part of the Express Tools pull down menu.
To rectify this, I have modified the AutoCAD Express Tools Menu
to include the Command Line functions.
You can download the "Enhanced Express Tools 2004 Menu" from here :
http://www.afralisp.com/lisp/express.htm
You can also download the "Enhanced Express Tools 2002 Menu" if you wish :
http://www.afralisp.com/lisp/express2002.htm
=================================
Coding
=======
Entering Edit Boxes
Dialog boxes have many different kinds of visual means
of showing and/or editing information. These are called tiles.
Tiles, in effect, have attributes (properties).
The tile attributes define the way tiles might react or may be
shown by default. Some attributes can be defined in the driving
source code (AutoLisp) and others in the dialog source code (DCL).
Attributes can also define the size or shape of tiles.
The attribute that we will discuss to allow the enter key to act as
the "OK" button is the "allow_accept" attribute.
This particular tile attribute is always defined in the DCL file.
The DCL Coding shown below is the typical syntax for an edit box :
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (2 of 9) [23/03/2005 05:49:16 p.m.]
: edit_box {
label = "some_label";
allow_accept = true_or_false;
width = tile_width;
edit_width = length_of_edit_box;
edit_limit = edit_limit_of_edit_box;
key = "key_name_for_driving_source_access";
mnemonic = "alt_key_for_easy_jump";
}
Everything in between the braces { } is the edit box attributes.
The "allow_accept" attribute shown above shows true_or_false.
To set an edit box to allow the enter key to act as the "OK" button
set the "allow_accept" attribute to be equal to true.
If the attribute does not exist it may be added to the DCL file.
Note: Omitting the "allow_accept" attribute in dialog control syntax
will leave the tile at "allow_accept = false" by default.
Here's a practical example.
TRAJ2 : dialog {
label = "Conveyor Trajectory";
: edit_box {
label = "&Velocity (m/s)";
key = "VEL";
edit_width = 5;
allow_accept = true;
}
: edit_box {
label = "&Radius of Pulley (m)";
key = "RA";
edit_width = 5;
allow_accept = true;
}
: edit_box {
label = "&Angle of Incline";
key = "INC";
edit_width = 5;
allow_accept = true;
}
: edit_box {
label = "&Depth of Material (mm)";
key = "DEP";
edit_width = 5;
allow_accept = true;
}
ok_cancel ;
:text_part {
label = "Designed and Created";
}
:text_part {
label = "by Kenny Ramage";
}
}
Save this as TRAJ2.DCL. Now for the AutoLisp coding :
;CODING BEGINS HERE
(defun C:TRAJ2 ()
(setq V 1.5
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (3 of 9) [23/03/2005 05:49:16 p.m.]
R 0.3
ang 8.0
MD 75.0
);setq
(setq dcl_id (load_dialog "TRAJ2.dcl"))
(if (not (new_dialog "TRAJ2" dcl_id))
(exit)
);if
(set_tile "VEL" "1.5")
(set_tile "RA" "0.3")
(set_tile "INC" "8.0")
(set_tile "DEP" "75.0")
(mode_tile "VEL" 2)
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
(action_tile
"accept"
(strcat
"(progn (setq V (get_tile \"VEL\"))"
"(setq R (get_tile \"RA\"))"
"(setq ang (get_tile \"INC\"))"
"(setq MD (get_tile \"DEP\"))"
" (done_dialog)(setq userclick T))"
)
)
(start_dialog)
(unload_dialog dcl_id)
(if userclick
(alert (strcat "Velcocity = " V "\n"
"Radius = " R "\n"
"Angle = " ang "\n"
"Material Depth = " MD))

);if

(princ)
);defun
(princ)
;CODING ENDS HERE
Save this as TRAJ2.LSP. Now load and run it. A dialog should appear.
Change any of the values in the edit boxes.
Now, whilst still in the edit box, press your "Enter" key.
The dialog closes and the rest of the program runs.
When you press the "Enter" key, because the edit box
tiles attribute "allow_accept" is set to "true", the coding for the
tile which has the attribute "is_default" (the "OK" tile) is triggered.
This attribute also specifies whether a particular tile can be
double-clicked - a List Box for example :
http://www.afralisp.com/lispa/lisp49n.htm
=======================
Try this out :
//DCL CODING STARTS HERE
map : dialog {
label = "Image Tiles and Buttons";
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (4 of 9) [23/03/2005 05:49:16 p.m.]
: image_button {
key = "grid";
aspect_ratio = 0.5;
width = 30;
color = -15;
}
ok_only;
}
//DCL CODING ENDS HERE
Save this as Map.dcl
And now the AutoLisp Coding :
;CODING STARTS HERE
(Defun C:Map (/ dcl_id)
(setq dcl_id (Load_Dialog "map")) ; Load the DCL file
(If (Not (New_Dialog "map" dcl_id)) ; Display the dialog
(Exit))
(lgm:grid "grid" 10 5) ; Draw the Grid
(Action_Tile "grid" "(callback_grid $key $x $y 10 5)") ; Define Callback
(Start_Dialog) ; Wait until done
(Princ) ; Exit Quietly
)
(Defun callback_grid (key x y cols rows / xs ys xr yr)
(Setq
xs (/ (DimX_Tile key) (Float cols)) ; pixels per column
ys (/ (DimY_Tile key) (Float rows)) ; pixels per row
xr (Fix (/ x xs)) ; selected column
yr (Fix (/ y ys)) ; selected row
)
(Start_Image key) ; paint the box red
(Fill_Image (fix (* xr xs)) (fix (* yr ys)) (fix xs) (fix ys) 1)
(End_Image)
)
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (5 of 9) [23/03/2005 05:49:16 p.m.]
(Defun lgm:grid (key cols rows / x y xs ys n)
(Setq
xs (/ (setq x (DimX_Tile key)) (Float cols)) ; pixels per column
ys (/ (setq y (DimY_Tile key)) (Float rows)) ; pixels per row
)
(Start_Image key)
(Setq n 0)
(While (<= n rows) ; draw the horizontal lines
(Vector_Image 0 (fix (* ys n)) x (fix (* ys n)) -18)
(Setq n (1+ n)))
(Setq n 0)
(While (<= n cols) ; draw the vertical lines
(Vector_Image (fix (* xs n)) 0 (fix (* xs n)) y -18)
(Setq n (1+ n)))
(End_Image)
)
(princ)
;CODING ENDS HERE
Save this as Map.lsp.
Load and run it to see what happens.
===============================
Would you like a little routine to test your dialogs?
;CODING STARTS HERE
;;; LOADDCL.LSP
;;; Loads, displays, activates and unloads a dialog box of
;;; the same name. Used to verify dialog box design.
(defun C:LOADDCL (/ DCL_ID DLBNAME)
(setq DLBNAME (getstring "\nDCL File Name : "))
(if (findfile (strcat DLBNAME ".DCL"))
(progn
(setq DCL_ID (load_dialog DLBNAME))
(if (not (new_dialog DLBNAME DCL_ID)) (exit))
(action_tile "accept" "(done_dialog)")
(action_tile "cancel" "(done_dialog)")
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (6 of 9) [23/03/2005 05:49:16 p.m.]
(start_dialog)
(unload_dialog DCL_ID)
);;progn
(alert
(strcat "Unable to display < " DLBNAME " > Dialog!"))
);;if
(princ)
)
(princ)
;CODING ENDS HERE
Save this as LoadDcl.lsp
=====================
Things Weird and Wonderful
========================
CDGPurge
=========
Ever get drawings from outside sources that are full of layer filters,
page setups or layerstates? What about the junk you can't see,
like registered applications? You might be surprised at the amount
of "leftovers" a third party program may leave behind. CDG Purge
will purge items that the standard AutoCAD command won't - including:
Registered applications
Named layer filters
Layer States
Page Setups
Empty Groups
And, the most important thing,
it's FREE!!!!

http://www.caddevelopmentgroup.com/Downloads.htm
=============================================
Miscellaneous Rubbish that I almost Forgot
===================================
CAD Encoding - The Journal is focused on helping you to improve your
work environment with tutorials and working code examples written in,
and for, the most popular customizing languages for the major CAD software
programs and Microsoft Office products - Visual Basic for Applications,
Visual Basic, Visual C++, AutoLisp, Visual Lisp, and DCL.
http://www.cadencoding.com
========================
The Back Stoep
=============
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (7 of 9) [23/03/2005 05:49:16 p.m.]
An elderly man lay dying in his bed. In death's final agony. As he
started to slip away, he suddenly smelled the aroma of his favourite
chocolate chip cookies wafting up the stairs. He gathered his
remaining strength and lifted himself from the bed. Leaning against
the wall, he slowly made his way out of the bedroom, and with even
greater effort forced himself down the stairs. Gripping the railing
with both hands, he crawled downstairs defying the pull of Morpheus.
With laboured breath, he leaned against the door-frame, gazing into
the kitchen. Were it not for the immense pain caused by his extreme
exertions, he would have thought himself already in heaven for there
spread out upon waxed paper on the kitchen table - were hundreds of
his favourite chocolate chip cookies. Was it heaven? Or was it one
final act of heroic love from his devoted wife, seeing to it that he
left this world a happy man? Mustering one great final effort, with
tears in his eyes, he threw himself toward the table, landing on his
knees in a rumpled posture. His parched lips parted: the wondrous
taste of the sweet biscuit was already mentally tasting in his mouth,
seemingly bringing him back to life.
He felt renewed strength pulsate through his body. The aged and withered
hand trembled on its way to one lone biscuit at the edge of the table,
when..........
.....It was suddenly smacked with a spatula by his wife...... "Hands
off, " she said, "they're for the funeral."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If we are too loud, you are too old.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2003-12


http://www.afralisp.com/newsletter/2003/2003-12.htm (8 of 9) [23/03/2005 05:49:16 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-12
http://www.afralisp.com/newsletter/2003/2003-12.htm (9 of 9) [23/03/2005 05:49:16 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-13
=========================
Wednesday 6th August 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
printf("To C or not to C...that is the question\n");
=========================
The Front Stoep.
==============
Ahum, could I have your attention please!!!
This week on AfraLisp we have a couple of surprised guest speakers.
First up is Mr Scott McGlynn who is about to enlighten us all with
his outlook on the wonderful world of "PolyLines and Arcs."
http://www.afralisp.com/lisp/polyarc.htm
And secondly, and who I must say spared no expense to get here this week,
is Mr Glen Ryan, who has brought his "Plan" along for all us to have a
wee look and poke at :
http://www.afralisp.com/lisp/plan.htm
A big round of applause please Ladies and Gentlemen.
On a more humorous side, we also have a couple of contributions from
the house comics - "More Dinosaurs" and "Some Aussie Humour."
Both will be appearing in the small room just off to the left
of the Ladies loo :
http://www.afralisp.com/utterrubbish.htm
===============
And on behalf of the management of this here establishment,
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (1 of 7) [23/03/2005 05:49:17 p.m.]
I would just like to remind everyone that we are not snobs.
We accept drinks and money from anyone.
==================================
Pearls of Wisdom
===============
If one synchronized swimmer drowns, do the rest drown, too?
===============
Coding
=======
I am trying to figure out a way using Lisp or VBA to set
a drawing to "Read Only" after it has been opened.
Is there a way to do this?
Rick France
==========
Ooooh, that's a good one...........
Anyone care to enlighten us with an answer to this?
==========
Hello,
I have been trying to find out on how to just check if a certain block
(which I know its name) is already on a drawing or not. I am not sure, but I
was hoping you can help me with that. I have been reading your help files on
the internet, but I still could not put a routine (lsp) to check if a block
is already there.
I know I can check by typing a "rename" and see it there, but I wanted an
auto lisp routing so I can avoid the "redefine" block option when you create
a new block.
I would greatly appreciate any help from you. Thank you very much in
advance...
==========
Ahmed,
Have a look at this snippet of coding :
(setq t (tblsearch "BLOCK" "BLOCKNAME"))
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (2 of 7) [23/03/2005 05:49:17 p.m.]
If the Block exists, it will return the entity list :
((0 . "BLOCK") (2 . "BLOCKNAME") (70 . 0) (10 0.0 0.0 0.0)
(-2 . <Entity name: 40075288>))
If the block doesn't exist, it will return "nil".
=============================
Hey Kenny~
I was customized a button. But when I re-loaded it, It came up a smiley face.
So I tried the copy from acad.mns method, and pasted that section into the
.mnu file. but, when I re-load acad the button continues to come up a smiley face.
I think it is taunting me! Thanks for your help!! Maybe I should just make a
custom menu and load that....
Brian
======
The easiest way to get around this problem is to create yourself a partial menu
and a toolbar DLL. You can find step by step instructions on how to go about
doing this here :
http://www.afralisp.com/vbaa/vbadll.htm
================
Try this out :
Create a block consisting of a couple of lines and a circle with
a radius of 20. Now type this :
(setq e (entget (car (nentsel))))
Now pick the circle. AutoLisp should return something like this:
Select object: ((-1 . ) (0 . "CIRCLE") (5 . "282")
(100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbCircle")
(10 0.0 -1.51849 0.0) (40 . 20.0) (210 0.0 0.0 1.0))
Hey, Hang about. It's returned the entity list of the circle even
though it's part of a block!! Now type the following:
(setq d (assoc 40 e))
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (3 of 7) [23/03/2005 05:49:17 p.m.]
(setq e1 (subst '(40 . 50.0) d e))
(entmod e1)
Now REGEN the drawing.
Did you noticed what happened? The radius of the circle has change
even though it's part of a block. Not only that, it has also redefined
the block definition. In other words, every block in the drawing with
the same name would have changed.
Just a thought!!
==============
Want to create your own entity?
Normally, in AutoLisp you would draw a line like this:

(command "Line" pt1 pt2 "")
Now, create you own line by doing this:
(setq e '((0 . "LINE")(8 . "0")(10 50.0 50.0 0.0)
(11 100.0 100.0 0.0)))
(entmake e)
Just another thought!!
==================
Things Weird and Wonderful
========================
This HTML Code will allow you to open a Lisp file from a web page :
<html>
<head>
<title>Open Lisp Document</title>
<SCRIPT LANGUAGE=javascript>
<!--
function openLisp(theElement)
{
var Shell = new ActiveXObject("Shell.Application");
return Shell.ShellExecute(theElement.innerText);
}
//-->
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (4 of 7) [23/03/2005 05:49:17 p.m.]
</SCRIPT>
</head>
<body>
<a href=# onclick="return openLisp(this);">c:\test.lsp</a><p>
<a href=# onclick="return openLisp(this);">c:\test1.lsp</a>
</body>
</html>
============
Miscellaneous Rubbish that I almost Forgot
===================================
Would you like a customised message in your Status Bar?
(setvar "modemacro" (getvar "Cprofile"))
Will display the Active Profile
(setvar "modemacro" (getvar "LoginName"))
Will display the current users login name.
(setvar "modemacro" "Company Name")
Will display your company name.
And this will toggle your screen menu :
(setenv "ScreenMenu" (itoa (- 1 (atoi (getenv "ScreenMenu")))))
Put this in your AcadDoc and you can toggle your Middle Button :
;CODING STARTS HERE
(defun C:mb ()
(if (= (getvar "mbuttonpan") 0)
(progn
(setvar "mbuttonpan" 1)
(prompt "\nMiddle Button set to Pan.")
);progn
(progn
(setvar "mbuttonpan" 0)
(prompt "\nMiddle Button set to Osnap Menu.")
);progn
);if
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (5 of 7) [23/03/2005 05:49:17 p.m.]
(princ)
);defun
(princ)
;CODING ENDS HERE
==================
The Back Stoep
=============
Compliments of Mark Johnston :
A grouchy old man goes to the doctor for a physical. Naturally, his grouchy
old wife goes with him.
The man's ears, like most everything else, are not what they used to be so
his wife is along to hear for him.
The doctor does his usual work and then sits down with the two of them.
Doc says to the old man "To complete my examination I'll need three more
things. A blood sample, a urine sample and a stool sample."
The old man says "WHAT?"
His wife says to him "He wants your underpants."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If we are too loud, you are too old.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (6 of 7) [23/03/2005 05:49:17 p.m.]
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-13
http://www.afralisp.com/newsletter/2003/2003-13.htm (7 of 7) [23/03/2005 05:49:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-14
=========================
Tuesday 12th August 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Please remove your shoes before reading further.
=========================
The Front Stoep.
==============
We've been as busy as little bees on AfraLisp this week.
A whole two new tutorials plus we've got a cracker of an
article from Stig Madsen. Nuff said. read on.........
Can you remember way back to Issue No 2003-03
(http://www.afralisp.com/newsletter/2003/2003-03.htm)
when I asked how you went about setting up your AutoCAD
workstations?
Well, I've been looking into this subject and I've come
up with something that I'm sure will interest a lot of people.
Read on again..............
Custom Application Setup
=========================
You've written your AutoLisp and VBA routines, you've set up
your Block Libraries and your Custom Partial Menu is now complete.
Everything has been tested but now you hit another snag. You'd
like to distribute your custom application to other drawing
officers, or maybe you have 50 machines in your office that
you would like to install it on but you have one big problem.
Having to set up each individual machine is a real pain.
There are directories to be created, support paths to be added,
menu's to be loaded, etc, etc. And if you are distributing it
outside the office, you now have to try and put your setup into
words that can be clearly understood by the poor guy on the
other end.
In this tutorial we will look at automating the whole process.
We will make use of two remarkable software applications that
will make this a breeze, namely "Inno Setup" and "Acad Install".
"Inno Setup" will be used to install our required support files,
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (1 of 9) [23/03/2005 05:49:18 p.m.]
and "Acad Install" will do the job of configuring AutoCAD for us,
all with a lovely user interface. And they are FREE.
Pop along and create your own "Custom Application Setup".
http://www.afralisp.com/lisp/install1.htm
===============
Although "ACAD Install" was primarily written to work in
conjunction with "Inno Setup" it can also be used as a stand
alone application. I find it particularly useful for configuring
AutoCAD for a Network environment. In a Network environment
there is no need for a full blown installation application, as all
of the support files, menu's, lisp files, etc. are already on the
Network and are shared by each user. All we really require is a
method of configuring AutoCAD to suit our Network paths.
This is where "Standing Alone with Acad Install" comes into play.
http://www.afralisp.com/lisp/acadinst1.htm
===============
Scripting Objects
==================
by Stig Madsen
Windows provides several script engines, most of which are
primarily targeted for web development. Among the engines
are JScript, VBScript and PERL. When a script is run by
Windows, it is handled by Windows Script Host (WSH), which
invokes the appropriate script engine.
WSH itself provides access to a range of administrative
objects and services such as network drives, the registry
and printer connections. In this tutorial, Stig looks at
one particular object in WSH to retrieve information.
http://www.afralisp.com/lisp/script1.htm
========================
Pearls of Wisdom
===============
If Wile E. Coyote had enough money to buy all that Acme crap,
why didn't he just buy dinner?
===============
Coding
=======
Answers to:
"Setting a drawing to read-only after it's been opened."
I've got an answer. I'd don't know if it's the best answer though.
I used the shell command to do it. If you try to save the drawing,
it won't let you. Try it out.
A couple of flaws:
1. After running the command, it doesn't tell you in the AutoCAD
titlebar that it's in read-only mode. The drawing would have to
be re-opened for "-Read Only" suffix to appear.
2. If the drawing is brand new and hasn't been saved as anything,
it doesn't work. The drawing needs to be saved as a drawing file
before this will work.
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (2 of 9) [23/03/2005 05:49:18 p.m.]
Anyway, here's the code:
;CODING STARTS HERE
(defun c:set-read-only (/ dwgprfx dwgnm)
(setq dwgprfx (getvar "dwgprefix"))
(setq dwgnm (getvar "dwgname"))
(command ".shell" (strcat "attrib " dwgprfx dwgnm " +r"))
)
;CODING ENDS HERE
Just type set-read-only at the AutoCAD command prompt, and
the drawing that you are in will become read-only.
Steve Mattingly
===========
Morning Kenny,
Try this code
Open VBA in AutoCAD.
Create a form.
Add two buttons.
Paste in the following code
and then run the VBA program.
'CODING STARTS HERE
'**************************************
Private Sub CommandButton1_Click()
If ThisDrawing.ReadOnly Then
MsgBox "Autocad opened this file as read only." & Chr(10) & _
"The attribute Read-Only tag will be set."
Else
MsgBox ThisDrawing.FullName & " read only attribute set "
End If
SetAttr ThisDrawing.FullName, vbReadOnly
' Set read-only attributes.
End Sub
Private Sub CommandButton2_Click()
If ThisDrawing.ReadOnly Then
MsgBox "File was opened as a read only." & Chr(10) & _
"The attribute Read-Only tag will be removed." & Chr(10) & _
"Autocad will not allow the drawing to be save."
Else
MsgBox ThisDrawing.FullName & " read only attribute removed "
End If
SetAttr ThisDrawing.FullName, vbNormal
' Set normal attributes.
End Sub
'***********************************
'CODING ENDS HERE
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (3 of 9) [23/03/2005 05:49:18 p.m.]
Tom
===================
This got me thinking, so I replied to Tom :
"I'm just wondering if this coding could not maybe be embedded
in a drawing to force it to be read only. Just a thought."
===================
And, quick as a flash, he replied with :
I went to the help again and in the example I only had to add
one line and it works. This is the code I was thinking about.
Now it would only have to be embebded.
'CODING STARTS HERE
Public WithEvents ACADApp As AcadApplication
'Use with Application Event
Sub Example_AcadApplication_Events()
' This example intializes the public variable
'(ACADApp) which will be used ' to intercept
'AcadApplication Events
'
' The VBA WithEvents statement makes it possible
'to intercept an generic object with the events
'associated with that object.
'
' Before you will be able to trigger any of the
'AcadApplication events, ' you will first need to
'run this procedure.

' We could get the application from the ThisDocument
'object, but that would require having a drawing open,
'so we grab it from the system.
Set ACADApp = GetObject(, "AutoCAD.Application")
End Sub
Private Sub ACADApp_BeginOpen(FileName As String)
' This example intercepts an Application BeginOpen event.
'
' This event is triggered when a drawing is opened by AutoCAD.
'
' To trigger this example event:
' 1) Make sure to run the example that initializes
' the public variable (named ACADApp) linked to this event.
'
' 2) Use AutoCAD to open an existing drawing
' Use the "FileName" variable to determine which drawing file is
' being opened
MsgBox "A drawing is about to be loaded from: " & FileName
SetAttr FileName, vbReadOnly ' Set read-only attributes.
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (4 of 9) [23/03/2005 05:49:18 p.m.]
End Sub
'CODING ENDS HERE
==========
This works once the first drawing is opened.
Isn't help wonderful?
Tom
====
Hi Kenny,

I am a regular visitor of your very informative website.
I have been doing a lot of lisp for a long time but still
a long way to get to your level of skill. I've been trying
to do a lisp program that would let me draw a closed polyline,
computes its area then write it inside the polyline. To me
that's easy but I could not find a way to make the text
associative with the polyline wherein when you edit the
polyline, the text (area) would change automatically.
This is very useful at an early stage of planning when you're
trying to play with different layouts and at the same time
knowing how big those areas are. I would appreciate if you
could come up with a solution to this.

Keep up the good work and more power to you!

Michael C. Pamatmat
==================
Michael,
To achieve this, you would have to have a look at reactors,
and to be specific, object reactors. Have a look at this tutorial :
http://www.afralisp.com/vl/reactors3.htm
This should be a good starting point for you.
=============
And one from Luc Richard.
This function searches for a specific string within
an array of strings, return true if it's a member of
the array and false if not a member
'CODING STARTS HERE
Function Member(searchstr As String, searcharr As Variant)
On Error GoTo ErrorHandler
Dim K As Integer
K = 0
Do While K <= UBound(searcharr)
If searchstr = searcharr(K) Then
Member = True
Exit Function
End If
K = K + 1
Loop
On Error GoTo 0
Member = False
Exit Function
ErrorHandler:
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (5 of 9) [23/03/2005 05:49:18 p.m.]
Member = False
End Function
'CODING ENDS HERE
Thanks Luc, much appreciated.
===========
Dear Kenny,

I need to build an Isometric Circle and I just know
the point of the center and the diameter.
How to do this with vla-AddEllipse of Visual Lisp?
Could you help me?

Thank you.

Sebastio
=========
Things Weird and Wonderful
========================
Did you know, that you can test if a variable is a list
by using the following statement :
(= T (listp var))
Using the (listp) function, if the variable is a list
it will return T, if not it will return nil.
And to check if the variable is a Real or an Integer,
you can use the (numberp) function.
And to top it all off, if you want to check if the variable is a
positive or a negative number, use the (minusp) function.
I just thought you should know!!
===============
Want some "Country Technology"?
http://www.augafrica.com/humour/country_technology.htm
===============
And for all you budding coders out there,
this is for you and should be classified
as required reading :
"How To Write Unmaintainable Code"
http://www.afralisp.com/vbaa/unmain.htm
===============
Miscellaneous Stuff that I almost Forgot
===================================
Have you dropped into CAD Encoding lately?
http://www.cadencoding.com
Here's a few new additions.
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (6 of 9) [23/03/2005 05:49:18 p.m.]
(Beware of the link word wrap)
Stepping Over The Line
By Randall Rath
http://www.cadencoding.com//modules.php?
name=Sections&sop=viewarticle&artid=25
So you want to play with Access?!
By Cornfield
http://www.cadencoding.com//modules.php?
name=News&file=article&sid=49
SelectionSet Speed Testing
By SomeCallMeDave
http://www.cadencoding.com//modules.php?
name=News&file=article&sid=54
HotKeys
By Chuck Gabriel
http://www.cadencoding.com//modules.php?
op=modload&name=Downloads&d_op=viewdownloaddetails&lid=18
The Back Stoep
=============
A Good Pun is it's own Reword
=========================
Energizer Bunny arrested - charged with battery.
A pessimist's blood type is always b-negative.
Practice safe eating - always use condiments.
A Freudian slip is when you say one thing but mean your mother.
Shotgun wedding: A case of wife or death.
I used to work in a blanket factory, but it folded.
If electricity comes from electrons...
does that mean that morality comes from morons?
Marriage is the mourning after the knot before.
A hangover is the wrath of grapes.
Corduroy pillows are making headlines.
Is a book on voyeurism a peeping tome?
Dancing cheek-to-cheek is really a form of floor play.
Banning the bra was a big flop.
Sea captains don't like crew cuts.
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (7 of 9) [23/03/2005 05:49:18 p.m.]
Does the name Pavlov ring a bell?
A successful diet is the triumph of mind over platter.
Time flies like an arrow. Fruit flies like a banana.
A gossip is someone with a great sense of rumour.
Without geometry, life is pointless.
When you dream in colour, it's a pigment of your imagination.
Condoms should be used on every conceivable occasion.
Reading whilst sunbathing makes you well-red.
When two egotists meet, it's an I for an I.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Take off your shoes and hum along with us.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2003-14


http://www.afralisp.com/newsletter/2003/2003-14.htm (8 of 9) [23/03/2005 05:49:18 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-14
http://www.afralisp.com/newsletter/2003/2003-14.htm (9 of 9) [23/03/2005 05:49:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-15
=========================
Tuesday 19th August 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
If anybody can think of an English word that rhythms
with "purple", they are very, very clever.
=========================
The Front Stoep.
==============
This week was not only a wee bit cold, it also rained!!
Hey, 19mm in two nights. That's more than our annual rainfall.
At least it made it easier for my wife to pick up my beers bottle 'cos
normally I just chuck them out of my study window and she deals
with them whilst she's picking up the dog turds, and the remains of
dead cats that the dogs have got, and would be burglars that I have
got etc, etc. Because of the rain though, she's had it bloody easy 'cos
everything washed down into the pool which means that whilst she's
scooping out the leaves and twigs and dead frogs, and cats that
can't swim, and the next-door-neighbours-kids-that-can't-swim, she can
also deal with the rest of the rubbish at one time. Which makes me
pleased 'cos I like things neat and tidy around where I live.
Don't you agree?
Pearls of Wisdom
===============
Did you ever notice that when you blow in a dog's face,
he gets mad at you, but when you take him on a car ride,
he sticks his head out the window?
===============
Coding
=======
Kenny,
Thanks for the great newsletter. I always learn something and get a
smile from it.
I have a little routine here that draws isocircles in response to
Sebastio's question in the last letter.
;CODING STARTS HERE
(defun c:isocircle(/ PtCenter isoRad isoPlane Beta Theta Ratio eccent
Temp1 Temp2 AxisMajor PtOrigin
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (1 of 10) [23/03/2005 05:49:20 p.m.]
AxisEndPt varOrigin VarCenter VarEndPt objMSpace
objEllipse)
(vl-load-com)
(setq PtCenter (getpoint "\nPick Center Point "))
(setq isoRad (getreal "\nEnter Radius "))
(initget 1 "Top Left Right")
(setq isoPlane (getkword "\nEnter Iso Plane (Top, Left, Right) "))
(setq Beta 0.5235983) ; 30 degrees in radians, needed for 30 deg
isometric projection
(setq Ratio 0.57735027) ; axis ratio for 30 deg projection
(setq Theta
(cond
((= isoPlane "Top") 0.0) ; 0 degrees
((= isoPlane "Left") 2.09439) ; 120 degrees
((= isoPlane "Right") 1.0471967) ; 60 degrees
)); end theta
(setq eccent (sqrt (- 1 (* ratio ratio)))); eccentricity
(setq Temp1 (- 1 (* eccent eccent (cos beta) (cos beta))))
(setq Temp2 (- 1 (* eccent eccent)))
(setq AxisMajor (/ isoRad (sqrt (/ temp2 temp1))))
(setq PtOrigin (list 0 0 0))
(setq AxisEndPt (polar PtOrigin theta axismajor))

(setq varOrigin (vlax-3d-point PtOrigin))
(setq varCenter (vlax-3d-point PtCenter))
(setq varEndPt (vlax-3d-point AxisEndPt))
(setq objMSpace (vla-get-modelspace (vla-get-activedocument
(vlax-get-acad-object))))
(setq objEllipse (vla-addellipse objMSpace varOrigin varEndPt Ratio))
(vla-move objEllipse varOrigin varCenter)
(vlax-release-object objEllipse)
(vlax-release-object objMSpace)
)
;CODING ENDS HERE
Cheers,
David Blackmon
aka SomeCallMeDave
===================
Would you like to list the files within sub-directories
of a particular directory?
;CODING STARTS HERE
(defun C:SEARCHFOR (/ foundfiles folder fn)
(defun filesearch (fld filename / fld fn found flst lst)
(cond ((setq flst (vl-remove ".."
(vl-remove "." (vl-directory-files fld))))
(setq lst (mapcar (function (lambda (n)
(if (= (substr fld (strlen fld) 1) "\\")
(strcat fld n)(strcat fld "\\" n))))
flst)
)
(foreach fd lst
(cond ((vl-file-directory-p fd)
(filesearch fd filename))
(T
(cond ((wcmatch fd filename)
(setq found fd
foundfiles
(cons found foundfiles)
)
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (2 of 10) [23/03/2005 05:49:20 p.m.]
(princ found)
(terpri)))))
)
)
)
)
(setq folder (getstring "\nStart in folder: ")
fn (getstring "\nFile to search for: ")
)
(if (= folder "")(setq folder (getenv "systemDrive")))
(cond ((and folder (/= fn ""))
(filesearch folder fn))
)
(princ (strcat "\n" (itoa (length foundfiles)) "
files found"))
(princ)
)

;CODING ENDS HERE
For example, wanna know how many lsp files you have?
Command: SEARCHFOR
Start in folder: C:\\ACAD2004
File to search for: *.lsp
C:\ACAD2004\Sample\Database Connectivity\CAO\caotest.lsp
C:\ACAD2004\Sample\VisualLISP\activex\vla-tst.lsp
C:\ACAD2004\Sample\VisualLISP\External\propagate.lsp
C:\ACAD2004\Support\sample-profile-util.lsp
C:\ACAD2004\Tutorial\VisualLISP\Lesson1\gpmain.lsp
C:\ACAD2004\Tutorial\VisualLISP\Lesson2\gpmain.lsp
7 files found
Stig Madsen
============
And something in a similar vein - as Dracula said to his Cousin :
;CODING STARTS HERE
;DIRTXT - Directory Text - Allows you to print the contents
;of any directory from Notepad whilst in AutoCAD.
;Written by Russel W. Steffy
;
;Your acad.pgp file must have these lines in it:
; SHELL, , 0,*OS COMMAND: ,
; NOTEPAD, START NOTEPAD, 0,*FILE TO EDIT: ,
;
; FOLLOWING THIS FORMAT:
; <COMMAND NAME>,[<DOS REQUEST>],<BIT FLAG>,[*]<PROMPT>,
;
;<BIT FLAG> should be set to zero
;
;
;***ERROR HANDLING***
(defun dirtxterr (s)
(if (/= s "Function cancelled")
; If an error (such as CTRL-C) occurs
(princ)
(princ (strcat "\nError: " s))
; while this command is active...
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (3 of 10) [23/03/2005 05:49:20 p.m.]
) ;if
(princ "\n!!!Directory Text error!!!")
(setq *error* olderr)
;Restore old *error* handler
(princ)
) ;end dirtxterr
;***ERROR HANDLING***
(defun c:dirtxt
(/ olderr source winpath cnt 2cnt src sing_char dospath)
(setq olderr *error*
;Save old *error* handler
*error* dirtxterr
) ;Set new *error* handler
(setq source (getfiled "PICK FILE TO GET PATH"
(getvar "DWGPREFIX")
"*"
16
)
)
(princ)
(setq winpath source
dospath source
)
;***STRIP FILENAME FROM END OF STRING***
(while (/= "\\" (substr winpath (strlen winpath) 1))
(setq winpath (substr winpath 1 (- (strlen winpath) 1)))
) ;while NOT \
;***STRIP FILENAME FROM END OF STRING***
; PUT DOUBLE QUOTES AROUND FOLDER NAMES AND FILE NAME
(setq cnt 1
src (strlen dospath)
2cnt 0
)
(while (< cnt src)
(setq sing_char (substr dospath cnt 1))
(if (= sing_char "\\")
(progn
(if (>= 2cnt 1)
(progn
(setq
dospath (strcat (substr dospath 1 (- cnt 1))
"\"\\\""
(substr dospath (+ cnt 1) (- src cnt))
) ;strcat
) ;setq
(setq cnt (+ cnt 1)
2cnt (+ 2cnt 1)
)
) ;progn
(progn
(setq
dospath (strcat (substr dospath 1 cnt)
"\""
(substr dospath (+ cnt 1) (- src cnt))
) ;strcat
) ;setq
(setq cnt (+ cnt 1)
2cnt (+ 2cnt 1)
)
) ;progn
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (4 of 10) [23/03/2005 05:49:20 p.m.]
) ;if
) ;progn
) ;if
(setq src (strlen dospath))
(setq cnt (+ cnt 1))
) ;while
(setq dospath (strcat dospath "\""))
; PUT DOUBLE QUOTES AROUND FOLDER NAMES AND FILE NAME
;***STRIP FILENAME FROM END OF STRING***
(while (/= "\\" (substr dospath (strlen dospath) 1))
(setq dospath (substr dospath 1 (- (strlen dospath) 1)))
) ;while NOT \
;***STRIP FILENAME FROM END OF STRING***
(setq ap "AM"
cd (rtos (getvar "CDATE") 2 4)
mx (atoi (substr cd 5 2))
hr (atoi (substr cd 10 2))
mn (substr cd 12 2)
mo (nth mx
'(nil "JAN"
"FEB" "MAR"
"APR" "MAY"
"JUN" "JUL"
"AUG" "SEP"
"OCT" "NOV"
"DEC"
)
)
) ;setq
(if (>= hr 12)
(setq ap "PM")
)
(if (>= hr 13)
(setq hr (itoa (- hr 12)))
(setq hr (itoa hr))
)
(setq yr (strcat "DATE: "
mo
" "
(substr cd 7 2)
", "
(substr cd 1 4)
)
)
(setq tm (strcat winpath " " yr " TIME: " hr ":" mn " " ap))
(setq out_unit (open (strcat winpath "DIR.TXT") "w"))
;write dir.txt file
(write-line tm out_unit)
(write-line "" out_unit)
(close out_unit)
(command "SHELL"
(strcat "DIR " dospath "*.*/B/A:-d/O:n>>" dospath "DIR.TXT")
)
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (5 of 10) [23/03/2005 05:49:20 p.m.]
(command ".REDRAW")
(setq *error* olderr)
(command "NOTEPAD"
(strcat winpath "DIR.TXT")
)
(princ)
) ;end c:dirtxt
(princ)
;CODING ENDS HERE
==================
Kenny,
We are a small Electronics company who designs and stuffs Printed
Circuit Boards (PCB) and what I'm trying to create is a simple Bill of
Material lisp routine that when a drawing is open in autocad will
search all blocks with attribute tags that I have placed on the drawing.
Where I am having some troubles is some of my blocks are placed in model
space and some are placed in paper space.
The attribute tags that I want extracted are listed below. The brackets
give you an example
CATNO (007-0027)
DESCRIPTOR (U1)
QTY (This would be a tally of the total amout of CATNO found on the
drawing that match each other)
DESCRIPTION (74HC273)
MFG (PHILIPS MOTOROLA)
MFG_CATNO (74HC273N MC74HC273N)
Currently we are using a freeware program called "OpenOffice" in our
office and it would be nice to have the exported attributes load into
this program. OpenOffice can inport .xls, .csv, .txt plus other formats
that I know nothing about.
I want to thank you for your help in this matter. I have enjoyed reading
your online newsletters and have downloaded several codes from your
site. You are the only one I could think of who would know how to find a
solution to my problem.
Thank You
Mark Ruble
============
I would always get mad when someone would close a drawing and
not zoom it back out. I worked on a lot of big projects and sometimes would
have 15 tab of drawings.
This little gem will go through each tab, zoom out and do a Qsave.
It's also good to use if you are going to email someone your DWG's
See ya
John Michael Hivatal
;CODING STARTS HERE
(defun c:loz (/ echo lolst llnt lcnt lnam)
(setq echo (getvar "cmdecho"))
;_get echo var.
(setvar "cmdecho" 0)
;_set so commands will not show
(setq lolst (layoutlist))
;_get layout tabs list
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (6 of 10) [23/03/2005 05:49:20 p.m.]
(setq llnt (length lolst))
;_how many layout tabs
(setq lolst (reverse lolst))
;_flip list so first tab is at front of list
(setq lcnt 0);_counter
(while (< lcnt llnt)
;_loop through list
(setq lnam (nth lcnt lolst))
;_get each iten in list
(command "layout" "set" lnam)
;_go to the tab
(command "zoom" "e")
;_zoom extence
(setq lcnt (1+ lcnt))
;_add 1 to counter
);_end while
(command "qsave")
;_after all tabs have been zoomen out do a save
(setvar "cmdecho" echo)
;_reset echo back to original setting
(princ)
);_end defun say bye-bye
(princ)
;CODING ENDS HERE
==================
Things Weird and Wonderful
========================
Did you know that the AND function returns NIL if any of its arguments
are NIL, otherwise it returns T. The OR function returns T if any of its
arguments are T, otherwise it returns NIL.
Reading this carefully explains why, with no arguments, (and) is T,
but (or) is NIL.
This is true, I think.
And this???
(and (or))
Returns nil
Or :
(or (and))
Returns T
By the way, NOT returns T if its argument is NIL; and returns NIL if its
argument is T.
(not (and (or)))
Returns T
Huh!!
======
And on a similar note :
Kenny,
A note about your comments regarding the listp function. Nil is
considered a list, so (listp nil) will return T. I don't know about
others, but this one I didn't expect.
Mike Weaver
===========
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (7 of 10) [23/03/2005 05:49:20 p.m.]
Well done Mike, at least someone is awake!
So, we all agree that "nil" is considered by (listp) to be a list.
But, to determine whether it is empty or not, we need to look at
(boundp) which has only one argument which we will call "sym".
Now (boundp) returns T if "sym" has a value bound to it.
If no value is bound, or if it has been bound to nil, (boundp) returns nil.
If "sym" is an undefined symbol, it is automatically created and is
bound to nil.
Try this :
(setq a (list 2))
Returns: (2)
(setq b nil)
Returns: nil
(listp a)
Returns: T
Yep, it's a list.
(listp b)
Returns: T
Mmm, so you were right Mike, "nil" is also a list.
But.......
(boundp 'a)
Returns: T
It must contain something?
(boundp 'b)
Returns: nil
Now we know it's truly empty, although still a list.
Interesting hey??
But, before you run off crying for your Mother,
(boundp 'anotherlist)
Returns: nil
(listp anotherlist)
Returns: T
Hey, we've just created an empty list!!
Useful hey?
===============
Some brilliant photographs here :
http://www.worth1000.com/
=======================
"Cam Studio"
============
Other than being one of the best screen capturing applications
I've used, this magic program will also produce Streaming Web
Format files.
What the SWF Producer basically does is to convert AVI files to Flash
(.swf) files. It can convert almost all AVI files to Flash, including
those not produced with CamStudio.
http://www.rendersoftware.com/products/camstudio/index.htm
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (8 of 10) [23/03/2005 05:49:20 p.m.]
The beauty about the whole thing, is that it is not only Free,
it's also Open Source.
Yippeee!!!!
Miscellaneous Stuff that I almost Forgot
===================================
Want to add two lists together?
(setq list1 (list 1.1 2.2 3.3))
Would return: (1.1 2.2 3.3)
(setq list2 (list 4.4 5.5 6.6))
Would return: (4.4 5.5 6.6)
Therefore..........
(setq total (mapcar '+ list1 list2))
Would return : (5.5 7.7 9.9)
Now you know why it's called (map) (car).
We've had a few discussions on how to find the mid point of
two points. Here's a (mapcar) version - and it works in 3D!!
;CODING STARTS HERE
(defun c:mp ( / pt1 pt2 pt3)
(setq pt1 (getpoint "\nSelect First Point : ")
pt2 (getpoint pt1 "\nSelect Second Point : "))
(setq pt3
(mapcar '+ pt1
(mapcar '/
(mapcar '- pt2 pt1)
'(2.0 2.0 2.0)
)
)
)
(command "LINE" pt3 pause)
);defun
(princ)
;CODING ENDS HERE
==============
The Back Stoep
=============
A Breakthrough in Medical Research
==============================
Medical research has just discovered, that in the human body,
there is a nerve that connects the eyeball to the rectum.
It is to be called the anal-optic nerve.
It is found to be responsible for giving people a shitty
outlook on life.
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (9 of 10) [23/03/2005 05:49:20 p.m.]
If you don't believe it, and need proof, pull a hair from
your ass and see if it doesn't bring a tear to your eye.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Rock 'n Roll is Here to Stay!!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-15
http://www.afralisp.com/newsletter/2003/2003-15.htm (10 of 10) [23/03/2005 05:49:20 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-16
=========================
Tuesday 26th August 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
For Sale!!
Morning after pill for men.
It changes your blood type.
=========================
The Front Stoep.
==============
Yep, the time has arrived yet again.
Pre-Production for my bands fourth album has began.
What the heck has that got to do with coding Kenny???
Well lot's really!! You see, whether you are writing a program,
or writing a song, the same process needs to be followed.
Firstly you need an aim - you need to know what you are trying to write.
Rock album, Layer Manager, Country song, Drawing Setup routine????
Secondly, you need a method - AutoLisp, VBA, C++ - In music, digital,
analogue, live, acoustic, electric, etc.
Thirdly, you need time, commitment and money to do it - all of these
are normally in short supply.
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (1 of 18) [23/03/2005 05:49:22 p.m.]
Which brings me to the answer to your first question which you haven't
yet asked, but I know you will ask if I let you get a word in edgewise.
What is "Pre-Production" Kenny?
Pre-Production is simply the detailed planning of the three step process
mentioned above. If this is not achieved, don't even bother to start!!
==========
COND vs IF
==========
Written by David Hoekstra
"IF I had a nickel for every COND statement that
I ever wrote in lisp, I'd be rich!"
I see lots of lisp routines that use only the IF
function for conditional statements. I think this
has a lot to do with the fact that most new AutoLISP
programmers start out with IF, and never proceed on
to COND. I have talked to several lisp programmers
who state that they never learnt how to use COND,
and seemed to think it was useless.
COND is a thing of beauty, and let me tell you why.
http://www.afralisp.com/lisp/conif.htm
=================

Pearls of Wisdom
===============
The Earth is 98% full. Please delete anyone you can.
===============
Coding
=======
Please forgive the basicness of this question.
I am very new to this. I would like to be able to do
the following in a toolbar button :
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (2 of 18) [23/03/2005 05:49:22 p.m.]
Check to see if an xref is loaded, if not, load it, if so, reload it.
I would greatly appreciate any help.
TIA,
Jeff Berg
==========
Another way of drawing lines :
;CODING STARTS HERE
(defun C:ALINE (/ su_pt su_tmp su_list su_item )
(setq su_pt (getpoint "\nFirst Point : "))
(while
(setq su_tmp (getpoint su_pt "\nNext Point : "))
(setq su_list (append su_list (list su_tmp)))
)
(foreach su_item su_list
(entmake (list '(0 . "LINE")
(cons 10 su_pt)(cons 11 su_item))))
(princ)
);defun
(princ)
;CODING ENDS HERE
=================
Hi Kenny,
Here is an AutoLISP routine LBEND2.LSP in which I
first added a DCL interface, thanks to you.
You can put it on your site if you like.
Thanks once again.
KongYik
First the DCL coding :
//DCL CODING STARTS HERE
lbend2 : dialog {
label = "LOBSTER_BENDS 2" ;
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (3 of 18) [23/03/2005 05:49:22 p.m.]
:row {
:column {
label = "Pipe dia" ;

: popup_list {
label = "DN";
key = "dlb";
value = 5;
edit_width = 6;
}

: edit_box {
label = "OD";
key = "deb";
is_enabled = false;
edit_width = 7;
}

: toggle {
label = "user_defined";
key = "drb";
}

} //column1
:column {
label = "Bend_radius" ;
: popup_list {
label = "Factor";
key = "rlb";
value = 3;
edit_width = 6;
}

: edit_box {
label = "Radius";
key = "reb";
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (4 of 18) [23/03/2005 05:49:22 p.m.]
is_enabled = false;
edit_width = 7;
}

: toggle {
label = "user_defined";
key = "rrb";
}

} //column2
:column {
label = "Mitre numbers" ;

: popup_list {
label = "No";
key = "mlb";
value = 4;
edit_width = 6;
}

: edit_box {
label = "No";
key = "meb";
is_enabled = false;
edit_width = 7;
}

: toggle {
label = "user_defined";
key = "mrb";
}

} //column3
} //row
: row{ //label = " ";

: text {
label = "Select centre point of bend and two angles";
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (5 of 18) [23/03/2005 05:49:22 p.m.]
}


}

ok_cancel;

} //dialog
//DCL CODING ENDS HERE
Save this as LBEND2.DCL
And now the AutoLisp coding :
;CODING STARTS HERE
;;;KYBOEY PIPING
;;;Lobster_Bends2
;;;Mitre bends-selected & user's input
;;;16/07/2 9:58PM
;;27/01/3 11:02PM
;|
Draw lobster bends radially from the centre of the radius
by providing the angles of the bends from the first angle
to the second angle but avoid using 0(zero) for the second
angle.
Selected input from lists are for radius times norminal dia.
of pipes.
And drawn radially between the two angles counter-clockwise
starting at 0deg.
(User input uses dimensions as supplied. Diameter=as a real,
Bend_radius=as a real, Mitre_numbers=as an interger & decimals
are ignored.
Non numbers are disallowed and re-input are requested.)
My endeavour is to draw most graphics in polyline, so moving
and deleting will be easier, hence some of the lines overlap.
Everything are done in haste so lookout for the bugs!
Program by Kong Yik Boey
Comments and suggestions are always welcome.
Send to "kongyboey@yahoo.com.au"
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (6 of 18) [23/03/2005 05:49:22 p.m.]
Enjoy!
|;
(defun c:lbend2 ( / dcl_id dlbl rlbl mlbl dlbp rlbp mlbp debp
rebp mebp x y pnt1 an1 an2 rad0 rad1 rad2
pipedia mitrenum segment hsegment
p1 p2 p3 p4 pt1 pt2 pt3 pt4 ptl count smode
pipesizes radiuses userclick)

(setq dlbl '(" " "100" "150" "200" "250" "300" "350" "400" "450"
"500" "550" "600"))
(setq rlbl '(" " "1.5D" "3D" "4D" "5D"))
(setq mlbl '(" ""1""2""3""4""5""6""7""8""9""10""11""12"))
(setq pipesizes '(0.0 114.30 168.28 219.08 273.05 323.85
355.60 406.40 457.20 508.00 558.80 609.60))
(setq radiuses '(0.0 1.5 3.0 4.0 5.0))

(setq dcl_id (load_dialog "lbend2.dcl"))
;load dialog
(if (not (new_dialog "lbend2" dcl_id))
;test for dialog
(exit)
;exit if no dialog
);if

(start_list "dlb")(mapcar 'add_list dlbl)(end_list)
(start_list "rlb")(mapcar 'add_list rlbl)(end_list)
(start_list "mlb")(mapcar 'add_list mlbl)(end_list)
;----
(action_tile "drb" "(pick_opt1)")
(action_tile "rrb" "(pick_opt2)")
(action_tile "mrb" "(pick_opt3)")
(action_tile "deb" "(set_tile \"dlb\" \" \")")
(action_tile "dlb" "(set_tile \"deb\" \" \")")
(action_tile "reb" "(set_tile \"rlb\" \" \")")
(action_tile "rlb" "(set_tile \"reb\" \" \")")
(action_tile "meb" "(set_tile \"mlb\" \" \")")
(action_tile "mlb" "(set_tile \"meb\" \" \")")
;----
(defun pick_opt1 ()
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (7 of 18) [23/03/2005 05:49:22 p.m.]
(mode_tile "deb" (- 1 (atoi $value)))
(mode_tile "dlb" (- 1 (- 1 (atoi $value))))
);

(defun pick_opt2 ()
(mode_tile "reb" (- 1 (atoi $value)))
(mode_tile "rlb" (- 1 (- 1 (atoi $value))))
);

(defun pick_opt3 ()
(mode_tile "meb" (- 1 (atoi $value)))
(mode_tile "mlb" (- 1 (- 1 (atoi $value))))
);
;----
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, set flag
);action_tile

(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn(setq dlbp (atoi(get_tile \"dlb\")))"
;position of list selection
"(setq rlbp (atoi(get_tile \"rlb\")))"
"(setq mlbp (atoi(get_tile \"mlb\")))"
"(setq debp (atof(get_tile \"deb\")))"
"(setq rebp (atof(get_tile \"reb\")))"
"(setq mebp (atoi(get_tile \"meb\")))"
"(done_dialog)(setq userclick T))"
;close dialog, set flag
);strcat
);action tile
(start_dialog)

(unload_dialog dcl_id)
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (8 of 18) [23/03/2005 05:49:22 p.m.]
;unload
;;-----------
(if(or(and(= dlbp 0)(= debp 0.0))(and(= rlbp 0)(= rebp 0.0))
(and(= mlbp 0)(= mebp 0)))
(princ"\nNo dimensions provided - try again")

(progn ;1
(if userclick
;check O.K. was selected
(progn

(if (= dlbp 0)(setq pipedia debp)(setq pipedia
(nth dlbp pipesizes)))
(if (= rlbp 0)(setq rad0 rebp)
(if(and(= debp 0)(= rebp 0))
(setq rad0(* (atof(nth dlbp dlbl))
(nth rlbp radiuses)))
(setq rad0(* pipedia(nth rlbp radiuses)))
)
);if
(if (= mlbp 0)(setq mitrenum mebp)(setq mitrenum mlbp))
(setq pnt1(getpoint"\nSelect radial center of bend :")
;1st point
an1(getorient pnt1"\nFirst angle :")
;starting angle
an2(getorient pnt1"\nSecond angle :")
;total angle of bend
)
(if(= an2 0.0)(setq an2 (- (* pi 2) 1e-016)))
;help!!??
(setq
;pipedia(getreal"\nPipedia :")
;pipe dia
;rad0(getreal"\nBend radius :")
;bend radius
rad1(- rad0(/ pipedia 2))
;inside rad of pipe
rad2(+ rad0(/ pipedia 2))
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (9 of 18) [23/03/2005 05:49:22 p.m.]
;outside rad of pipe
;mitrenum(getint"\nNumber of mitres :")
;number of mitre
segment(/(- an2 an1)mitrenum)
;segment angle
hsegment(/ segment 2)
;half segment angle
p1(polar pnt1 an1 rad1)
;1st inside rad point
p2(polar pnt1 an1 rad2)
;2nd outside rad point
ptl(list p1 p2)
;define point list
an1(+ an1 hsegment)
;set angle of half segment for 3rd&4th point
count 1
;start count at 1
smode(getvar"osmode")
);setq

(repeat mitrenum
(setq pt1(polar pnt1 an1 (/ rad2 (cos hsegment)))
;outer point
pt2(polar pnt1 an1 (/ rad1 (cos hsegment)))
;inner point
pt3(polar pnt1 an1 (/ rad2 (cos hsegment)))
;outer point
ptl(append ptl (list pt1 pt2 pt3))
;add to point list
);setq
(if (/= mitrenum count) (setq an1(+ an1 segment)count
(1+ count)))
);repeat
;if there is another segment increase angle by
;segment angle and count

(setq p4(polar pnt1 (+ an1 hsegment) rad2)
;end points
p3(polar pnt1 (+ an1 hsegment) rad1)
;end points
ptl(append ptl (list p4 p3))
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (10 of 18) [23/03/2005 05:49:22 p.m.]
;add to point list
);setq

(repeat mitrenum
(setq pt4(polar pnt1 an1 (/ rad1 (cos hsegment)))
;return segment point
ptl(append ptl(list pt4))
;add to point list
an1(- an1 segment)
;decrease angle by segment angle & go back
);setq
);repeat
(setq ptl(append ptl(list p1)))
;finished at first point and point list

(setvar "osmode" 0)
(command "._pline" (foreach ptt ptl(command ptt)) )
;draw mitre bend
(setvar "osmode" smode)

);progn
);if userclick
);progn1
)if
;;------------
(princ)
);defun
(princ)
;CODING ENDS HERE
Save this as LBEND2.LSP
=======================
And this will convert all lines in a drawing
to polylines with a thickness of 0.5 :
CODING STARTS HERE
(defun C:LWID ( / sa ca ta enta ea enta pa cecho)
(setq cecho (getvar "cmdecho"))
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (11 of 18) [23/03/2005 05:49:22 p.m.]
(setvar "cmdecho" 0)
(setq sa (ssget "x" (list (cons 0 "LINE"))))
(if sa
(progn
(setq ca 0 ta (sslength sa))
(while (< ca ta)
(setq enta (ssname sa ca) ea
(entget enta) pa (cdr (assoc 10 ea)))
(command "pedit" (list enta pa)
"y" "w" "0.5" "x")
(setq ca (1+ ca))
);while
);progn
);if
(setvar "cmdecho" cecho)
(princ)
)
(princ)
;CODING ENDS HERE
Henry......
=================
=================
What do you call female Viagra?..... Jewelry
=================
Want the length of an arc?
'CODING STARTS HERE
Option Explicit
Sub ArcLength()
Dim objArc As AcadArc
Dim ArcLength As Double
Dim dblRad As Double
Dim dblAng As Double
Dim varPoint As Variant
ThisDrawing.Utility.GetEntity objArc, varPoint, "Select an Arc: "
dblRad = objArc.Radius
dblAng = objArc.TotalAngle
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (12 of 18) [23/03/2005 05:49:22 p.m.]
ArcLength = dblAng * dblRad
MsgBox "Arc length = " & ArcLength
End Sub
'CODING ENDS HERE
And the area?
'CODING STARTS HERE
Sub ArcArea()
Dim objArc As AcadEntity
Dim dblArea As Double
Dim varPoint As Variant
ThisDrawing.Utility.GetEntity objArc, varPoint, "Select an Arc :"
dblArea = objArc.Area
MsgBox "Area = " & dblArea
End Sub
'CODING ENDS HERE
==================
Things Weird and Wonderful
========================
Type the following two lines at the AutoCAD command prompt:
(setq message '(alert "Can You Remember Me?"))
(setq drawline '(command "line" pause))
Now do a few more things.
Anything, It doesn't matter.
Okay, now type this:
(eval message)
(eval drawline)
Me thinks that there is more to (setq) than meets the jaundiced eye!!
Comments??
===========
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (13 of 18) [23/03/2005 05:49:22 p.m.]
Miscellaneous Stuff that I almost Forgot
===================================
AfraLisp is proud to present : "Cartoon a Day"
http://www.afralisp.com/cartoon-a-day.htm
Compliments of Ted Goff
=====================
The Back Stoep
=============
Harry Potter goes to Autodesk
========================
By Terry Baker
AutoCAD was shown to the public at a computer show in the USA,
in an early form, for the first time in October 1982 and bore
the name of MicroCAD, so the story goes. The name was changed
to AutoCAD after it was found that another company was already
using the name MicroCAD.
I had started off on my own in 1979 doing designs and drawings
for other people that needed this service and was soon joined
by my brother, and shortly thereafter by 2 young guys who joined
as apprentice draftsmen. As business blossomed, more staff joined
and among the contractors that we hired was one young guy with the
name of Kenny. Yes, the very same Kenny Ramage who today runs the
Afralisp and AUGAfrica web sites.
Around about 1982 I was asked by one of my regular clients, Kevin Eaton,
if I had seen drawings being produced on computer. I think I burst out
laughing at the suggestion, but agreed to go to a demonstration on a SKOK
system. The demo of drawing a gearwheel, complete with teeth and spokes in
just a few minutes so impressed me that I started shopping around and looked
at another system, Calcomp, costing a whopping R500 000 [~US$70 000]. By this
time I was completely sold on CAD. All I had to do now was to find a CAD system
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (14 of 18) [23/03/2005 05:49:22 p.m.]
I could afford. (The SKOK system cost R120 000) [~US$16 500] I also took a keen
interest in computers and started shopping around for one for myself.
There were about 10 different makes of PC on the market and not one of them
compatible with the next.
The colour and resolution of the NCR DM5 looked the best to me and I bought
it, never for one minute doubting that I would find a CAD system to run on it.
The operating system was called CPM-80, I think.
Shortly after that, in June 1986, I took my first trip overseas to the UK for
a month, with my friend Hilary. What an experience! Whilst traveling around
the UK I visited every bookshop we came across, and any other shop that looked
as though it may sell computers, but they were far and few between. I ended up
buying a computer magazine in which there was a full page advert for AutoCAD.
After making enquiries I was directed to the distributor of AutoCAD in the UK.
Enter Harry Potter.
At this stage I must mentioned that I have just recently read the first Harry
Potter book by J. C. Rowling called "Harry Potter and the Philosopher's Stone".
I encourage you, if you have not as yet read this book to do so. It will make
my story a lot more interesting. Whilst reading this book I had this very strong
feeling of deja vu.
Hogarth is taking Harry Potter to London to do shopping for his kit before he is
sent off to Hogwarts, a boarding school for witches & wizards. Whilst walking
through London they reach their destination, a door, which is the entrance to
the place where they need to purchase the kit. The only problem is that it
appears to Harry that he and Hogarth are the only ones who are able to see
the door, which is the entrance to the shops.
Back to my story.
After speaking to the distributor of AutoCAD, I was instructed to visit Stage
One, which is what the distributor was called.
Hilary and I set off by Underground to Waterloo Station, and map in hand,
headed for the address give us, of Stage One.
Now, for such a full-page advert of a software package that every designer
would "kill" for, I thought we should see the shop, with neon lights blazing,
from at least a block or possible even two blocks away. When we reached the
address I looked at the map, re-looked at the address, twice, then went to
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (15 of 18) [23/03/2005 05:49:22 p.m.]
closest door to the address and asked the "Indian" gentleman if he knew where
Stage One, or AutoCAD, could be found. He had never heard of either but
suggested that we try the shop next door. That we did, with the same results.
In desperation, we tried the single door between both the aforementioned
shops and hey presto!, some large fellow by the name of Richard Handyside
introduced himself as the manager. Once inside, and having carefully to
negotiate piles of boxes, manuals, and 5-inch floppy disks, the shop seemed
to open up after a few meters of passage. Was this it? AutoCAD? Autodesk?
I don't think "Autodesk" had yet been born at this stage.
After a brief discussion with Richard and one of his colleagues, we left
with "Demo Copy" of AutoCAD 1.3 under arm, very happy to now return to
South Africa and get stuck into the CAD drawing business. I had a lot
more long distance chats to Richard Handyside, most went something like
"how do you draw a line an exact length and an exact angle?" and "How do
you snap to a line". "Snap! What's that?"
I remember buying an IBM PC when I returned from the UK because AutoCAD
only became available on the NCR DM5 a few months later and I could not wait.
I also remember that version 1.4 arrived on 2 floppy disks, one for the
program, and one for the drivers. Sample drawings were also on one of the
2 disks.
However, it was not long after this that my business changed from doing
drawings, to selling AutoCAD. (Sorry Kenny) My first customer was a
Mr. Gerald Gordon who was a lecturer in Architecture at the University
of Witwatersrand, and who was referred to me by Richard Handyside.
A few years later my company Infosoft merged with two other dealers,
CadArt and TechnoCAD, to form Afracad, the largest Autodesk dealer
in Africa at that stage. Does Afracad ring a bell? (think Afralisp?)
A few years later Autodesk's founder John Walker came to visit us in
South Africa. (Remind me to tell you about that one.)
P.S. If you old enough to remember any of this, or even if you're not,
drop me a line on :
mailto:tb@caesol.co.za.
Terry Baker
=====================
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (16 of 18) [23/03/2005 05:49:22 p.m.]
That's all folks,
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Shake off those blues!!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (17 of 18) [23/03/2005 05:49:22 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-16
http://www.afralisp.com/newsletter/2003/2003-16.htm (18 of 18) [23/03/2005 05:49:22 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-17
=========================
Tuesday 2rd September 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
For Sale!!
One leopard.
Absolutely spotless!!
=========================
The Front Stoep.
==============
Something different this week folks!!
How's about we all have a look around for the greatest bits of
SHORT coding that we can find. (or write for that matter.)
A great program doesn't have to be a long, conflated, discombobulated,
thesis. Short can also be beautiful.
A couple of examples :
Want to Zoom into your current cursor position?
;CODING STARTS HERE
(defun c:zc ( )
(setq point (cadr (grread 1)))
(command "zoom" "_c" point "")
(princ)
)
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (1 of 14) [23/03/2005 05:49:23 p.m.]
(princ)
;CODING ENDS HERE
=================
The following is published with kind permission
and a few threats on my part :
Has it ever bugged you trying to handle a
default option with (getkword)?
The usual method I've seen is to get the input,
and then handle the user's selection of the default,
resetting the variable if need be. Here is an example
of the "traditional" method :
(initget 0 "Length Width Depth Time")
(setq Inp (getkword "\nSpecify a dimension
[Length/Width/Depth/Time] <Time>: "))
(setq Inp (if Inp Inp "Time"))
Consider the alternative below however.....
(initget 0 "Length Width Depth Time")
(setq Inp (cond ((getkword "\nSpecify a dimension
[Length/Width/Depth/Time] <Time>: "))
("Time")))
By using (cond) to evaluate the return from (getkword),
if it is nil (which happens if the user hits enter for
the default), we can use the 2nd condition to return
the default value. Otherwise, (getkword) will return
something, so the first condition sets the value for
the variable.
The clever programmer can even develop a slick function
for general input.
Why?
Notice the repetitive elements in the example.
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (2 of 14) [23/03/2005 05:49:23 p.m.]
R. Robert Bell
===============
So come on y'all, get looking, get reading.
WE ARE WAITING.................
Pearls of Wisdom
===============
Local Area Network in Australia :
The LAN down under.
===============
Don't forget to visit :
"Cartoon a Day"
http://www.afralisp.com/cartoon-a-day.htm
Coding
=======
From last week :
"How can I check to see if an xref is loaded?"
This should get you started.
Here's how to list the Xrefs in your drawing :
;CODING STARTS HERE
(defun c:getxref ()
(vl-load-com)
;retrieve a reference to the Active Document
(setq activedocument
(vla-get-activedocument
(vlax-get-Acad-Object)))
;retrieve a reference to the blocks
(setq theblocks
(vla-get-blocks activedocument))
;create an empty list
(setq theList '())
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (3 of 14) [23/03/2005 05:49:23 p.m.]
;process each block
(vlax-for item theblocks
;check if it's an Xref
(setq yesxref
(vlax-get-property item 'isXref))
;if it is
(if (= yesxref :vlax-true)
;do the following
(progn
;get the Xref name
(setq ablock
(vlax-get-property item 'Name))
;store it in the list
(setq theList
(append (list ablock) theList))
);progn
);if
);vlax-for
;print the list
(princ theList)
);defun
(princ)
;CODING ENDS HERE
=================
Hello Kenny,
I am a recent subscriber on your site and newsletter.
I wonder if you've come across a couple of lisp routines.
This one I had many, many years ago that does not work on ACAD 2000 and
above. It was a freeze and thaw routine where you would select a layer
with freeze, and it would freeze that individual layer. In a given
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (4 of 14) [23/03/2005 05:49:23 p.m.]
AutoCAD session, you could freeze any number of layers using this tool
and before you ended the session you could THAW. That would that only
the layers that were frozen by the FREEZE command in that AutoCAD
session. Do you have a current 2000+ replacement for that?
My second request is for the civil engineers in the crowd. I need a
leader arrow that can read the ID of the point the arrow begins and
completes the coordinates in the text string. In other words....the X
value would be reported in the text with a station call (STA +0 __),
then the Y coordinate is reported in the second text string as the
elevation (EL. __).
Any help would be appreciated.
Best regards,
Jeff
=====
Want to determine where AutoCAD is installed?
;CODING STARTS HERE
(defun C:ThePath (/ product path)
;Finds where AutoCAD lives.
;Note: includes trailing backslash.
(setq product "ACAD.EXE"
path (findfile product))
(setq path (substr path 1
(- (strlen path)
(strlen product)))
);setq
);defun
;CODING ENDS HERE
=================
This WILL drive you nuts :
;CODING STARTS HERE
;;;GAME.LSP
;;;by Esko Suomalainen, FINLAND
;;;
;;;-----------------------------------------------------------
;;;DESCRIPTION
;;;
;;;This is a game for AutoCAD.
;;;
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (5 of 14) [23/03/2005 05:49:23 p.m.]
;;;Designed and implemented by Esko Suomalainen.
;;;
;;;Usage: Try to hit the target circle with the cursor!
;;;Program then calculates shots and time that had been consumed.
;;;Program is loaded and called by typing "GAME"
;;;
;;;-------------------------------------------------------------
(defun C:GAME( / luku osuma tarpt pt blold count cmdold result)
(setq blold (getvar "blipmode"))
(setvar "blipmode" 0)
(setq cmdold (getvar "cmdecho"))
(setvar "cmdecho" 0)
(redraw)
(setq *DIRANG* (/ (* (RND) 2.0 pi) 99.0) ntimes 0 hit nil count 0)
(command ".time" "reset" "") ; timer is started
(while (not hit)
; start looping with hit = nil
(if (= ntimes 7)
; target goes 7 steps to the same direction
(progn
; and then changes direction randomly
(setq tarpt (TARGET T)) ; direction is changed
(setq ntimes 0)
);endprogn
(setq tarpt (TARGET nil)); direction is NOT changed
);endif
(setq ntimes (1+ ntimes))
;;;
;;; Pointing device is checked with grread. If the first element of
;;; (grread 3) is 3, then pointer button is pressed and hit must be
;;; checked.
;;;
(if (= (car (setq pt (grread 3))) 3)
;selected point is needed later
(progn
(setq count (1+ count))
(grdraw (cadr pt) (polar (cadr pt) 0.0 0.05) 1)
; point is marked
(setq hit (CHKHIT (cadr pt) tarpt))
; function CHKHIT checks if it was
);endprogn
;a hit
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (6 of 14) [23/03/2005 05:49:23 p.m.]
);endif
);endwhile
(EXPL tarpt)
; Target is "exploded" with function EXPL
;;;
;;; Result is informed to player
;;;
(princ (strcat "\nYou needed " (itoa count) " shots!"))
(princ (strcat
" Your time was "
(rtos (* (getvar "tdusrtimer") 1e5) 2 0)
; timer is readed for time
" seconds."))
(setq result (rtos (- 1e6 (* count
(getvar "tdusrtimer") 5e7)) 2 0))
(if (< (atof result) 0)(setq result "0"))
; result is 0 or greater
(princ (strcat "\nYou got " result " points."))
;;;
;;Finish and return to ACAD
;;;
(setq *DIRANG* nil)
(setvar "blipmode" blold)
(setvar "cmdecho" cmdold)
(prin1)
)
;;;
;;;Moving the target, target is a circle
(defun TARGET (flag / oldpt newpt entg)
;;;
;;;If there is no target, one is drawn
;;;
(if (not (entlast))
(command ".circle" (getvar "viewctr") 0.17)
);endif
;;;
;;; The target is moved with entmod.
;;; If flag = T, then direction angle
;;; is recalculated with random number (from function RND).
;;;
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (7 of 14) [23/03/2005 05:49:23 p.m.]
(if flag
(setq *DIRANG* (+ (/ (RND) 100.0) *DIRANG*))
);endif
(setq oldpt (cdr (assoc 10 (entget (entlast)))))
; old insertion point
(setq newpt (polar oldpt *DIRANG* 0.2))
; new insertion point
;;;
;;; newpt must stay inside the limits, so it is checked and direction
;;; angle is changed to opposite direction, if necessary.
;;;Next time when this function is entered, the object
;;;comes back inside the limits.
(if(or
(>= (car newpt)(car (getvar "limmax")))
; first x-coordinates...
(<= (car newpt)(car (getvar "limmin")))
(>= (cadr newpt)(cadr (getvar "limmax")))
; ... then y
(<= (cadr newpt)(cadr (getvar "limmin")))
)
(setq *DIRANG* (+ *DIRANG* (/ pi 2.0)))
; direction is changed
);endif
;;;
;;; Moving is done with entmod
;;;
(setq entg (entget (entlast)))
(setq entg (subst (cons 10 newpt) (assoc 10 entg) entg))
(entmod entg)
newpt
;new target location is returned to calling function
)
;;;
;;; Random number calculation
;;; Returned number is between 1 - 99
(defun RND(/ rndnum)
;;;
;;; Random number is calculated from system clock. Also, sometimes
;;; number is modified with the x-coordinate of pointing device
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (8 of 14) [23/03/2005 05:49:23 p.m.]
;;; (to avoid regularity)
;;;
(setq rndnum (rtos (getvar "cdate") 2 10))
(setq rndnum (atoi (substr rndnum (- (strlen rndnum) 2) 2)))
(if (>= 60 rndnum 40)
; if rndnum is between 40 - 60, it is modified
(setq rndnum (fix (+ rndnum (car (cadr (grread 3))))))
);endif
rndnum
; random number is returned to calling function
)
;;;
;;;Checking of hits
;;;
(defun CHKHIT(pt1 pt2 / spt2 ept2)
;;;
;;; Function creates a "box" around pt2 and checks, if pt1 is inside
;;; the box.
;;;
(setq spt2 (polar pt2 (/ pi 4.0) 0.1))
(setq ept2 (polar pt2 (* (/ pi 4.0) 5.0) 0.1))
(if (and
(>= (car spt2) (car pt1) (car ept2))
(>= (cadr spt2) (cadr pt1) (cadr ept2))
)
T
; pt1 inside the box --> T returned
nil
; pt1 not in the box --> nil returned
);endif
)
;;;
;;;"Explosion" of the target
;;;
(defun EXPL(pt)
(grdraw (polar pt 0.7 0.3) (polar pt 3.8 0.5) 1)
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (9 of 14) [23/03/2005 05:49:23 p.m.]
(grdraw (polar pt 1.7 0.7) (polar pt 4.8 0.5) 1)
(grdraw (polar pt 0.2 0.2) (polar pt 3.3 0.8) 1)
(grdraw (polar pt 2.0 0.6) (polar pt 5.2 0.4) 1)
)
;CODING ENDS HERE
==================
Things Weird and Wonderful
========================
To store a "secret variable", enter the following
at the AutoCAD command prompt :
Command: -linetype
Current line type: "ByLayer"
Enter an option [?/Create/Load/Set]: C
Enter name of linetype to create: VARIABLE
Wait, checking if linetype already defined...
Descriptive text: Kenny's Secret Variable
Enter linetype pattern (on next line):
A,1.5,-2.5
New linetype definition saved to file.
Enter an option [?/Create/Load/Set]: L
Enter linetype(s) to load: VARIABLE
Linetype "VARIABLE" loaded.
Enter an option [?/Create/Load/Set]: [ENTER]
Command: (setq tbdata (tblsearch "LTYPE" "VARIABLE"))
((0 . "LTYPE") (2 . "VARIABLE") (70 . 0)
(3 . "Kenny's Secret Variable") (72 .
65) (73 . 2) (40 . 4.0) (49 . 1.5) (49 . -2.5))
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (10 of 14) [23/03/2005 05:49:23 p.m.]
Command: (setq var (cdr (assoc 3 tbdata)))
"Kenny's Secret Variable"
Mmmm, interesting!!!!
======================
Have you got parasites on your PC?
http://www.doxdesk.com/software/js/parasite.html
Are you sick and tired of your browser?
Have a look at Mozilla Firebird.
http://texturizer.net/firebird/features.html
Miscellaneous Stuff that I almost Forgot
===================================
Some interesting things on this site :
http://www.veign.com/
====================
You will find some "Sample Profile Utilities" here :
http://www.afralisp.com/vl/profile-samples.htm
=====================
The Back Stoep
=============
25 Signs You've Grown Up
=========================
1. Your house plants are alive, and you can't smoke any of them.
2. Having sex in a single bed is out of the question.
3. You keep more food than beer in the fridge.
4. 6:00am is when you get up, not when you go to bed.
5. You think Kenny's band BedRock is to loud.
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (11 of 14) [23/03/2005 05:49:23 p.m.]
6. You watch the Discovery Channel.
7. Your friends marry & divorce instead of hook up & break up.
8. You go from 130 days of vacation time to 14.
9. Jeans and a sweater no longer qualify as "dressed up."
10. You're the one calling the police because those damn kids
next door won't turn down the stereo.
11. Older relatives feel comfortable telling sex jokes around you.
12. You don't know what time the pubs close anymore.
13. Your car insurance goes down and your payments go up.
14. You feed your dog Herbal-life instead of McDonalds leftovers.
15. Sleeping on the couch makes your back hurt.
16. You no longer take naps from noon to 6pm.
17. Dinner and a movie is the whole date instead of the beginning
of one.
18. Eating a basket of chicken wings at 3am would severely upset,
rather than settle, your stomach.
19. You go to the drug store for ibuprofen and antacid, not condoms
and pregnancy tests.
20. A bottle of cheap wine is no longer "pretty good stuff."
21. You actually eat breakfast food at breakfast time.
22. "I just can't drink the way I used to," replaces,
"I'm never going to drink that much again."
23. 90% of the time you spend in front of a computer is for real work.
24. You no longer drink at home to save money before going to a bar.
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (12 of 14) [23/03/2005 05:49:23 p.m.]
And the NUMBER ONE sign that you've grown up................
25. You read this entire list looking desperately for one sign
that doesn't apply to you.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
Shake off those blues!!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2003-17


http://www.afralisp.com/newsletter/2003/2003-17.htm (13 of 14) [23/03/2005 05:49:23 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-17
http://www.afralisp.com/newsletter/2003/2003-17.htm (14 of 14) [23/03/2005 05:49:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-18
=========================
Tuesday 9th September 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
For Sale!!
One budgie going cheep.
=========================
The Front Stoep.
==============
Spring is officially here in Namibia. Our clocks have
moved forward to Summer Time and we are now one hour
ahead of GMT. My vegetable garden has been prepared
and we are looking forward to a bumper crop this year.
In fact, I've just finished eating a beautiful avocado
pear, fresh from the tree in my front garden. In a couple
of weeks I'll start picking mangoes, and my lemons are
hanging in clusters from their branches.
Oh, life is tough in Africa.
========
Oh by the way, on AfraLisp I've posted a listing of the
AutoCAD 2004 System Variables in PDF format :
http://www.afralisp.com/zip2/sysvar2004.ZIP
And an extract from the 2004 Customisation manual in regards
to Menus :
http://www.afralisp.com/zip2/2004MENU.ZIP
Pearls of Wisdom
===============
Sarchasm: The gulf between the author of sarcastic wit
and the person who doesn't get it.
===============
Coding
=======
Quite a few responses to last weeks challenge in regards
to short code.
In fact, there was so much I've decided to split them
over two Newsletters.
Not much though in the way of VBA code. (hint, hint.)
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (1 of 13) [23/03/2005 05:49:25 p.m.]
============
Hi Kenny
I like many others (I would imagine) use Zoom Marco's
extensively, below are the one's I've set-up and use
day-in day-out -
;Zoom All
;--------
(defun c:za ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "_ALL")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom Dynamic
;------------
(defun c:zd ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "_DYNAMIC")
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom Extents
;------------
(defun c:ze ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "_EXTENTS")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom Previous
;-------------
(defun c:zp ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "_PREVIOUS")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom Window
;-----------
(defun c:zw ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "_WINDOW")
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
(setvar "CMDECHO" Save_CmdEcho)
(princ)
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (2 of 13) [23/03/2005 05:49:25 p.m.]
)
;Zoom Out 0.5x
;-------------
(defun c:z5 ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "0.5x")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom Out 0.95x
;--------------
(defun c:z9 ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "0.95x")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
;Zoom In 2.0x
;--------------
(defun c:z2 ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 1)
(command "._ZOOM" "2.0x")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
And now for something completely different -
;Zero Fillet
;-----------
(defun c:F0 ( / Save_FilletRad Save_TrimMode)
(setq Save_FilletRad (getvar "FILLETRAD"))
(setq Save_TrimMode (getvar "TRIMMODE"))
(setvar "FILLETRAD" 0)
(setvar "TRIMMODE" 1)
(setvar "CMDECHO" 1)
(command "._FILLET")
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
(setvar "FILLETRAD" Save_FilletRad)
(setvar "TRIMMODE" Save_TrimMode)
(princ)
)
Will be interesting to see other routines that you post
within your newsletter, especially from the *guru's*
(yourself, Stig, Peter, Robert etc) as I honestly
think it will be very interesting to see how some short
code (maybe simple) can really save so much time...
Cheers, Mike
===========
See http://www.btlsp2000.com/page100.html#imp for
the routine I use to process defaults at input.
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (3 of 13) [23/03/2005 05:49:25 p.m.]
It's clunky, but it works.
I define a 2 dimensional input matrix, first.
(if (not imxxx)(setq imxxx (list 2 "Pick..."
(entlast) "Get..." (getvar "lastpoint") "Enter..." 1.0))).
Then, (setq imxxx (imp imxxx)).
...Bill
=====
The following was "stolen" from Randall :
'Accept Numbers only
'Use This in the keypress event of the Box
If KeyAscii < 45 Or KeyAscii > 57 Then
KeyAscii = 0
End If
=======
'Ignore Numbers
'Use This in the keypress event of the Box
If KeyAscii < 97 Or KeyAscii > 122 Then
If KeyAscii < 64 Or KeyAscii > 90 Then
KeyAscii = 0
End If
End If
=======
'Force to caps
'Use This in the keypress event of the Box
KeyAscii = AutoCap(Me.ActiveControl, KeyAscii)

'Force to caps
'This is the function
Public Function AutoCap(Tbox As TextBox, _
KeyAscii As MSForms.ReturnInteger) As Integer
AutoCap = KeyAscii
If KeyAscii > 95 And KeyAscii < 123 Then
AutoCap = AutoCap - 32
End If
End Function
=============
This is kind of short code.
It creates a rectangle based on the user's
width and height entered.
I used entmake instead of the rectang command so
the I would have to worry about setting and resetting
the cmdecho variable.
;CODING STARTS HERE
(defun c:rc (/ wid hgt ins1)
(princ "\nCreate a rectangle")
(initget 3) (setq wid (getreal "\nWidth: "))
(initget 3) (setq hgt (getreal "\nHeight: "))
(setq ins1 (getpoint "\nSelect insertion point: "))
(entmake
(list
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (4 of 13) [23/03/2005 05:49:25 p.m.]
(cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 4)
(cons 70 1)
(cons 10 (list (car ins1) (cadr ins1)))
(cons 10 (list (+ (car ins1) wid) (cadr ins1)))
(cons 10 (list (+ (car ins1) wid) (+ (cadr ins1) hgt)))
(cons 10 (list (car ins1) (+ (cadr ins1) hgt)))
)
)
(princ)
)
;CODING ENDS HERE
Hope this is short enough!
Steve Mattingly
==============
To open a drawing :
(command "vbastmt" (strcat "AcadApplication.Documents.Open "
(chr 34) filen (chr 34)))
;where filen is a qualified path and filename
And to close a drawing :
(command "vbastmt"(strcat "AcadApplication.Activedocument.Close") 0)
Will
============
This will add a prefix in font of all your Layer Names :
;CODING STARTS HERE
(defun C:PreLay ()
(vl-load-com)
(vlax-for x
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
(vl-catch-all-apply
'vla-put-name
(list x (strcat "Prefix-" (vla-get-name x))))
)
(princ)
)
;CODING ENDS HERE
Toni
=====
Kenny my man,
A couple of shorties :
FIXX
An Improved version to (FIX)
rounds numbers to either upper or lower value.
(AutoLISP native function FIX always rounds
numbers to the nearest lower integer).
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (5 of 13) [23/03/2005 05:49:25 p.m.]
;CODING BEGINS HERE
(defun fixx (realnum)
(if (> realnum (+ (fix realnum) 0.5))
(setq realnum (1+ (fix realnum)))
(setq realnum (fix realnum))
)
realnum
)
;CODING ENDS HERE
Examples :

(fixx 1.3) returns 1
(fixx 1.6) returns 2 (AutoLISP's FIX would have returned 1)
(fixx 1.50000001) returns 2
(fixx 1.49999999) returns 1
(fixx 1.49999999999) returns 1
(fixx 1.50000000001) returns 2
(fixx 0.0001) returns 0
(fixx 0.9999999) returns 1
================
SET_SLIDE
Easily activate a slide_image in a DCL
Syntax: (SET_SLIDE key path bg_color)
Elements :
key - STR - slide_image key name
path - STR - Full path of SLD file
color - INT - Background color
(Refer to AutoCAD DCL programming books for the right color )

;CODING STARTS HERE
(defun set_slide (key path color / x y fillx filly)

(setq x (dimx_tile key))
(setq y (dimy_tile key))
(start_image key)
(fill_image 0 0 x y color)
(slide_image 0 0 x y path)
(end_image)
(setq fillx (dimx_tile key))
(setq filly (dimy_tile key))
)
;CODING ENDS HERE

Example: (set_slide "icon1" "c:/myapps/stairs" 1)
=======================
Dave R.
=======
Kenny
Attached is a lisp program I have written to change
xref addressing from absolute to relative addressing.
For example, an xref like :
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (6 of 13) [23/03/2005 05:49:25 p.m.]
D:\PROJECTS\1234\CAD\ELEC\A1SHEET.dwg
If A1SHEET.dwg is in the same folder as the current drawing,
the xref path will be changed to :
.\A1SHEET.dwg
This makes xrefs drive independent so drawings can more easily
be shared. (It also makes xrefs project independent.)
;CODING STARTS HERE
; relpath.lsp
; C GREEN 1/6/02
; Change absolute Xref addressing to relative addressing.
;
; 4/6/03 - Bug fix - Now works OK if drawing and xref have
; different driver letters.
; .\ added to path if folder is a subfolder of the current
; drawing folder.
;
; Version 1.1
;
(defun c:relpath (/ a blk bref dfp dots dsf dsfl dt e n p
relpath xdn xfp xsf xsp xt)
(setvar "cmdecho" 1) ; Turn command echo off
(princ "Relpath Version 1.1 - Creating relative paths to XREFs...\n")
(setq dfp (getvar "dwgprefix")) ; Drawing prefix
;
(setq e (tblnext "block" t)) ; Retrieve 1st block in drawing
(while (/= e nil) ; Loop through all blocks in drawing
(setq bref (assoc 1 e))
(getstring "\nBreakpoint 1, press Enter to continue...");Erase_BP

(if (/= bref nil) ; Process if block is an xref
(progn
(setq blk (assoc 2 e)) ; Get xref reference name
(setq blk (cdr blk))
(setq xsp (cdr (assoc 1 e))) ; Get Xref save path
;
(setq n (strlen xsp)) ; Extract folder name of xref save path
(setq a (substr xsp n 1))
(while (/= a "\\")
(setq n (- n 1))
(setq a (substr xsp n 1))
)
(setq xfp (substr xsp 1 n)) ; Xref prefix
(setq xdn (substr xsp (1+ n))) ; Xref drawing name
;
; Continue processing only if xref and drawing drives letters
; are the same
(if (= (strcase (substr xfp 1 1)) (strcase (substr dfp 1 1)))
; Changed 4/6/03
(progn
(if (= xfp dfp)
(setq relpath (strcat ".\\" xdn))
; Set current folder if xref in same folder as drawing
(progn
(setq n 1)
(setq xt (substr xfp 1 1)) ; Get first character of xref path
(setq dt (substr dfp 1 1)) ; Get first character of drawing path
(while (= xt dt) ; Keep looping if common portion of name
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (7 of 13) [23/03/2005 05:49:25 p.m.]
(setq n (1+ n))
(setq xt (substr xfp 1 n)) ; Get next portion of xref path
(setq dt (substr dfp 1 n)) ; Get next portion of drawing path
) ; end while
;
(setq xsf (substr xsp n)) ; Remainder of xref path
(setq dsf (substr dfp n)) ; Remainder of drawing path
(setq dsfl (strlen dsf)) ; Length of remainder of drawing path
;
(setq dt (substr dsf 1 1))
; Get first character of remainder of drawing path
(setq n 0)
(setq p 1)
(repeat dsfl
(if (= dt "\\") ; Normal path delimiter
(setq n (1+ n))
)
(if (= dt "/") ; Alternative path delimiter (just in case)
(setq n (1+ n))
)
(setq p (1+ p))
(setq dt (substr dsf p 1))
) ; end repeat
(setq dots "")
(repeat n
(setq dots (strcat dots "..\\"))
; Loop to form number of relative steps up
) ; end repeat
(setq relpath (strcat dots xsf))
; Form the relative path to the xref
; Added 4/6/03
(if (/= "." (substr relpath 1 1))
; Final check to see if folder is a subfolder of current folder
(setq relpath (strcat ".\\" relpath)) ; Add current folder symbol
) ; end if
;
) ; end progn
); end if
(command "xref" "path" blk relpath) ; Rename old path with new path
) ; end progn
) ; end if
) ; end progn
) ; end if
(setq e (tblnext "block")) ; Retrieve next block in drawing
) ; end while
(setvar "cmdecho" 1) ; Turn command echo on
(princ)
)
; end of function
;CODING ENDS HERE
Craig Green
===========
From last week :
"I need a leader arrow that can read the ID of the point
the arrow begins and completes the coordinates in the text
string."
...........
Kenny,
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (8 of 13) [23/03/2005 05:49:25 p.m.]
Check out the leader lisp.
;CODING STARTS HERE
(defun c:TOW (/ Inspt NextPoint EndPoint Xpoint Ypoint)
(setq Inspt (getpoint "Select start point: "))
(setq Xpoint (car Inspt))
(setq Ypoint (rtos(cadr Inspt)))
(if (>= Xpoint 100.0)
(progn
(setq a (fix(/ Xpoint 100)))
(setq Xpoint (rtos(- Xpoint (* a 100))))
(setq Line1 (strcat "STA " (rtos a 5) "+" Xpoint))
)
(setq Line1 (strcat "STA 0+" (rtos Xpoint)))
)
(command "leader"
Inspt

pause
pause
""
Line1
(strcat "TOW EL=" Ypoint)
""
)
)
(defun c:TOLC (/ Inspt NextPoint EndPoint Xpoint Ypoint)
(setq Inspt (getpoint "Select start point: "))
(setq Xpoint (car Inspt))
(setq Ypoint (rtos(cadr Inspt)))
(if (>= Xpoint 100.0)
(progn
(setq a (fix(/ Xpoint 100)))
(setq Xpoint (rtos(- Xpoint (* a 100))))
(setq Line1 (strcat "STA " (rtos a 5) "+" Xpoint))
)
(setq Line1 (strcat "STA 0+" (rtos Xpoint)))
)
(command "leader"
Inspt

pause
pause
""
Line1
(strcat "TOLC EL=" Ypoint)
""
)
)
(princ)
;CODING ENDS HERE
Jeff Fry.
========
Hi Kenny.

I've been searching the net for a 'dwg reference scanning wizard.
I have 15,000 documents (sorted by project folders).
There is a need to scan the 15,000 files (most in DWG 2000 format.)
And record which DWG file[s] is referenced to which DWG[s].

AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (9 of 13) [23/03/2005 05:49:25 p.m.]
My AutoLISP knowledge, isn't to that level yet.
Can you help?
Regards as Always,
A. Monforte
============
I am trying to extract dimension data...
actually dynamically link it to a spreadsheet.
Do you have any ideas???
I have a cabinet builder that wants to link
his drawings with a cutting list.....so that,
for example,when he changes the length of a
cabinet in the drawing, it will be
reflected in the list.....any ideas???

So far the only method I can think of is to add
a second dimension line,
then pull the dimension text over to the list
(which I have drawn up in the same drawing file.....
Appreciate any ideas you might have.
(I'm in Kelowna, B.C.)
Thank you
Gerry
======
Hi Kenny,
I really enjoy your newsletter, keep it coming.
I have two burning issues that I have been trying
to investigate to no avail.
When using Dialog boxes, in particular image buttons
on them, is there a way to load the image before the
dialog box appears on the screen. Some of my dialogs
that have a lot of image buttons on them (15 or so)
appear without images and then they appear after a
short pause. Is this a processor thing (my computer
is pretty new with fairly reasonable amounts of ram etc.)
or is there an order for the coding to speed up this
process or to pre-load the images.
My other question.
Have you seen yet any way to manipulate the "QLEADER"
command variables (straight arrow line or spline line
in particular-I use both on a regular basis).
The last time I looked into this it was not possible
to preset any features prior to running this command.
Thanks,
Kris de Jong
=============
Things Weird and Wonderful
========================
...looking in the mirror. She says to her husband,
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (10 of 13) [23/03/2005 05:49:25 p.m.]
"I look fat and ugly, pay me a compliment"
Husband says,
"Your eyesights spot on"
====================
Want a good FREE Spam Filtering program?
http://www.spampal.org/
========================
Miscellaneous Stuff that I almost Forgot
===================================
If you come across a drawing that always gives you errors,
is really large compared to the amount of visible entities,
or there is an indication that many blocks are there
that you cant see, then apply the following sequence:
1. Open the drawing. (Duh!!)
2. At the command prompt type "z" (for zoom) followed by "v"
(acquires everything visible)
3. Type "e" for erase, then enter.
4. Type "ALL", then enter.
5. Type "R" to remove the entities we wish to retain, then enter.
6. Window in the title block (if your title block is in modelspace,
otherwise just window all visible entities) and all lines within,
then enter.
7. Then purge the drawing and remove any unwanted block(s).
8. Then save.
And there you go.
===============
The Back Stoep
=============
Some wise thoughts :
1. Never, under any circumstances, take a sleeping pill
and a laxative on the same night.
2. If you had to identify, in one word, the reason why
the human race has not achieved, and never will achieve,
its full potential, that word would be "meetings."
3. There is a very fine line between "hobby" and
"mental illness."
4. People who want to share their religious views
with you almost never want you to share yours with them.
5. You should not confuse your career with your life.
6. Nobody cares if you can't dance well. Just get up and dance.
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (11 of 13) [23/03/2005 05:49:25 p.m.]
7. Never lick a steak knife.
8. The most destructive force in the universe is gossip.
9. You will never find anybody who can give you a clear and
compelling reason why we observe daylight savings time.
10. You should never say anything to a woman that even remotely
suggests that you think she's pregnant unless you can see an
actual baby emerging from her at that moment.
11. There comes a time when you should stop expecting other
people to make big deal about your birthday. That time is
about age eleven.
12. The one thing that unites all human beings, regardless of
age, gender, religion, economic status or ethnic background,
is that, deep down inside, we ALL believe that we are above
average drivers.
13. A person who is nice to you, but rude to the waiter,
is not a nice person.
(This is very important. Pay attention. It never fails.)
14. Your friends love you anyway.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
We Love Rock n' Roll......
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

AfraLisp Newsletter No 2003-18


http://www.afralisp.com/newsletter/2003/2003-18.htm (12 of 13) [23/03/2005 05:49:25 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-18
http://www.afralisp.com/newsletter/2003/2003-18.htm (13 of 13) [23/03/2005 05:49:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-19
=========================
Monday 15th September 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Anyone interested in a bargain?
I have a parachute, never opened, used once, small stain.
Offers?
=========================
The Front Stoep.
==============
Bit early, but I've got a heavy week with the band.........
Lot's and lot's of "shorties" this week. In fact, I've got enough to even
carry some over until next week. Please keep them coming though,
'cos eventually I'll be creating a "Shorties" section on AfraLisp and
I'm sure you would all like to be included.
Question? (well a few.)
How do you deal with your drawings once complete?
Do you check them?
How do you circulate them for comments/approval/signatures?
Do you store them electronically?
Do you keep hardcopies?
I'm basically interested in finding out what you do with the drawings
once the draughtsman/woman/other has completed them.
If you could spare a few minutes, let me know.
What's New on AfraLisp?
======================
AutoLisp Basics - Download in PDF format.
http://www.afralisp.com/zip2/autolisp_basics.zip
================
Not to be missed : ACCESSing AutoCAD
By Scott McGlynn
First installment
http://www.afralisp.com/vb/access.htm
=============
Pearls of Wisdom
===============
"The floggings will continue until morale improves."
===============
Coding
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (1 of 13) [23/03/2005 05:49:27 p.m.]
=======
And the "Shorties" continue...............
Hey Kenny, I got busy with stuff going on at work but here are a couple
of short lisp routines.
I have a set of routines that saves and recalls views to warp me to
different points in the drawing.
To save:
(DEFUN C:S1 ()
(COMMAND "-VIEW" "S" "1")
(PRINC)
)
To recall:
(DEFUN C:1 ()
(COMMAND "-VIEW" "R" "1")
(PRINC)
)
This routine turns on, thaws and sets the 0 layer current:
(defun c:0 ()
(command "-layer" "t" "0" "on" "0" "s" "0" "")
(command "color" "bylayer")
(command "linetype" "s" "bylayer" "")
(princ)
)
A tilemode toggle to switch back and forth from paper and model spaces:
(defun c:ti ()
(setq a (getvar "tilemode"))
(if (= a 0) (setvar "tilemode" 1) (setvar "tilemode" 0))
(princ "\nCreated by: Andrew W. Scanlon CD")
(princ)
)
Lastly, since I deal a lot with areas I have a few routines that create
text labels noting the acreage and square feet.
Acreage:
(defun c:adt ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "cmdecho" 0)
(princ "\nCreated by: Andrew W. Scanlon CD")
(princ "\nSelect object: ")
(command "area" "o" pause)
(setq area (getvar "area"))
(setq result (/ area 43560))
(setq tx (rtos result 2 2))
(setvar "cmdecho" 1)
(command "text" pause pause pause (strcat tx " AC"))
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
Square feet:
(defun c:sfdt ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "cmdecho" 0)
(princ "\nCreated by: Andrew W. Scanlon CD")
(princ "\nSelect object: ")
(command "area" "o" pause)
(setq area (getvar "area"))
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (2 of 13) [23/03/2005 05:49:27 p.m.]
(setq txsf (rtos area 2 2))
(setvar "cmdecho" 1)
(command "text" pause pause pause (strcat txsf " SF"))
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
Acreage and Square feet:
(defun c:asd ()
(setq Save_CmdEcho (getvar "CMDECHO"))
(setvar "cmdecho" 0)
(princ "\nCreated by: Andrew W. Scanlon CD")
(princ "\nSelect object: ")
(command "area" "o" pause)
(setq area (getvar "area"))
(setq result (/ area 43560))
(setq txac (rtos result 2 2))
(setq txsf (rtos area 2 2))
(setvar "cmdecho" 1)
(command "text" pause pause pause (strcat txac " AC"))
(command "text" "" (strcat txsf " SF") "")
(setvar "CMDECHO" Save_CmdEcho)
(princ)
)
Hope these are helpful. Good work on the newsletter and keep them
coming. Good luck on your next album.
Thank you,

Andrew Scanlon
==============
Kenny,
I looked thru my VB code for "short code" that I could pass on. None of it
is generic enough, and would not make sense unless you worked here. Here is
some of my lisp code. Most of the really short code that I have has already
been covered by others. This is some of the other (fairly short) code that I
have found useful.
Have a good day,
Robert
=======
Swaps the position of two pieces of text;
;code starts here:
(defun c:swT ()
(setvar "cmdecho" 0)
(prompt "\pick first text line: ")
(setq ss1 (entget (car (entsel))))
(prompt "\npick second text line ")
(setq ss2 (entget (car (entsel))))
(setq old1 (assoc 1 ss1))
(setq old2 (assoc 1 ss2))
(setq new1 (assoc 1 ss2))
(setq new2 (assoc 1 ss1))
(setq ent1 (subst new1 old1 ss1))
(setq ent2 (subst new2 old2 ss2))
(entmod ent1)
(entmod ent2)
(princ)
)
;code ends here
Swaps the position of any two sets of entities:
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (3 of 13) [23/03/2005 05:49:27 p.m.]
;code starts here:
(defun c:swE (/ cmd ss1 ss1bp ss2 ss2bp)
(setq cmd (getvar "cmdecho")) (setvar "cmdecho" 0)
(prompt " Select 1st items to swap : ")
(setq ss1 (ssget))
(initget 1) (setq ss1bp
(getpoint "\nPick first base point: ")) (terpri)
(prompt "\nSelect 2nd items to swap places with 1st: ")
(setq ss2 (ssget))
(initget 1) (setq ss2bp (getpoint "\npick 2nd base point: "))
(setq a (getvar "osmode")) (if (<= 16384 a) (princ "OSnap OK")(setvar
"osmode" (+ 16384 a)))
(command ".move" ss1 "" ss1bp ss2bp ".move" ss2 "" ss2bp ss1bp
".move" ss1 "" ss1bp ss1bp)
(setq a (getvar "osmode")) (if (>= a 16384)(setvar "osmode" (- a 16384)))
(setvar "cmdecho" cmd) (princ)
)
;code ends here
Rotates the drawing horizontal or vertical:
;code starts here:
(defun c:rth ()
(command "rotate" "all" "" "0,0" "90")
(command "zoom" "e")
)
(defun c:rtv ()
(command "rotate" "all" "" "0,0" "-90")
(command "zoom" "e")
)
;code ends here:
This one increments numbers (numbers text). If you don't want a prefix or
suffix just hit space bar when prompted.
;code starts here:
(DEFUN C:CHNUM ()

(setq counter (getINT "\nStarting Number..."))


(setq counter (1- counter))
(IF (= NT NIL)(SETQ NT " ")(SETQ ONT NT))
(IF (= ST NIL)(SETQ ST " ")(SETQ OST ST))
(SETQ OST ST)
(SETQ NT (GETSTRING (STRCAT "\nPrefix:<" NT ">") t))
(IF (= NT "") (SETQ NT ONT))
(IF (= NT " ") (SETQ NT ""))
(SETQ sT (GETSTRING (STRCAT "\nSuffix:<" ST ">") t))
(IF (= ST "") (SETQ ST OST))
(IF (= ST " ") (SETQ ST ""))
(while (SETQ B (ENTGET (CAR (ENTSEL))))
(SETQ ER (ASSOC 0 B))
(SETQ ER1 (CDR ER))
(IF (/= "TEXT" ER1)(EXIT))
(setq counter (1+ counter))
(SETQ TX (STRCAT NT (ITOA COUNTER) st))
(SETQ C (ASSOC 1 B))
(SETQ D (CONS 1 TX))
(SETQ B (SUBST D C B))
(ENTMOD B)

)
(PRINC)
)
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (4 of 13) [23/03/2005 05:49:27 p.m.]
;code ends here.
================
Kenny,
Here is one of my fav lil functions. Nothing special,
just a mirror-delete function using ActiveX methods
but useful.
;CODING STARTS HERE
;;; Mirror Delete
;;; Invokes a mirror and delete of a selected object.
;;; Author: John (Se7en) Kaul
;;;**********************************
(defun c:md (/ x pt)
(vla-StartUndoMark (vla-get-activedocument
(vlax-get-acad-object)))
(vla-mirror
(setq x (vlax-ename->vla-object (car (entsel))))
(vlax-3d-point (setq pt (getpoint
"\nSpecify first point of mirror line:")))
(vlax-3d-point (getpoint pt
"Specify second point of mirror line:"))
)
(vla-delete x)
(vlax-release-object x)
(vla-EndUndoMark (vla-get-activedocument
(vlax-get-acad-object)))
(princ)
)
;CODING ENDS HERE
Later, 7
=========
And a couple of more from 7 :
;;; Slected-p
;;;------------------
;;; This function will test to see if something is selected on screen
;;;
;;; Returns: T or nil
;;;
;;; Author: John Kaul
;;;
;;; Usage: (if (not (Slected-p))
;;; (vlax-ename->vla-object (car (entsel))))
;;;===================================
(defun Slected-p ()
(and (cadr (ssgetfirst)))
)
======
;;; UNDO GROUPING FUNCTIONS
;;;========================
(defun vl-UndoBegin ()
(vla-StartUndoMark
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object)
)
)
)
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (5 of 13) [23/03/2005 05:49:27 p.m.]
(defun vl-UndoEnd ()
(vla-EndUndoMark
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object)
)
)
)
===========
;;; VLASEL
;;; This function mimics the AutoLISP entsel function.
;;; The difference is that the return value is a vla-object.
;;;
;;; Returned Value: A the selected item as a vla-object
;;; such as: #<VLA-OBJECT IAcadCircle 01b42790>
;;;
;;; Usage: (setq MyJunk (vlasel))
;;;================================
(defun vlasel (/ sel)
(if (setq sel (entsel))
(vlax-ename->vla-object (car sel))
)
)
;;;=============
;;; VLA-ENTLAST
;;;-------------
;;; This function mimics the AutoLISP entlast function
;;; -The difference is that the return value is a vla-object
;;;
;;; Return Value: The item as a vla-object such as:
;;; #<VLA-OBJECT IAcadCircle 01b42790>
;;;
;;; Usage: (setq MyJunk (vla-entlast))
;;;====================================
(defun vla-entlast (/ sel)
(if (setq sel (entlast))
(vlax-ename->vla-object sel)
)
)
============
I like "7ens" coding 'cos his intro's and explanations are about three
times as long as his coding!!!
============
And one that's a wee bit different. A "shorty" menu :
***POP11
[Info]
[$(eval,Drawing: $(getvar,dwgname))]$M=$(getvar,dwgname);
[$(eval,Date: $(edtime,$(getvar,date),MON DD""",""" YYYY))]+
$M=$(edtime,$(getvar,date),MON DD""",""" YYYY);
[$(eval,Day: $(edtime,$(getvar,date),DDD))]$M=$(edtime,$(getvar,date),DDD);
[$(eval,Time: $(edtime,$(getvar,date),H:MMam/pm))]+
$M=$(edtime,$(getvar,date),H:MMam/pm);
[$(eval,Elapsed: $(edtime,$(getvar,tdusrtimer),H:MM:SS))]+
$M=$(edtime,$(getvar,tdusrtimer),H:MM:SS);
[$(eval,Scale: 1:$(rtos,$(getvar,dimscale),2,2))]+
(strcat "1:" (rtos (getvar "DIMSCALE") 2 2));
Jorge
=============
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (6 of 13) [23/03/2005 05:49:27 p.m.]
And here's a couple from yours truly :
;CODING STARTS HERE
(defun c:al-eval ()
(vl-load-com)
(setq applic (vlax-get-acad-object))
(vla-eval applic (strcat "MsgBox \"Hello Everybody\"" ", "_
"vbInformation" ", " "\"AfraLisp\""))
(vla-eval applic (strcat "MsgBox \"Are You Fine?\"" ", "_
"vbQuestion" ", " "\"CAD Encoding\""))
(vla-eval applic (strcat "MsgBox \"Or, are you not Well?\"" ", "_
"vbCritical" ", " "\"VBA Expresso\""))
(alert "\nAnd this is the boring\nAutoCAD message box!!")
(princ)
);defun
(princ)
;CODING ENDS HERE
==========
;CODING STARTS HERE
(defun c:al-launchbrowserdialog ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-LaunchBrowserDialog util 'theurl "AfraLisp Browser"
"Open" "http://www.afralisp.com" "ACADBROWSER" 1)
(princ theurl)
);defun
(princ)
;CODING ENDS HERE
========
Answers to last weeks queries :
Kenny:
I read with great interest the latest instalment of the Afralisp
newsletter and spotted the program to set an xref's relative addressing.
Here's a less eloquent, but equally useful program I developed. The
catch is that all the files must be in the same folder, so it's not
"true" relative referencing. We use it when we archive our issued sets
of drawings and want to strip off the pathing to the network working
directories.
;CODING STARTS HERE
(defun c:stripxrefpath ()
; make a selection set of all blocks in the current
drawing
(setq selset (ssget "x" '((0 . "insert"))))
; count how many blocks there are
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (7 of 13) [23/03/2005 05:49:27 p.m.]
(setq setlength (sslength selset))
; set up a counter at 0 for the first block
(setq counter 0)
; go thru loop for once eack block
(repeat setlength
; get the first block
(setq ent1 (ssname selset counter))
; get the entity name of the block
(setq ename (entget ent1))
; get the real name of the block
(setq blockname (cdr (assoc 2 ename)))
; search block table for info on the block
(setq blockinfo (tblsearch "block" blockname))
; check if the block is an xref
(if (assoc 1 blockinfo)
; if the block is an xref, strip the path off the xref
(command "-xref" "path" blockname blockname)
)
; repeat for the next block
(setq counter (+ counter 1))
)
;exit quietly when done
(princ)
)
;CODING ENDS HERE
Keep up the good work!
Ron Albrecht
============
Kenny,
Here is a possible solution to the "Q-LEADER" question,
if you have not already provided it. Many of the variables
are held in the "xrecord" within the main dictionary called
"AcadDim". See "EXPRESSO CODE CAF" article by SMADSEN dated
01-07-2003. I had a question about them recently and found
my answer there.
http://www.vbdesign.net/expresso
Thanks,
Andrew C. Millard
================
In response to Kris de Jong's question about Qleader and being
able to use both spline arrows and straight arrows, I send in this short lisp.
It doesn't change the settings prior to drawing the leader but it is quick to
change it from straight to spline. I tried to incorporate the actual qleader
command into the lisp but I couldn't get it to work so you have to run it
after the qleader command is complete.
;----start coding---
(defun c:lfix ()
(setq ldr (car (entsel))
ldd (entget ldr))
(progn
(setq odr (assoc 72 ldd)
ndr (cons 72 1)
ldd (subst ndr odr ldd))
)
(entmod ldd)
(princ)
)
;-----end-----
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (8 of 13) [23/03/2005 05:49:27 p.m.]
I'm looking forward to next week's newsletter for a
better solution than this one.
Elise
=====
Hi Kenny
<snip>
Have you seen yet any way to manipulate the "QLEADER"
<snip>
Below comes courtesy of Robert Bell via the LISP Guild on the AUGI Web Site -
Here is an alternative function that does not require an external file
(written by one of the Express Tools team):
;|
qlset.lsp - example initialization of QLEADER settings
Frank Whaley, Autodesk
Two functions are included in this file:
(acet-ql-get)
Returns an association list containing the current QLEADER settings from the
Named Object Dictionary.
(acet-ql-get <alist>)
Sets the specified values for QLEADER settings from the given association
list.
Returns an association list containing the new values.
These functions can be used to examine the current QLEADER settings, or to
initialize the setting before using the QLEADER command.
For example, to use splined leaders and framed text:
(acet-ql-set '((65 . 1)(72 . 1)))
Both functions use the following group codes to identify QLEADER settings:
3: user arrowhead block name (default="")
40: default text width (default=0.0)
60: annotation type (default=0)
0=MText
1=copy object
2=Tolerance
3=block
4=none
61: annotation reuse (default=0)
0=none
1=reuse next
62: left attachment point (default=1)
63: right attachment point (default=3)
0=Top of top line
1=Middle of top line
2=Middle of multiline text
3=Middle of bottom line
4=Bottom of bottom line
64: underline bottom line (default=0)
65: use splined leader line (default=0)
66: no limit on points (default=0)
67: maximum number of points (default=3)
68: prompt for MText width (word wrap) (default=1)
69: always left justify (default=0)
70: allowed angle, first segment (default=0)
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (9 of 13) [23/03/2005 05:49:27 p.m.]
71: allowed angle, second segment (default=0)
0=Any angle
1=Horizontal
2=90deg
3=45deg
4=30deg
5=15deg
72: frame text (default=0)
170: active tab (default=0)
0=Annotation
1=Leader Line & Arrow
2=Attachment
340: object ID for annotation reuse
|;
(defun acet-ql-get (/ xr cod itm reply)
(if (setq xr (dictsearch (namedobjdict) "AcadDim"))
(progn
(foreach cod '(3 40 60 61 62 63 64 65 66 67 68 69 70 71 72 170 340)
(if (setq itm (assoc cod xr))
(setq reply (append reply (list itm)))))
reply)
'((3 . "")
(40 . 0.0)
(60 . 0)
(61 . 1)
(62 . 1)
(63 . 3)
(64 . 0)
(65 . 0)
(66 . 0)
(67 . 3)
(68 . 1)
(69 . 0)
(70 . 0)
(71 . 0)
(72 . 0)
(170 . 0))))
(defun acet-ql-set (arg / cur prm)
;; fetch current
(setq cur (acet-ql-get))
;; override per argument
(while arg
(setq prm (car arg)
arg (cdr arg)
cur (subst prm (assoc (car prm) cur) cur) )
;; handle DIMLDRBLK
(if (= 3 (car prm))
(setvar "DIMLDRBLK" (cdr prm))))
;; put back
(dictremove (namedobjdict) "AcadDim")
(setq cur (append '((0 . "XRECORD")(100 . "AcDbXrecord")(90 . 990106))
cur))
(dictadd (namedobjdict) "AcadDim" (entmakex cur))
(acet-ql-get))
;; load quietly
(princ)
R. Robert Bell, MCSE
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (10 of 13) [23/03/2005 05:49:27 p.m.]
AUGI Guild Moderator
www.AcadX.com
Cheers, Mike
============
Re: Dwg reference scanning wizard.
Kenny,
He should join the opendwg alliance, then download my program "Archive Them"
from www.vbdesign.net. He will need visual basic to modify the code a bit
and add recursion. But it should give him a good start.
Jeremie Schultz
==============
Hopefully the following link may help -
http://www.cadalyst.com/solutions/alispsols/0801als/0801als.htm
Cheers, Mike
============
Things Weird and Wonderful
========================
You gotta love a good beer slogan.............................
The latest Becks Beer advert in Scotland (displayed in pubs etc) is as
follows:
'YOU DON'T HAVE TO BE POSH TO SWALLOW BECKS'
Michael Perry
============
H3ll0 7h3r3. 50 y0u'v3 d3c1d3d 70 p4y 4 v1517 70 5n34k P34k h4v3 y0u?
Do you know what this means?
No!! Then pop along here and find out :
http://www.vbdesign.net/modules.php?name=Sneak_Speak
Miscellaneous Stuff that I almost Forgot
===================================
DCL Primer.
http://www.afralisp.com/zip2/dcl_primer.zip
=====
Batch Purge 2004.
http://www.afralisp.com/vba/bp2004.htm
=====
Basic Tool System Primer.
http://www.afralisp.com/lispb/toolr.htm
The Back Stoep
=============
A man and his wife are awakened at 3 o'clock in the morning by a loud
pounding on the door.
The man gets up and goes to the door where a drunken stranger, standing
in the pouring rain, is asking for a push. "Not a chance," says the husband,
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (11 of 13) [23/03/2005 05:49:27 p.m.]
"it is three o'clock in the morning".
He slams the door and returns to bed.
"Who was that?" asked his wife.
"Just some drunk guy asking for a push," he answers.
"Did you help him?" she asks.
"No, I did not, it is three in the morning and it is pouring outside!"
His wife said "Can't you remember about three months ago when we broke
down and those two guys helped us?" "I think you should help him, and you
should be ashamed of yourself!"
The man does as he is told, gets dressed, and goes out into the
pouring rain.
He calls out into the dark, "Hello, are you still there?"
"Yes," comes back the answer.
"Do you still need a push?" calls out the husband.
"Yes, please!" comes the reply from the dark.
"Where are you?" asks the husband.
"Over here on the swing!" replies the drunk.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
We Love Rock n' Roll......
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (12 of 13) [23/03/2005 05:49:27 p.m.]
Search
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-19
http://www.afralisp.com/newsletter/2003/2003-19.htm (13 of 13) [23/03/2005 05:49:27 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-20
=========================
Tuesday 23rd September 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
For Sale :
3 cows never bred.
Also 1 gay bull for sale.
=========================
The Front Stoep.
==============
Well I'm finally back home and can drink some decent beer instead
of the 'orrible South African stuff that tastes of chemicals.
By the way, the national drink of Namibia is a grape fruit schnapps
known as Pamulmoosen. Lovely stuff.
Anyway, long letter today so let's get on with it.........
Pearls of Wisdom
===============
If a man is standing in the middle of the forest speaking and there
is no woman around to hear him...is he still wrong?
===============
Remember these questions from last week?
How do you deal with your drawings once complete?
Do you check them?
How do you circulate them for comments/approval/signatures?
Do you store them electronically?
Do you keep hardcopies?
Firstly, here's what we do in my office :
Do you check them?
After the drawing is complete, a print is made, stamped for checking,
and then given to the Senior Design Draughtsman for allocation
to a dedicated Checker for that Project. We use the tried and tested method
of yellow pencil if correct and red if incorrect. We tried checking
electronically (red lining) but no one was happy with this as the drawing
is difficult to view. The computer of course is still used by the checker
to calculate trig, etc.
How do you circulate them for comments/approval/signatures?
A print of each drawing is circulated to all relevant stakeholders,
and authorities for comments/approval/laughter.
This could take place at various stages of the design.
Do you store them electronically?
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (1 of 12) [23/03/2005 05:49:29 p.m.]
All drawings and revisions are stored on the Network.
The Network is backup up to tape and then finally to platters.
On completion of a Project, a full set of drawings is given to
the "customer" in hardcopy and electronic format and also archived
on the Network. Each draughtsman has full access to all archives
unless security related.
Do you keep hardcopies?
Yep, on plastic for two main reasons.
One, for legal reasons all plastics are signed by the relevant
responsible persons.
e.g. Structural/Mechanical/Process Designer, Engineer, etc.
Two. We provide prints to our structural/mechanical workshops.
This could be up to 6 copies of each drawing. We find it cheaper
to make multiple copies of a plastic drawing on a plan printer
rather than using the plotters which can be a wee bit expensive
to run.
And here's some of your answers :
Do you check them?
Yes
How do you circulate them for comments/approval/signatures?
Varies to a degree, but Yes
Do you store them electronically?
Yes
Do you keep hardcopies?
Generally No, some may go to customers and/or vendors and
reduced size copies may be retained for some assorted purposes
and various lengths of time, but there is no "file" (so to speak) of
paper copies.
Titus B. Ruch
============
Hi Kenny,
I am working for an infrastructure construction company in the Netherlands.
This how the work goes inn our AutoCAD department.
We get jobs from other departments ( enviroment, advice "consulting" ,
directional drilling , etc ) Sometimes we get jobs from other branches or
even from other companies. The client decides if the drawing is OK or not.
We do not keep hardcopies. The files are on the network. There is an IT
department to take care of archieving.
We keep small hardcopies (A3 size) of sample drawings for our reference
and for the clients too.
If a job is done in a perfect way, I try to keep a second digital copy in my
SAMPLES directory.
The drawing which are older than 2 years are backed up on CD's. I have
made an Excel file with a VBA macro to add file names of the CD's and a
second macro to find files and on which CD each file is located.
greetings
Sherko
=======
How do you deal with your drawings once complete?
We keep a set of CAD files on our server in a project "As-Built"
folder once the project is complete and we remove the drawings from the
working folders that the CAD staff have access to.
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (2 of 12) [23/03/2005 05:49:29 p.m.]
Do you check them?
Almost always for as-built sets.
How do you circulate them for comments/approval/signatures?
We send hard copies or CAD files based on the clients request, but
always with an issue date on the drawing (ex. Issued for Owner's Use -
09-18-03, etc.).
Do you store them electronically?
Every issued set is kept in a separate archive folder for that
project.
Do you keep hardcopies?
No. We stopped doing that 2 years ago.
Ron Albrecht
============
Kenny,
Just a quick word on how we handle our drawings.
We save all of our drawings on a server while they are being worked on
and until the construction is complete or the record drawings are finished.
Then, once or twice a year, we go through all the finished projects, delete
any files that we deem unnecessary and burn the remainder to a CD.
We also save the final, stamped drawings (hardcopies), in a flat file.
Not sure why we need to save the hard copy other than for the original
stamp by the engineer but we do and we have a ton of them.
I thought that maybe the engineers got them out to look at them since
they don't have access to the electronic files but they don't.
Instead, they ask us to find it in the electronic archives and either plot it
out or they occupy our stations to look at it. Not sure why they don't install
an AutoCAD reader on their computers. They probably just need an excuse
to get out of their offices and come see our happy faces.
Keep up the good work,
Elise Bauman
============
Hi Kenny, Whassup!

About the "what shall we do with the finished drawings"
(reminds me of a song about a drunk or something.... ;-) ).

We generally work in projects for our waste treatment plants.
We write manuals for these installations which contain the drawings we
made (all on paper inside cardboard ring-files (you know what i mean, but
I can't find an English word right now).
We generally make 3 manuals (each manual is about 20-30 files big which
basically takes up about 3-5 metres of closet space). 1 for the customer,
1 version for ourselves which we try not to touch so it stays complete, and 1
we use for reference which can be harassed at will ;-). Sometimes customers
call us on the phone with problems so we have to play help-desk and say
"Have a look at page 267 of folder 11b of the manual"
We also keep the DWG files electronically stored on our network server.
Sometimes when we need to copy some stuff from another project (you know
the deal; you catch yourself thinking "oh yeah, didn't we already do somthing
like that somewhere back in 1998 or so....")

Hope this was what u wanted. Best regards,
George Bolssens
==============
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (3 of 12) [23/03/2005 05:49:29 p.m.]
Thanks to everyone who took the time to respond, and if you haven't
responded yet, please feel free to do so.
Coding
=======
The Shorties (continued)
=====================
;CODING STARTS HERE
;;;=============
;;; Get-EntSelcted
;;;-------------------------
;;; This function will offer a way for the programer to get an
;;; entity already slected by the enduser on the screen before the
;;; program took control. This program was intended for use in an
;;; ActiveX program. I have chosen not to use the "Pickfirst" method
;;; in accomplishing this task because I wanted a way to do this even
;;; if the "pickfirst" variable was toggled to zero. If no entity is
;;; currently selected on the screen, this function will prompt the
;;; end user to select an entity.
;;;
;;; Author: John Kaul
;;;
;;; Returns: Either previously selected entity or a selected entity
;;;
;;; Usage: (vlax-ename->vla-object (Get-EntSelcted)
;;;======================
(defun Get-EntSelcted ()
(if (setq x (cadr (ssgetfirst)))
(setq x (ssname x 0))
(progn
(while (not (setq x (entsel "\nSelect object: "))))
(setq x (car x))
)
)
(sssetfirst nil)
(redraw x 3)
x
)
;CODING ENDS HERE
=======
Hi Kenny,
Did someone do this already?
;Toggle the statusbar OSNAP on and off
(defun C:TOGGLESNAP ()
(setq csnap (getvar "osmode"))
(if (> 16383 csnap)
(setq csnap (+ csnap 16384))
(setq csnap (- csnap 16384))
)
(setvar "osmode" csnap)
(princ)
)
Mark Johnston
==============
Hi Kenny , about short lisp , it is my sample .
To clean the pickbox when chose by error
I have a button with this few command

^C^Cline;^C^C
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (4 of 12) [23/03/2005 05:49:29 p.m.]

It will clean all pickbox , same as Esc
Maybe is another way , but it work well for me.
I use the keyboard the least I can.

Chau Amigo .
============
Kenny:
Here are two AutoLISP programs that I developed and have
used over the years, for manipulating text entities:
TXTR.lsp - Replaces the text string of one text entity with the
text string from another, and deletes the second selected entity.
TXTS.lsp - Adds the text string of one text entity to the end of a
second selected entity, adding a space before tacking on the
additional text. The second selected text entity remains untouched.
Removing the semicolon in the code in front of the ERASE
command will change the program so that the second selected
text entity is deleted.
Of course, these can be written shorter, but the basic error
checking is worth leaving in.
TXTR.lsp code starts here:
(defun C:TXTR ( / E1 E2 ED1 ED2 F1 L1 L2 L3 S1 S2)
;*****
(defun F1 (AR1 AR2)
(setq E1 nil)
(while (null E1)
(if (null (setq E1 (entsel AR2)))
(princ "\nNothing was selected, try again...")
(progn
(setq ED1 (entget (car E1)))
(if (/= (cdr (assoc 0 ED1)) "TEXT")
(progn
(setq E1 nil)
(prompt "\nRejected - Entity is a ") (princ (cdr (assoc 0 ED1)))
);progn
);if /=TEXT
);progn
);if
);while
(if (= 1 AR1) (setq ED2 ED1))
(cdr (assoc 1 ED1))
);defun F1
;*****
(setq S1 (F1 1 "\nSelect text string to change..."))
(redraw (cdr (assoc -1 ED2)) 3)
(setq S2 (F1 2 "\nSelect new text string..."))
(redraw (cdr (assoc -1 ED2)) 4)
(setq L1 (assoc 1 ED2))
(setq L2 (cons (car L1) S2))
(setq L3 (subst L2 L1 ED2))
(entmod L3)
(command "ERASE" E1 "")
(princ)
);defun C:TXTR
(princ)
End of TXTR.lsp code.
TXTS.lsp code starts here:
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (5 of 12) [23/03/2005 05:49:29 p.m.]
(defun C:TXTS ( / E1 E2 ED1 ED2 F1 L1 L2 L3 S1 S2 S3)
;*****
(defun F1 (AR1 AR2)
(setq E1 nil)
(while (null E1)
(if (not (setq E1 (entsel AR2)))
(princ "\Select again..."))
(setq ED1 (entget (car E1)))
(if (/= (cdr (assoc 0 ED1)) "TEXT")
(progn
(setq E1 nil)
(prompt "\nRejected - Entity is a ") (princ (cdr (assoc 0 ED1)))
);progn
);if /=TEXT
);while
(if (= 1 AR1) (setq ED2 ED1))
(cdr (assoc 1 ED1))
);defun F1
;*****
(setq S1 (F1 1 "\nSelect text string to change..."))
(redraw (cdr (assoc -1 ED2)) 3)
(setq S2 (strcat " " (F1 2 "\nSelect text string to add...")))
(redraw (cdr (assoc -1 ED2)) 4)
(setq S3 (strcat S1 S2))
(setq L1 (assoc 1 ED2))
(setq L2 (cons (car L1) S3))
(setq L3 (subst L2 L1 ED2))
(entmod L3)
; (command "ERASE" E1 "")
(princ)
);defun C:TXTS
(princ)
End of TXTS.lsp code
Have a good one.
Ron D.
======
Hoi Kenny,
Thanks for your weekly news letter.
In a drawings one works with different (sometimes many) layers.
For example in P&ID's one layer for every sort of fluid, not mentioning one
for pump, instruments,valves, etc, etc.
Normaly one would use Layer Control to set a layer current, searching thru
all the layers.
It's boring and time consuming, so I made this short routine and put it
under a button in my toolbar.
If something is already drawn on a certain layer I can use this routine
just by clicking the button, select a element and push enter, spacebar or
right click on my mouse.
The layer the element is drawn on will now be set current.
(setvar "clayer" (cdr (assoc 8 (entget (ssname (ssget) 0)))))
Greetings,
Joop
PS. Now that I am writing this I wonder:
Is there a way to auto-terminate this routine without using enter?
===========
Kenny,
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (6 of 12) [23/03/2005 05:49:29 p.m.]
Rot.lsp rotates selected graphics relative to selected point. I have found
this little program to be invaluable!
;code starts here:
; rot.lsp - Rotates objects graphically - C Green 9/3/99
;
(defun c:rot ( / p1 p2)
(prompt "\nSelect objects to rotate: ") (ssget)
(setq p1 (getpoint "\nCentre of rotation: "))
(setq p2 (getpoint p1 "\nReference point: "))
(command "rotate" "p" "" p1 "r" p1 p2 pause)
)
;code ends here
I often find it handy to divide the space between to points with nodes at
equal spacings to facilitate setting out other graphics etc. This little
program does just that (default spacing is 2).
(Don't forget to set pdmode and pdsize to the required values.)
;code starts here:
;PD.LSP - Point divide function - C Green 3/3/98
;Divide distance between two points by the nominated value.
;Version 1.0
;
(defun c:pd ( / a d k pt1 pt2 x)
(prompt "\nPoint Divide:")
(setq pt1 (getpoint "\nFirst point: "))
(setq pt2 (getpoint "\nSecond point: "))
(setq x (getint "\nDivide into <2>: "))
(if (= x nil) (setq x 2)) ; Force default of 2
(setq d (distance pt1 pt2))
(setq a (angle pt1 pt2))
(setq d (/ d x))
(setq k 1)
(while (/= k x)
(setq pt1 (polar pt1 a d))
(command "point" pt1)
(setq k (+ k 1))
)
)
;code ends here
Obviously, all the nodes added by pd.lsp will not be required once setting
out has been completed. The program dp.lsp erases ALL nodes on the
drawing.
;code starts here:
;DP.LSP - Function to delete all nodes on drawing - C Green 3/3/98
(defun c:dp ()
(command "ERASE" (ssget "X" (list (cons 0 "POINT"))) "")
)
;code ends here
Regards,
Craig Green
===========
Hey Kenny, here's an example of how to use Se7en's 'Selected-p' function,
for the newsletter.
<code>
;;; FUNCTION
;;; catchs any errors in selection process
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (7 of 12) [23/03/2005 05:49:29 p.m.]
;;; returns a valid VLA-OBJECT or nil
;;; *requires* 'Selected-p' by John Kaul
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;; (setq obj (MST-Select-It))
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright 2003 Mark S. Thomas
;;; mark.thomas@theswamp.org
;;;
;;; VERSION
;;; 1.0 Tue Sep 16, 2003 07:04:21
(defun MST-Select-It (/ obj)
(if
(vl-catch-all-error-p
(if
(not (Slected-p))
(setq obj
(vl-catch-all-apply
'vlax-ename->vla-object
(list (car (entsel)))
)
)
)
)
(setq obj nil)
)
obj
)
</code>
Mark Thomas
http://www.theswamp.org
============
Kenny
Some times I find it very handy to draw what I call 'disconnected lines'.
For example say you want to draw a line from point 1 to point 2 and then
from point 3 to point 4 WITHOUT drawing a line between point 2 and point 3
etc etc. To achieve this I have written dline.lsp.
;code starts here:
(defun C:dline ( / p1 p2)
(setq p1 (getpoint "\nFirst point: "))
(if (/= p1 nil)
(setq p2 (getpoint p1 "\nSecond point:"))
)
(while (/= p1 nil)
(command "line" p1 p2 /r)
(setq p1 (getpoint "\nFirst point: "))
(if (/= p1 nil)
(setq p2 (getpoint p1 "\nSecond point:"))
)
)
(prin1)
)
;code ends here
Some times I also find it very handy to be able to select (window) several
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (8 of 12) [23/03/2005 05:49:29 p.m.]
dtext entities and convert them all to SEPARATE mtext entities (without
grouping them as one block of mtext). To achieve this I have written
mtxt2dtext.lsp.
; dtxt2mtxt.lsp - C GREEN - 17.01.2003
; CONVERT DTEXT TO MTEXT.
;
(defun C:dtxt2mtxt (/ p l n e os as ns st s nsl osl sl si chf chm mtext ds
dimz cmde)
(princ "\nChange dtext to mtext.\n")
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "color" "bylayer")
(setq chm 0
p (ssget)
)
(if p
(progn
(setq l 0
n (sslength p)
)
(while (< l n)
(if (= "TEXT" (cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq s (cdr (setq as (assoc 1 e)))); Convert entity to mtext
(setq mtext '((0 . "MTEXT") (100 . "AcDbEntity")(100 . "AcDbMText"))
mtext (append mtext
(list (assoc 8 e) (assoc 10 e)
(assoc 7 e) (assoc 40 e)
(cons 41 (* 1.1 (abs (- (caar (textbox e))
(caadr (textbox e))))))
(cons 3 (strcat (cdr (assoc 1 e))))
)
)
)
(entdel (cdr (assoc -1 e))) ; Delete dtext
(entmake (append mtext '((1 . "")))) ; Add mtext
(COMMAND "MOVE" "LAST" "" "0,0" (strcat "0," (rtos (cdr (assoc 40 e))
2 5)))
(setq chm (1+ chm))
)
)
(setq l (1+ l))
)
)
)
(princ "\nChanged ")
(princ chm)
(princ " dtext.")
(setvar "cmdecho" cmde)
(prin1)
)
Regards
Craig Green
===========
;CODING STARTS HERE
;;;==========================
;;; Get-EntSelcted
;;;---------------------------
;;; This function will offer a way for the programer to get an
;;; entity or entities already slected on the screen before the
;;; program took control. This program was intended for use in an
;;; ActiveX program. I have chosen not to use the "Pickfirst" method
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (9 of 12) [23/03/2005 05:49:29 p.m.]
;;; in accomplishing this task because I wanted a way to do this even
;;; if the "pickfirst" variable was toggled to zero. If no entity is
;;; currently selected on the screen, this function will prompt the
;;; end user to select an entity.
;;;
;;; Author: John Kaul
;;;
;;; Returns: Either previously selected entity, a selected entity, or
;;; a list of selected entities.
;;;
;;; Usage: (vlax-ename->vla-object (Get-EntSelcted))
;;;======================================
(defun Get-EntSelcted (/ x cntr xlength xlist)
(setq x (cadr (ssgetfirst)))
(if x (setq xlength (sslength x)))
(cond
((= xlength 1)
(setq x (ssname x 0))
(sssetfirst nil)
(redraw x 3))
((> xlength 1)
(setq cntr xlength)
(cond
((>= cntr 2)
(setq cntr (1- xlength))
(while (>= cntr 0)
(setq xlist (cons (ssname x cntr) xlist)
cntr (1- cntr)))
(foreach a xlist (progn (sssetfirst nil) (redraw a 3))))))
;; Might not want to have this function do any selecting for you.
;; if you do, un-comment this block.
;;; ((= xlength nil)
;;; (while (not (setq x (entsel "\nselect object: "))))
;;; (setq x (car x))
;;; (sssetfirst nil)
;;; (redraw x 3))
)
(if (= nil xlist) x xlist)
)
;CODING ENDS HERE
John Kaul
==========
Things Weird and Wonderful
========================
Weird Things!!!
http://www.weirdies.com/weird-photographs.html
=========
Learn to play Air Guitar :
http://www.airguitar.com/
=========
Unable to close TROUSER.ZIP.
Replace floppy and retry (Y/N)
Miscellaneous Stuff that I almost Forgot
===================================
Kenny,
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (10 of 12) [23/03/2005 05:49:29 p.m.]
Here is an addition for the environment variable listing.
(getvar HideSystemPrinters)
I was looking for this the other day and had trouble finding it.
Cheers,
Tad Wirmel
==========
Mail Tracker
http://www.theinquirer.net/email_tracker.htm
==========
The Back Stoep
=============
Economic reality!
AN AMERICAN CORPORATION
You have two cows.
You sell one, and force the other to produce the milk of four cows.
You are surprised when the cow drops dead.
A SOUTH AFRICAN CORPORATION
You have two cows.
You go on strike because you want three cows.
A ZIMBABWEAN CORPORATION
A farmer has two cows.
You take over his farm, eat both cows and wait
for the international community to supply more.
A JAPANESE CORPORATION
You have two cows.
You re-design them so they are one-tenth the size of an
ordinary cow and produce twenty times the milk.
You then create clever cow cartoon images called
Cowkimon and market them World-Wide.
A GERMAN CORPORATION
You have two cows.
You re-engineer them so they live for 100 years,
eat once a month, and milk themselves.
A BRITISH CORPORATION
You have two cows.
Both are mad.
AN ITALIAN CORPORATION
You have two cows, but you don't know where they are.
You break for lunch.
A RUSSIAN CORPORATION
You have two cows.
You count them and learn you have five cows.
You count them again and learn you have 42 cows.
You count them again and learn you have 12 cows.
You stop counting cows and open another bottle of vodka.
A SWISS CORPORATION
You have 5000 cows, none of which belong to you.
You charge others for storing them.
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (11 of 12) [23/03/2005 05:49:29 p.m.]
A CHINESE CORPORATION
You have two cows.
You have 300 people milking them.
You claim full employment, high bovine productivity,
and arrest the newsman who reported the numbers.
AN AUSTRALIAN CORPORATION
You have two cows.
The one on the left is kinda cute...
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If we are too loud, you are too old.
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-20
http://www.afralisp.com/newsletter/2003/2003-20.htm (12 of 12) [23/03/2005 05:49:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-21
=========================
Tuesday 30th September 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Are you illiterate?
Write today for free help.
=========================
The Front Stoep.
==============
Ooooh, have I got a good one for you this week.
Yep, a brand new competition with a real, live, practical prize
at the end of it. And you don't even have to be a guru at coding
to stand a chance of winning!!
Okay first, what is it you need to do to enter?
We need you to tell us what was the most amusing, interesting, mind blowing,
leg shaking, despicable thing that ever happened to you, or that you witnessed
whilst at work.
That's it, simple hey??

Two Rules :

AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (1 of 12) [23/03/2005 05:49:31 p.m.]
1) It must be original. (no searching Google).
2) It must be Work and/or CAD related (leave the "pub" stories to me).
Each story will be published in the Newsletter but please keep your story as
short as possible as space is at a premium.
The competition will run over two weeks with the winner being announced
in three weeks time. So, get writing and send your entry to this address :
mailto:afralisp@mweb.com.na
and put "The Competition" in the "Subject" line.

Judges :

Kenny Ramage (moi)
Paul Cistoldi (our sponsor)
Andrew Canfield (cos he's got a great sense of humour and he'll be fair.)
=======
And what can you win?
Well here's a few words from our generous sponsors :
CADzation (www.cadzation.com) is pleased to help sponsor this AfraLisp
Newsletter Contest. Actually we think Kenny just needs some good humor
down there or maybe some writing material for some new songs.
Either way we are please to give a way a free copy of our AcroPlot Software
($149 U.S. value) to the winner. AcroPlot is one of the best ways to convert
AutoCAD drawings and Word documents to PDF files. With AcroPlot even a
hung over musician will have no problem easily sending hundreds of drawings
to a single PDF document. Best of all its so easy that you can just select your
drawings, hit convert, and listen to a little BedRock while AcroPlot does all the
work for you.
CADzation is a small company that was started because as
an engineer I was fed up with doing repetitive tasks all day long.
And I found that with Visual LISP it was easy to create routines that
could save me time.
So if youve ever wanted to create multipage PDF files of your AutoCAD and Word
documents stop by and check us out. If youre looking at integrating PDFs into your
existing workflow or document management routines just let us know, we love doing
customization and we can save you a ton of headaches.
Why use PDF files?
Mainly because they are one of the most common file formats distributed today.
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (2 of 12) [23/03/2005 05:49:31 p.m.]
Almost all new computers come with Adobe Reader preinstalled and most people
are already used to working with them. Youve probably heard some bashing from
Autodesk on the PDF format and that their DWF format is better.
For design transmittal maybe, for document transmittal Ill take PDF everyday.
And our AcroPlot software will take all of the work out of creating the PDF
files for you.
Should I use layers in PDF files?
Theres been talk lately about the use of layers in PDF files.
Adobe implemented this in their new Acrobat 6.0 Professional and all I can say is
that if you use layers in PDF files you better not let me ever run across you.
What was ideal about the PDF was that what you created everyone saw and printed.
The PDF is a document format and if you want layers you need a design format like
DWF. Plus if you create a PDF with layers I can easily create a DWF with layers
out or it.
We look forward to reading your stories and please stop by and give us your
feedback on our AcroPlot program at www.cadzation.com.
==================
By the way, I've got the licence already, just waiting to be awarded to
some lucky soul.
So come on.........we're all waiting........
==================
Pearls of Wisdom
===============
Move your vowels every day or you'll get consonated.
===============
From Last Week :
How do you deal with your drawings once complete?
Do you check them?
How do you circulate them for comments/approval/signatures?
Do you store them electronically?
Do you keep hardcopies?
Kenny,
I haven't had a chance to reply until now, but let me see if I can fill you
in on how things are done here. Once the project begins, our drawings are
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (3 of 12) [23/03/2005 05:49:31 p.m.]
constantly gone over. I work in close contact with the engineers and
sometimes, the client. And since only a few people work on a project, it
is relatively easy to control the documents. As we work on our drawings,
we do periodic electronic archives. I work in a civil engineering firm.
And depending on who the client is, we are required to submit drawings at
certain intervals. Examples would be at 50% complete, possibly 75%
complete, 90%, and of course at 100% complete. These intervals allow the
client to track our progress and correct any conflicts at an early stage of
design. At each interval, we burn a CD archive of the project. This way,
if we need to, we can go back and get information from an earlier time.
After all the construction is done and the as-builts are complete, we do
another archive and remove the project from the network server.
Something new that we will be starting, is to not only archive the CAD
files, but create and archive PDF copies of each drawing. This gives us
three important advantages. One, we have a "photographic snapshot" of a
drawing at a specific time. We do not have to worry about bringing up a
drawing and worrying if the xref has been changed. Two, more and more of
our clients are requesting an electronic copy of the drawings, and this
makes a nice tidy package to give them. Three, easier printing if we need
to verify something that went out. On occasion, we need to access a
drawing which may have been submitted several months earlier. By having
PDF's, anyone with a program on their computer that can read PDF's can look
at the exact same drawing the contractor is looking at, or if need be,
print it out.
Martin Kriewall
=============
(Spanish: Por favor, correg mi ingls!)
How do I deal with my drawings once complete?
I work alone, and I do a lot of "little" works that I complete in a few
hours.
When the dwg is complete, I purge, zip and e-mail it to the client and/or
for ploting and copying.
AND... (here is my secret:) I send the mails (Blind Carbon Copy) to an pop3
e-mail acount to save it "in the cyber space".
(store1). When it is full, I make another acount (store2).
This way I save all the work.
And ... I can access the dwgs by mail2web... "from any computer.. anywere"
Twice a year I made a backup in CD.
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (4 of 12) [23/03/2005 05:49:31 p.m.]
Jorge Prraga
=============
Coding
=======
The Shorties (continued)
=====================
Kenny,
I've been holding back for weeks but I just can't keep this bit of code
to myself anymore. I defy anyone to make real use of this routine. I've
used it all of twice in the last 5 years, but I'm glad I have it.
Viva useless yet fun code!
;CODING STARTS HERE
(defun c:omi ( / n1 n2 n3)
;You insert the offset distance in Metric units,
;program then offsets entity in Imperial units.
(setq n1 (getreal "Offset distance in Millimetres: "))
(setq n2 (cvunit n1 "mm" "inch"))
(setq n3 (rtos n2 2 4))
(command "offset" n3 pause pause)
(princ)
)
(princ)
;CODING ENDS HERE
Cheerio compadre
Ron Albrecht
============
;CODING STARTS HERE
; to make a texstyle and a layer current by selecting a single text
;; THS - THis Style
(defun c:ths ( / ennn )
(if
( = "TEXT" (cdr (assoc 0 (setq ennn (entget (car (entsel "\Select a
text")))))))
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (5 of 12) [23/03/2005 05:49:31 p.m.]
(progn
(setvar "clayer" (cdr (assoc 8 ennn)))
(command "_style"
(cdr (assoc 7 ennn)) ""
(cdr (assoc 40 ennn))
(cdr (assoc 41 ennn))
( * (cdr (assoc 51 ennn)) ( / 360 ( * 2 PI )))
"N" "N" "N"
)
(setvar "textsize" (cdr (assoc 40 ennn)))
) ;; end progn
(alert "This is not a single text")
) ;; end if
) ;; end defun
(prompt "\nUse \"ths\" to make a style current") (princ)
;CODING ENDS HERE
From the Pampas Argentinas
Jorge Prraga - La Plata, Buenos Aires
================================
Hi Kenny,
About toggling OSNAP.
In many LISP macros I need to switch the OSMODE
off then bring it back at the end of the program.
Here is what I do;
;;; This is somewhere at the begining of the program
(setvar "osmode" (logior (setq OldOsmode (getvar "osmode")) 16384))
;;
;; rest of the program
;;
;; at the end where you reset your system variables
(setvar "OSMODE" OldOsmode)
(princ)
greetings
Sherko
======
Opening a drawing:
(command "._vbastmt"
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (6 of 12) [23/03/2005 05:49:31 p.m.]
"ThisDrawing.Application.Documents.Open(\"DrawingName.dwg\")")
New drawing:
(command "._vbastmt"
"ThisDrawing.Application.Documents.Add")
New drawing with template:
(command "._vbastmt"
"ThisDrawing.Application.Documents.Add(\"TemplateName.dwt\")")
Frank
======
Some Questions
===============
Hello Kenny:
I have one question maybe you can help me out. The situation is I'm trying
to develop an aplication in AutoCAD Map, using VBA, but also I do havesome
AutoLISP routines alreday developed that I want to include within the VBA
code. Most of them (LISP) works fine in the VBA code using the
"Thisdrawing.SendComand (....)" method, but the ones which has to make an
interaction with the AutoCAD screen like mark an area (polygon) just do not
wait for the action on the screen and finalized the lisp routine, and the
VBA code continue to the next program lines until the end of VBA code, and I
get put into the AutoCAd windows to continue with the lisp code. As an
example if you include in the middle of a VBA code the "adequery" command
it will show the query define window, but when you try to define a polygon
area for the location query the next VBA code lines continues to execute not
waiting to finished the "adequery" command.
Alberto Andrade
===============
Dear Kenny
Is it true that tutorials provided for download in the site
will erase hard disk after one week?
Regards
Narendra.G
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (7 of 12) [23/03/2005 05:49:31 p.m.]
=====
I mean, what else could I tell him but "Yes dear!"
(Oh, aren't I cruel)
================
Do you know of a way to export text to a dos
text file or to notepad etc ??
thanks,
Kevin
======
Kenny.

I would like to be able to use a dialog box to choose which LISP file to run.
How do I make a call to run another lisp file from a radio button?

thanks
jorge
=====
Things Weird and Wonderful
========================
Want a FREE FTP program?
FTP Explorer
http://www.ftpx.com
=================
Don't forget to visit :
"Cartoon a Day"
http://www.afralisp.com/cartoon-a-day.htm
===============
Interesting!!
http://bbspot.com/news/2000/4/MS_Buys_Evil.html
Thanks Andy
============
Miscellaneous Stuff that I almost Forgot
================================
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (8 of 12) [23/03/2005 05:49:31 p.m.]
MASIPHEMBE - A Non-Profit voluntary organization promoting
a creative design culture in South Africa.
http://masiphembe.co.za.
====================
You can find "The AfraLisp Books" here :
http://www.afralisp.com/books.htm
==============
MP3 To Wave Converter :
http://www.acoustica.com/
Convert MP3s to WAVs or WMA.
Convert WAV creations into MP3
Convert WMA files to MP3 or WAV.
Demo, but worth looking at.
==============
CDex - a utility for extracting sound files from a CD-ROM and
converting WAV files into several other (compressed) formats,
like the popular MP3 format.
The latest version of CDex can be downloaded from:
http://www.cdex.n3.net
And CDex is FREE......
=================
The Back Stoep
=============
One of our favourite social occasions here in Africa is to participate in what
we call a "braai", but what you would probably call a "barbeque" or "barby".
Let's have a wee look at a typical "Kenny Braai".
Now, first of all, you'll need ingredients :
* 12 cases of beer
* 9 bottles of Whisky
* 4 x 2 litre Coke (for mix)
* 4 x 2 litre Coke Lites (for the chicks and Fat Freddy)
* 1 bottle of Sherry (for the chicks and your wife's gay cousin
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (9 of 12) [23/03/2005 05:49:31 p.m.]
- there's always a gay cousin!)
* 3 x 5 litre Cheapest Wine (for the chicks and just in case the beer and
whisky runs out)
* 1 Sheep (unless you've invited an Aussie 'cos it could be his fiance)
* 5 meters of thick German Sausage
* 5 kg Pork Chops
* 5 kg T-bone Steak
* Any available road kill for the wife's American friends.
* 6 Garlic onions - the whole things, not just 6 cloves.
* At least 5 chicks (to stand in the kitchen and make salad and
prepare the buns and all that sh*t)
* 1 x half 40 gallon drum for the barbeque
* 10 bags of Charcoal
* 4 boxes of Firelighters
* January 2003 - August 2003's Sunday Express Newspapers
* 1 hose pipe
* 1 bucket
Saturday:
05:00: Throw 2 bags of charcoal, January through March's Expresses and a
half a box of firelighters in the drum, and light the lot for a good
solid barbeque foundation.
05:35: Open 1 bottle of whisky and one 2 litre Coke.
06:15: Mutter to yourself that you're sure they're making the whisky bottles
smaller these days, and crack open a beer.
06:20: Go check that no one stole the meat from under your carport during
the night.
06:30: Beer
06:35: Beer
06:45: Email your mates to tell them "Today's going to be a fu$%en party!!"
06:55: Explain to your mom that you accidentally emailed her and that you
would never swear at her.
07:00: Beer
07:20: Microwave some of last night's Mac 'n Cheese for breakfast.
08:00: Wake up your wife so that she can go jogging on your behalf.
08:30: Walk around the house (and yard) naked while you're wife is out
jogging,
making sure that everything is going good. - Check on the fire.
08:45: Throw in another bag of charcoal and the rest of the first box of
firelighters.
09:15: Explain to your wife that the reason you're walking around naked
is to get rid of your snoring problem - You read this in a men's Health Magazine
10:00: Give her money to go buy buns and stuff for the barbeque.
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (10 of 12) [23/03/2005 05:49:31 p.m.]
10:15: Stop arguing and give her more money to get her hair done.
10:20: Give her your credit card.
10:30: Sit down to watch some TV and have a few beers.
11:30: Wonder where the first case of beer went, take one from the second case.
12:30: Look at your 9 cases of beer and decide that it should still be enough
for the guys.
12:55: Tell your wife that you only had 1 or 2 beers and that she shouldn't
moan so much.
13:00: Fat Freddy and his wife arrive - open 2nd bottle of whisky and the
Coke Lite, and open the Sherry for his wife.
13:45: Feel a slight buzz.
14:30: Look at the 3rd bottle of whisky and squint.
14:45: Feel buzzed more.
15:00: By this time should be everyone there.
15:15: Charcoal another bag of throw on the barbeque and open a beer.
15:30: Talk sh*t and beer
15:45: Ask the chicks if the ready is buns and the buttered.
16:00: More talk sh*t.
16:30: Arm wrestling competitions with gay the cousin.
16:50: Say to everyone that you win him let.
16:55: Suck petrol out of Fat Car's Freddy to just in case..
17:15: Give the Sheep to your friend Aussie and luck them wish future for the.
17:30: Meat the rest of the barbeque on the put and beer another have.
18:00: The more needs to fire burn, get the petrol.
18:45: Closest Medical Centre - Burn grade 1st wounds.
19:30: House at back - Freddy thank for beer open another barbeque and the
6th bottle of whisky.
20:30: Open Whisky bottle of 7th and hand Whisky out shooters of.
21:00: Tell love that you everyone them, especially Fat Freddy's Wife.
21:30: Finish the last beer of Whisky and case of bottle.
22:15: Closest Cedical Mentre - Stomach Pump
Sunday:
03:45: Eat.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (11 of 12) [23/03/2005 05:49:31 p.m.]
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
The More you Drink, the Better We Sound!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-21
http://www.afralisp.com/newsletter/2003/2003-21.htm (12 of 12) [23/03/2005 05:49:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-22
=========================
Tuesday 7th October 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
This [send money] is a [send money]
subliminal [send money] message.
=========================
The Front Stoep.
==============
Well, believe it or not, but I've only had four entries for "The Competition!!!!"
So come on every one of you. Only one more week to go before entries close.
Here's a review of what it's all about :
"We need you to tell us what was the most amusing, interesting, mind blowing,
leg shaking, despicable thing that ever happened to you, or that you witnessed
whilst at work."
And "The Prize?"
A free copy of AcroPlot Software ($149 U.S. value) to the winner, compliments
of CADzation (www.cadzation.com)
AcroPlot is one of the best ways to convert AutoCAD drawings and Word
documents to PDF files.
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (1 of 15) [23/03/2005 05:49:33 p.m.]
The Competition So Far
====================
Just this morning , at our on work breakfast , I remember and tell my crew
about a despicable thing that ever happened to me.
Circa 1977 , on a warm province in Argentina , Catamarca , maybe about 35
to 38 C on shadow.
We were uncrating a imported machine, whose crate was broken, and part
get rust and were stucked.
As we where on a country site, far from a wharehouse to get a LOOSIT liquid,
not know how you named it, i ask a
guy , those who ever goes to bring any thing we need .
Hi Joe , please go to the bar and get a Coke, hope you know it is a god anti rust
and looser part when they were blocked by rust.
After a wile , he went back us and say : Boss I bring a FANTA, cos' COKE is Hot.
You migth wonder what I told him.....

Gabriel CALS DE VIT
==================
Hi-ya Kenny,
My story is pretty short and, to tell ya the truth, not that good but
what-da-hell.
I work in the Arch/Mech field and one day my co. gets a job for one of
the local zoo's here in town. The Zoo's seal pond needed re-piping. The
job called for a bunch piping to circle the outside of the pond. A
"senior" (Let's call him Bob) came up to me and asked me to draw
something up in CAD to work out some dimensions. I, of course, said
"Sure. What do you want me to draw?"
After a few minutes, I realized what I was drawing. Bob wanted me to
figure out the longest lengths of straight pipe he could have if he
ordered some custom 18.5 deg Polyvinyl Chloride (PVC) fittings. I did it
--and I came up with something like 32 fittings. And at a nice chunk of
change a piece, that would blow the clients budget.-- but I also did
some quick notes on using High Density Polyethylene pipe (HDPE -Flexible
stuff) instead. I gave him what he wanted but I also brought up the idea
of using HDPE instead and he just looked at me funny. ("How dare he
question me?!")
A couple of days later I'm just chatting with my boss and he mentioned
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (2 of 15) [23/03/2005 05:49:33 p.m.]
that he wanted me to help someone with a small job.
"The job should be quite easy; 'Bob' found a new solution to a potential
problem."
"Sure. That's good, what did he do?"
"He came up with the idea of using HDPE instead of PVC on the 'Zoo
job'."
"He did?"
"Yeah, he said it just came to him."
(Yeah, "Came to him" ...I'll give him something; I'll put my boot up
his...) I asked 'Bob' about that; he said that he went with his
"original design" of using HDPE instead of PVC.
...See ya!
John
======
The most despicable thing that has happened to me at work was having
to share an office with a guy who smelled like a skunk. I was working
for an architect in Southern Oregon at the time and it was August,
the hottest month of the year. My office mate was known for getting his
drink on and he had done so this particular night, went home, bent down
to pet a cat on the porch and got sprayed right in the chest. Don't ask me
why, but he felt that he must share his stench with the office and in particular
me by coming into work the next morning. I tried my best to keep his air on
his side of the room with fans and such but it didn't work and the heat just
seemed to increase the volume. For two weeks I had to smell it all day at the
office and as soon as I would get home, I would have to shower to get the
stink off that followed me there. The problem that still gets to me is that he
didn't even own a cat!
Elise Bauman
============
Dear Sir Kenny,
Okey, Well the most amusing, interesting, mind blowing,
leg shaking, despicable thing that ever happened to me
was when I browsed your website and found out that
your website was the only site that i find very rich
in cad articles as well as cad customization. I've
been browsing for a year now, looking for a website
that can explain clearly and easily in Autocad
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (3 of 15) [23/03/2005 05:49:33 p.m.]
customization.
Keep up the very good work!!!
Regards,
Florence
========
Pearls of Wisdom
===============
Beer: So much more than just a breakfast drink .
===============
Coding
=======
The AutoCAD API's When and Why.
============================
By Andrew Cornfield
There are three major API's with which you can extend AutoCAD. They are respectively :
a C/C++ api called objectARX, a VB/VBA api, and an AutoLisp/VisualLisp api.
Every developer has their favorite but all partiality aside people often wonder
which is better, which should I use? The answer to those questions is:
"It depends on what you need to accomplish".
Each API has different things, which make it better in given situations.
When deciding on which API to use there are 4 things you need to ask yourself.
What language am I most comfortable in?
How much time do I have? Who is the target user and how much AutoCAD experience
do they have?
How much control over AutoCAD and possibly Windows do I need to accomplish the
task quickly?
After I address some of the functionality of the different API's you will see
why these are relevant.
I am only going to deal with these API's as they apply internally to AutoCAD
not as stand alone applications.
The objectARX API:

Out of the three API's this one has the most control over AutoCAD and Windows.
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (4 of 15) [23/03/2005 05:49:33 p.m.]
You can register its commands with AutoCAD. The user needs to know very little
about AutoCAD to run your program. The drawbacks to it are it takes longer to
develop in it for most developers than VBA or Lisp, and often it is overkill
especially for simple drafting tools. To get anything done in this API you
should already be very familiar with C and C++. On a personal level this API
is my favorite but that is because I do 99% of all my development in C and C++
so when I do something for AutoCAD it's easier for me not to have to switch
languages. For me it falls into the category of "what language am I most
comfortable with?". There are things within AutoCAD that this API can access
that the other API's cannot. This is the major reason for most developers who
use this API. They need to do something and it literally cannot be done using
the other two API's. This is also the only API to which you can secure
your code from having others read and copy your source. If you need to
develop custom objects, work with spatial filtering, expose functionality to
an application using another API, are developing third party tools for sale,
or a host of other things to which VBA and Lisp cannot access without great
difficulty or at all then this is the API you should use.
The VBA API:
If this is your first time extending the functionality of AutoCAD than this
is most likely the API for you.
This API is very friendly towards new developers.
The Visual Basic language reads in such a way that many times new developers
can work out simple questions by just reading the names of the functions.
This API does not have as much access to AutoCAD as the C++ or Lisp API's
do however you can construct and execute Lisp commands to give yourself
access to the few things that Lisp can do which VBA cannot natively.
If you are very good with VBA you can subclass the AutoCAD command line
and then there really isn't anything Lisp has access to which you wouldn't
using VBA. The major drawback to the VBA API is that it doesn't natively
register your functionality with AutoCAD. It must first be loaded as a dvb
in any of the various ways you can load applications into AutoCAD and then
executed via the tools menu or by a custom button or menu item. Depending
on your user base this can be a big issue. I have worked on contracts where
the drafters are all used to commands and don't want to use anything else.
In this case VBA can be a difficult sell. If the user group isn't that stuck
in there ways then VBA is usually a very easy sell. Especially after they
see how fast you can create tools with it. As with Lisp this is primarily
an internal developer's tool to extend AutoCAD within your company, or if
you have been contracted to work on site to write custom tools. Out of all
the API's this is the one, which can create applications the most quickly
especially applications, which require graphic dialogs.
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (5 of 15) [23/03/2005 05:49:33 p.m.]
It also has the most support from AutoDesk.

The Lisp API:

When I am speaking of Lisp I am specifically referring to AutoLisp and
VisualLisp I am not talking about ANSI Common Lisp. First a quick description
of AutoLisp. "AutoLisp: it combines the RAD features of iX86 with the
flexibility of COBOL". All kidding aside the major reason the Lisp API gets
used is because for many developers it satisfies the question "What language
am I most comfortable in?". For many people this is where they started and
it is what they are fastest developing in. Another reason to use this API is,
if the environment in which you work has large legacy libraries of Lisp routines.
Lisp is harder than VBA to learn yet still far easier than C or C++.
Until AutoCAD 2000, VBA was not very well implemented inside of AutoCAD and
left a great deal to be desired. Lisp was the primary choice for rapid in house
development of macro's. Large libraries of Lisp functions exist in many places.
Re-writing these in VBA is often not cost effective in the short term. If this
is the case then Lisp is the tool for you and may God have mercy upon your soul.
Kidding sort of. There are some very serious downsides to using Lisp so if you
are new to developing for AutoCAD or need to interface your functionality with
any other Windows programs or the Windows operating system you may want to look
into VBA instead. On the upside if you are interfacing with a program written
for the objectARX API it is a lot easier for the objectARX developer to expose
their functionality to Lisp than VBA but a good developer should be able to do
either so it really depends on who is writing the C++ side of things as to
which they expose their functionality to.
Here is a simple checklist for determining which API may be right for your project:
ObjectARX:
You are most comfortable working in C or C++
You need the absolute maximum amount of control over AutoCAD and Windows
You need to write custom objects
You need access to things which are not exposed to VBA or Lisp
You require more speed than can be had using VBA or Lisp
Your workplace requires applications be developed in C or C++
You need to use libraries external to AutoCAD which are only available to
C or C++
VBA:
You are most comfortable working in VBA
You need to use a dialogs
You need to interface with Windows or one of the Microsoft office programs
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (6 of 15) [23/03/2005 05:49:33 p.m.]
like Excel
You are new to developing for AutoCAD or are new to developing period
You require maximum speed of development time yet are not overly worried
about application speed
You know you are going to need a lot of help from Autodesk getting your
application written
Lisp:
The world ended and there are no other tools available
You are most comfortable working in Lisp
You are working with an AutoCAD version prior to 2000
You are working in one of those gray areas in AutoCAD where Lisp can
do something that would
require a huge amount of VB knowledge to accomplish the same thing.
Your workplace requires it
Your workplace may need to interface existing Lisp libraries with your tool
You enjoy pain
You don't need any dialogs or graphical user interaction other than the
command line/screen pics in your application
Parens make you happy (oh look here come the men in white coats for you now)
Now I will provide what you all come here for really. Free code.
Yes, that's right we know that's
why you really read this stuff isn't it. So since you suffered through the
above I suppose I shall have to reward you with free code so that you come back.
In each of the three API's I show a way to edit the first editable attribute
in a block reference. The use of "command" will not be seen here as that is
a huge pet peeve of mine. If you are using "command" you are not programming
you are scripting and they are two completely separate things.
ObjectARX:
void chngAtt()
{
ads_name entres;
ads_point ptres;
AcDbObjectId _Id, _attId;
AcDbObjectIterator *pIttr = NULL;
if(acedEntSel("Select a Block Reference", entres, ptres) != RTNORM )
{
//Selection failed
return;
}
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (7 of 15) [23/03/2005 05:49:33 p.m.]
acdbGetObjectId(_Id, entres);
AcDbObjectPointer<AcDbBlockReference> pRef(_Id,AcDb::kForRead);
if(pRef.openStatus()!=Acad::eOk)
{
//Open failed
return;
}
pIttr = pRef->attributeIterator();
while(!pIttr->done())
{
_attId = pIttr->objectId();
AcDbObjectPointer<AcDbAttribute> pAtt(_attId,AcDb::kForWrite);
if(pAtt.openStatus()==Acad::eOk)
{
pAtt->setTextString("We changed this");
break;
}
pIttr->step();
}
delete pIttr;
}
VBA:
Option Explicit
Sub chngAtt()
Dim objEnt As AcadObject
Dim objRef As AcadBlockReference
Dim varAtts As Variant
Dim objAtt As AcadAttributeReference
Dim emptyPt As Variant
ThisDrawing.Utility.GetEntity objEnt, emptyPt, "Select Block: "
If objEnt.ObjectName = "AcDbBlockReference" Then
Set objRef = objEnt
If objRef.HasAttributes Then
varAtts = objRef.GetAttributes
Set objAtt = varAtts(0)
objAtt.TextString = "We changed this"
End If
End If
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (8 of 15) [23/03/2005 05:49:33 p.m.]
End Sub
Lisp:
(defun C:chngAtt ()
(setq Mainent (entsel))
(setq entList (entget (car Mainent)))
(setq entAtt (entget (entnext (cdr (assoc -1 entList)))))
(setq entNewAttVal
(subst (cons 1 "We changed this") (assoc 1 entAtt) entAtt)
)
(entmod entNewAttVal)
(entupd (car Mainent))
(princ)
)
================
I had the same need to be able to run lisp routines directly from a dialog box
and came up with the following solution. I whittled it down to just three routines
for this sample but usually it contains 15 choices. I included routines that aren't
used often or are forgotten so that people in the office only have to remember
one command and then they can choose the routine they want to run, hit OK,
and then the chosen routine begins.
Hope this helps.
------ Coding starts here ---------
(defun c:lisp ()

(setq dcl_id (load_dialog "lisps3.dcl"))
(if (not (new_dialog "lisps3" dcl_id))
(exit)
)
(action_tile "flow" "(setq lld \"flow\")")
(action_tile "pcut" "(setq lld \"pcut\")")
(action_tile "ply" "(setq lld \"ply\")")
(action_tile "cancel" "(exit)(exit)")
(action_tile "accept" "(done_dialog)")

(start_dialog)
(unload_dialog dcl_id)
(if (= lld "flow")
(progn
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (9 of 15) [23/03/2005 05:49:33 p.m.]
(load "flow")
(c:flow)
)
)
(if (= lld "pcut")
(progn
(load "pipecut")
(c:pcut)
)
)
(if (= lld "ply")
(progn
(load "ply")
(c:ply)
)
)
)
;----DCL for lisp routine----
lisps3: dialog {
label = "Load Lisps";
:column {
:radio_button {
key = "flow";
label = "&Flow - Places a flow arrow (FLOW)";
}
:radio_button {
key = "pcut";
label = "&Pipe Cut - Draws end of a cut pipe (PCUT)";
}
:radio_button {
key = "ply";
label = "Pl&ywood - Creates a plywood section (PLY)";
}
}
spacer;
ok_cancel;
}
;-----lisp for flow routine------
(defun c:FLOW (/ pt1 pt2 obj1 obj2 odim ndim)
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (10 of 15) [23/03/2005 05:49:33 p.m.]
(command "cmdecho" "1")
(graphscr)
(setq odim (getvar "dimscale"))
(setq ndim (* 1.3 (getvar "dimscale")))
(setvar "dimscale" ndim)
(SETVAR "OSMODE" 512)
(prompt "pick middle center point...")
(setq pt1 (getpoint))
; this point serves as the middle center point of the arrow,
; it is also used as the base point in the rotate operation.
(command "date")
; this line does nothing.
(prompt "pick a point on the pipe that is upstream...")
(setq pt2 (getpoint))
;this point defines the initial alignment of the arrow with relation to the pipe.
(command "text" "j" "mc" pt1 (* 0.09 (GETVAR "DIMSCALE")) pt2 "V")
; insertion of the arrow.
(setq obj1 (entlast))
(command "rotate" obj1 "" pt1 "270")
; rotation of the arrow.
(setq obj2 (entlast))
(command "chprop" obj2 "" "c" "7" "")
; changes the color to white
(setvar "dimscale" odim)
(SETVAR "OSMODE" 0)

)
----- End coding ------

Elise Bauman
============
Questions
========
Hi Kenny
There must be a way to modify drawings without AutoCAD.
(I've seen it on internet)
I found something about objectDBX can you tell me more?
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (11 of 15) [23/03/2005 05:49:33 p.m.]
Rob Hemelop
============
Rob,

David Stein has a whole chapter dedicated to objectDBX in his "Visual Lisp Bible."
You can find it here :
http://www.dsxcad.com
You can also try the "OpenDWG Type Library" section which you can
find here :
http://www.vbdesign.net/expresso/
====================
Do you know how to disable the macro alert dialog through the registery?
thanks
Christian
========
I have a LISP that opens a dialog box, & fills info into attributed blocks.
Part of the LISP allows you to do several blocks in a row, and jump around
in the order that you do them. I want to add an UNDO mark to the LISP, but
as the Dialog is up always, I can't do the old standby of (command "Undo"
"mark") as it crashes every time it comes to this spot. Is there a way to
add an Undo mark without using the command function?
Jonathan Trostad
==============
I would like to add data to the 'drawing properties' window - 'custom' tab.
I found the info in the dxf codes, but I can not figure out how to insert
information into the fields by coding it.
James Herriott
=============
Kenny, i'm trying to search all function available for rtext....
i have this...
$(substr,$(getvar,dwgname),7,2
the substr function work well...
but if i put some other like strcat..
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (12 of 15) [23/03/2005 05:49:33 p.m.]
rtext will not recognise this...
is ther a list or a site who i can see all available function for rtext ??
thanks.
Andrea Andreetti
==============
Hello mr.Kenny
i have a question ,how to take a entity data in a complicated block , for
example
if i create a point command in a line or a circle command , and then i
create in a block.
please ..help me . because i will make in a valve block wich can do triming
automatic in a line command
sorry for my english..
Harris
======
Things Weird and Wonderful
========================
The following links are from the desk of Randall Rath :
"Would you like a new Monitor for Xmas?"
http://www.go-l.com/monitors/grand_canyon/features/index.htm
"Increase your internet connection speed"
http://www.j-walk.com/other/wifispray/
==============
And one that I stumbled across :
"Time Travel"
Imagine a man travelled from the future to collect an old PC to help solve
a tech crisis in 2038. Imagine not - for it's already happened.
Read his compelling story. BTW: World War III is set for 2015.
You've got 12 years to learn some survival techniques.
http://www.johntitor.com/
=====================
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (13 of 15) [23/03/2005 05:49:33 p.m.]
Miscellaneous Stuff that I almost Forgot
================================
I would like to point you towards an open source solution to translation.
Audacity, at http://audacity.sourceforge.net/ is an excellant little program
that works with wav, aif, au, snd, and mp3 files.
Karl Browning
============
The Back Stoep
=============
A comely redhead was thrilled to have obtained a divorce and
dazzled by the skill and virtuosity of her lawyer, not to mention
his healthy income and good looks. In fact, she realized, she had
fallen head over heels in love with him, even though he was a
married man.
"Oh, John," she sobbed at the conclusion of the trial, "isn't
there some way we can be together, the way we were meant to be?"
Taking her by the shoulders, John proceeded to scold her for her
lack of discretion and good judgment.
"Snatched drinks in grimy bars on the edge of town, lying on the
phone, hurried meetings in sordid motels rooms - is that really
what you want for us?" he asked.
"No, no..." she sobbed, heartsick.
"Oh," said the lawyer. "Well, it was just a suggestion."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (14 of 15) [23/03/2005 05:49:33 p.m.]
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
The More you Drink, the Better We Sound!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-22
http://www.afralisp.com/newsletter/2003/2003-22.htm (15 of 15) [23/03/2005 05:49:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-23
=========================
Tuesday 14th October 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
Forecast for tonight: Dark
=========================
The Front Stoep.
==============
Well that's it!!! The Competition is now closed. This weeks entries are listed
below and the winner will be announced next week.
Thanks to all who took the time and effort to participate.
An apology is due to Andrew Canfield for spelling his name wrong last week.
Sorry Andpy!!
A new site has hit the electronic highway.
Pop along but be careful you don't get stuck in
"The Swamp".
http://theswamp.org/phpBB2/index.php
=================================
You might have noticed that I've had a few guest writers over the past couple
of weeks. Well I'd like to extend an open invitation to all readers of this Newsletter
to please feel free to send me any contributions that you would like published.
It does not have to be coding specific but a CAD flavour would be nice.
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (1 of 14) [23/03/2005 05:49:35 p.m.]
Pearls of Wisdom
===============
100% of all smokers die.
So do 100% of all non-smokers.
===============
The Competition
==============
My funniest things that happened at work is when we moved into our new
building 3 years ago in the middle of winter .....
Check out the list below, as we had fun with telling it like it
is when moving into a building that isn't finished.
Monique
TOP TEN 20 LIST OF ..
SIGNS THAT YOU'VE MOVED INTO YOUR NEW BUILDING TOO SOON
(Meant in jest; please enjoy)
1. Don't know what floor you are on in the stairwell (no signs).
2. All the subtrades are "playing" with the HVAC systems and
everyone thinks the design is poor.
3. You have to use a plunger to open the kitchen cupboards
because there is no handles.
4. Contractors (males) are going out on dates with employees (females).
5. Men socialize with women in the washroom because there are no signs.
6. You can't access archived drawings because they're still buried deep in
moving boxes that can't be unpacked until the millwork is complete.
7. Dressing casual is a necessity (or better yet - you're made to do your desk
job wearing steel-toed boots, hard hat and safety glasses).
8. People you speak with on the phone, think that you're on your cell phone
at a construction site.
9. Your vehicle experiences multiple flat tires in your parking lot due to
construction debris.
10. There are bright pink streamers hanging from your ductwork in the
ceiling space.
11. Your deficiency list is 10 pages long and growing.
12. "As-Built" drawings are a work-in-progress.
13. There are no lights in your office.
14. You're in great shape because you've been forced to use the stairs
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (2 of 14) [23/03/2005 05:49:35 p.m.]
until the elevator is operational.
15. You're on a first name basis with all the contractors.
16. You actually need signs to direct visitors to the reception desk.
17. You are forced to dry your hands with toilet paper.
18. You have no heat in your office but there's plenty of hot water running
in the urinals and toilets.
19. Opening the middle kitchen drawer is quite the challenge when you
have to start by opening an end to open the one beside it, because there is
no handles to pull on.
20. It's the weekend and you get stuck in the partially finished elevator,
and can't remember anyone's phone number.
============
Hi Dear.
I guess I'll give it a try. A couple years ago before I left Hungary I used to be a
site supervisor and our workers were mainly Hungarian with the required trade
schools or licenses. So you could say that you were safe. Then I left for a couple
of years and I recently returned from Canada, where I used to design curtain
walls and other structures, can say in a safe environment. I started a renovation
on 5 stories 45 years old steel-structured building as a site supervisor- again. I
represented the principal contractor and had to handle the sub contractors.
What I found was really scary: namely the majority of the workers are now illegally
employed Romanian helpers sold out as trade persons who could not speak Hungarian
or other languages. They had no clue about construction work, demolition, remove
electrical cables, shut down water systems and so on. My nightmare had just begun.
You can imagine how tough the renovation could be on site, this was even worst.
Simple request like "please remove that wire there, then connect it with this and
then make light here to see here turned out to be shocking in body parts, sparking
in eyes, burning around ears. All this happened on a so call Romanian electrician.
Then the other day asking him and showing actually pointing to the next place
where the job was supposed to be started he went to the opposite direction with a
shovel to find job for himself. At this point I needed to fire him. Keep on with my
story for the price, we just finished the reinforcing procedures of the existing I columns
on scaffoldings when I left the staff behind and were heading for the project inspector
who was a tough and strict guy but new on the site. He was front of me about five
meters far and between us was built the three stories of scaffolding. I was smiling,
shaking my hands welcoming him given the impression that as if I really needed him.
Then all of a sudden the two legs - the right and the left - of the scaffolding started to
take over the steering and slowly but firmly right before the inspector collapsed
making me ridiculous. We both were frozen to death. Then I awarded myself with
strength to fire myself to save my own ass from temporarily immigrants though
permanently idiots.
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (3 of 14) [23/03/2005 05:49:35 p.m.]
Regards,
Gabor Meszlenyi
===============
Years ago we relocated our office from one of the oldest buildings in town to a
brand new multi story building with all the modern safety/security features.
Amongst our band of highly professional architects was a rather eccentric man;
well call him Rob, who decided to work back one night to catch up on his work
due to the time lost during the move. Rob got a bit carried away and before he
knew it, he was the only one left in the office and thought it was about time he
called it a night. After packing up, he hopped into an elevator (lift) and pressed
the ground floor button.
When he reached the ground floor, he discovered, to his horror, that the front
doors of the building were electrically locked - he was trapped! Being the quick
thinker he was, he returned to his lift and pressed the button to his floor to call
for help. Unfortunately, the new access control system rendered the lift useless
after hours unless a floor specific swipe card was used. Of course, Rob hadnt
been issued one as yet. He was stuck again. Aah, but wait, the modern lift car
was fitted with an emergency telephone! Rob picked up the receiver and was
automatically connected to an operator at the monitoring service. Rob explained
his predicament, but for some reason, the operator wanted to know the number
of the lift car he was in. Although the number was displayed on an illuminated
pushbutton inside the lift, Rob ventured outside the lift, holding onto the telephone
to see if there was a number on the lift architrave. The lift doors promptly closed
and the lift car returned to its home position at the top floor. Rob was left holding
a telephone with a rather short cord, and it appeared he had been disconnected!!!
It was around about this time, as I recall, that Rob spotted the EXIT signs (probably
illuminated by his RED face) that led him directly to the after hours exit door!
Craig Green
===========
We had a chap, now retired, who had the unbeknownst nickname of "Top of the
line Ed". Everything he bought was, as he went on about it, first rate, the
best.
During an afternoon coffee break, one threatening cloudy day, one of the
guys, Bob, had enough of this first rate bragging. (I'm sure everyone can
empathize, sympathize or even begrudgingly relate to this situation for
there's an Ed in every group).
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (4 of 14) [23/03/2005 05:49:35 p.m.]
Earlier in the day Ed bought two exquisite lampshades that were carefully
placed by the side of his desk until his afternoon journey home.
Bob decided not to take a coffee break that afternoon. When everyone left
the office he took the lampshades from the boxes and hid them out of sight.
When the crew returned Bob joined them on the way back from the washroom.
Bringing attention to the boxes, he sarcastically commented that the
cartons shouldn't be blocking the isle.
Bob proceeded to furiously jump up and down on the boxes, squashing them
pancake flat. Ed looked on with wide eyed chin dropping amazement. When Ed
got excited, his voice increased in pitch, by several octaves.
Finally he let loose in a near foreign dialect.
"Whatdoyouthinkyouaredoing?" he screamed frantically. With hands furiously
sliding up and down the sides of his face, eratically tugging on what
little hair he had left, "Mynewlampshadeswereinthoseboxes" he rambled.
Needless to say, Ed still bragged but kept nothing personal in the office
for the next 15 years.
Kevin
=====
This Incident happened to a work colleague a few years back.
Daryl, being a new draughtsman in a piping design office was asked to help
measure up some piping for an offshore platform. It was explained to Daryl
that the job was for a couple of days, and it would be a good idea to take a
tennis racket, as after the helicopter has taken off, the lads put up the nets
on the helideck ready for a game or two of tennis after work ....
Needless to say, we heard reports back the next day of Daryl boarding the
helicopter with his tennis racket!
(Hope they had a good supply of balls out there?)
Regards S.Rowe
==============
Dear Kennie,
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (5 of 14) [23/03/2005 05:49:35 p.m.]
You asked obout the most depecible thing (among others) that happened to
your readers.
Wel, let me tell you mine.
A couple off years ago my boss assigned me to hold a field check in a
production factory for the process lines and electrical installations.
I also had to make floor-plans including the equipment.
Making cad drawings of everything.
A big job, about 2,5 or 3 years.
When I started they told me they didnt have a real archive so I walked
around the compound to get accustemed to the (very old) buidings and the
people, finding out where all the drawings were.
About day five or six a man named Johnny, who worked ther for over fourty
years and liked a stiff drink every time of the day and did take them, told
me that in the past they did have a central place where they kept all kinds
off documents. It was on the attick off the oldest building.
After spending an hour searching for the key I kicked the door open.
O yeah, it was an archive, but also the home of about thirty rats and fifty
or so bats.
I inmediatly turned around, ran outside and emtied my stomach.
The smell, the stench, you won't belief it.
After my internal organs calmed down and my eyes dried up I looked for
Johnny who always carried a bottle with some home made stuff around to get
myself some medicine, put a hanckerchief over my mouth and nose and went
back inside. A man has to do what a man has to do. Right?
I tried not to tuch anything, because everything was covered with the
excrements and dead bodys of the rats and bats.
Later I organized myself a coverall, a box of disposable gloves and some
mouth caps and started to get all the archive boxes (or what was left of
it) out of there.
During that time Jhonny became a very close friend, or was it his bottle?
Never mind.
We put the boxes in a open shed in the (vainly) hope to get rid of most of
the stench.
When we got everything out I started to open the boxes and visiting Johnny
often.
The rats made havoc of the paper drawings, but strangely they did almost
nothing to the calques.
When after two weeks of air treatment the stench was reduced a little, we
found a company who was willing to phototype the drawings, against a cost
rise of fifty percent.
After that we burned all off the stinking, filthy remains and I could start
my field check.
Eventuallie I finished the job having a good time.
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (6 of 14) [23/03/2005 05:49:35 p.m.]
I still see Johnny now and then for a friendly discussion with his bottle.
This concludes my story of the most dispecable thing that ever happend to
me.
See/here/fax/mail you later.
Joop Moelee
============
I have 3 short ones for you Kenny:
#1
A fellow co-worker, lets just call him Robert, recently bought a new music CD.
Robert is in his early 50s. He had been listening to it non-stop for most of the
day via headphones. Finally at about 4:00 pm he couldnt contain himself anymore.
He unplugged the headphones letting the music play through the PCs speaker.
Next he climbed on top of his desk and proceeded to dance to his new CD.
Those that didnt look at him like he was crazy, were on the floor in tears from
laughter at the sight of a 50 year old man with gray hair dancing on his desk.
#2
Robert also was a bit gullible. A couple of years ago a joke email was circulating
around the office. It was simply a WAV file that shouted HEY EVERYBODY IM
WATCHING PORNO. The body of the email said to turn your volume up before
listening. Well Robert received this email prior to having his headphones plugged
in. Being a bit gullible, he did as instructed and cranked the volume in a library
quiet office. As the file started playing Robert, realizing that it was way too loud,
lunged for his PC which was on top of a drafting table set nearly 3 feet off the ground.
Rather than turning down the volume he hugged his computer attempting to muffle
the sound. Robert also turned candy apple red. Well as if the first time wasnt enough,
one of the CAD guys emailed him the exact same email a few days later. Once again
he cranked up the volume and played it. A few weeks later he received the same file
with a different name. He fell for it again.
#3
A coworker of mine (Bill) asked for my help creating a VBA program. This program
was to draw either a line or an arc between two circles that had known constant radii,
with the line/arc trimmed out of the circle. A selected block was to be inserted at the
midpoint of the line/arc. So I put together the program for Bill and he was happy. A
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (7 of 14) [23/03/2005 05:49:35 p.m.]
month or two later Bill comes up to me and starts chewing me out. Why dont the
lines/arcs go to the points I picked? After a few minutes trying to determine what he
was asking I realized what he was upset about. Then I simply told him, Because that
is what you wanted. Then I explained to him the purpose of the program and that the
line/arc trims itself outside of the circle like you wanted it too.
Andrew Scanlon
===============
Coding
=======
Kenny,
Andrew Cornfields shortsighted comments about AutoLISP deserve a rebuttal.
Lets take his comments one at a time:
1. The world ended and there are no other tools available.
I assume this is a joke and ignore it.
2. You enjoy pain.
I do, I enjoy the pain of having to type 1/6 the code of a C program and 1/2
the code of a VBA program. I enjoy not having to make a bazillion declarations
before getting to write the code that is actually doing the work I need done.
I enjoy not having to remember double or quadruple the amount of syntax
rules to write the code.
3. You don't need any dialogs or graphical user interaction other than the
command line/screen pics in your application.
Not true anymore. You can buy ObjectDCL and have a larger control selection
than one does through VBA and be able to use any other active-X control while
not having to deal with longer VBA code to do the simplest of things. Lispers
can have their cake and eat it too.
4. Lisp is harder than VBA to learn yet still far easier than C or C++.
This is nonsense. Lisp has far fewer syntax rules to remember than VBA. I have
taught people in an hour to write simple Lisp programs, not so for VBA. In the VB
class I took I estimate that people struggled an average of 2 or 3 times the amount
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (8 of 14) [23/03/2005 05:49:35 p.m.]
of class time to do equivalent coding to what they could have accomplished in Lisp.
In fact, almost every Lisper I have known that later went on to VBA complained
about how much longer it was taking them to learn the language compared to what
it took them for Lisp.
5. Parens make you happy (oh look here come the men in white coats for you now)
Parens do make me happy, I always know what expression is modifying what other
expression. I dont have any rules of precedence to remember and I always know how
to write a function because they are all written the same way. Why does this criticism
of Lisp always come from people who have to type 6 times the amount of code and
make all sorts of declarations with gobbledygook lingo that the Lisper is thankfully
spared from?
Yes, if you want to interact with ACCESS then VBA is the better choice. Most real world
code does not involve massive computation or interacting with dozens of other applications.
Computers are fast enough now that only very intensive operations ever demand that a user
gravitate to VBA or ObjectARX. If Autodesk would give users full-fledged Common Lisp instead
of VBA then we would really have something. One can even get around ObjectARX by buying
SharpLISP, writing their code in Lisp and having it translated into ObjectARX code.
Well, thats enough ranting for today. Thanks.
Jeremy Dunn
============
Your evaluation of why and when to use Autolisp is ridiculous! It is very
easy to program dialogue boxes using DCL. Your elitist atittude has given
you tunnel vision for VBA.
thpthkbbthpf
Joe Willis
=========
ello
sorry for my very bad english.
I have a little lisp routine who change all the blocks in a file
to color "ducalque".
j.beylot@wanadoo.fr
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (9 of 14) [23/03/2005 05:49:35 p.m.]
;CODING STARTS HERE
;;*******nom des 9 tables autocad********************************************
;;Layer Table "LAYER"
;; Linetype Table "LTYPE"
;; Named View Table "VIEW"
;; Text Style Table "STYLE"
;; Block Table "BLOCK"
;; Named UCS Table "UCS"
;; Named Application ID Table "APPID"
;; Named Dimension Style Table "DIMSTYLE"
;; Vport Configuration Table "VPORT"
(defun c:ccbl ()
(command "-calque" "co" "8" "*" "")
(command "chprop" "tout" "" "co" "ducalque" "")
(setq coul 256)
(setq entbl0 (tblnext "block" T));;on recupere la liste de definition du
1er bloc de la table des blocs
(while entbl0
(setq nombl0 (cdr (assoc -2 entbl0))); On extrait le nom de la premire entit
(print nombl0)
(while nombl0
(setq AncLst (entget nombl0))
(if (assoc 62 AncLst)
(setq NvLst (subst (cons 62 Coul) (assoc 62 AncLst) AncLst))
(setq NvLst (cons (cons 62 Coul) AncLst))
);;if
(entmod NvLst) ; Mets jour l'entit ds la df. de bloc
(setq nombl0 (entnext nombl0))
);;while

(setq entbl0 (tblnext "block"))
);;while

(command "_REGEN")
);;;*********************
;;(defun CHGC (noment);; / NomEnt LstEnt NomBloc DefBloc Coul AncLst NvLst)
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (10 of 14) [23/03/2005 05:49:35 p.m.]
;; (setq
;; ;;NomEnt (car (entsel "\nSlectionnez une insertion de bloc: "))
;; LstEnt (entget NomEnt) ; On rcupre la liste de dfinition de l'entit INSERT
;; NomBloc (cdr (assoc 2 LstEnt)) ; On extrait le nom du bloc
;; DefBloc (tblsearch "BLOCK" NomBloc) ; On rcupre la liste de dfinition du BLOC
;; NomEnt (cdr (assoc -2 DefBloc)) ; On extrait le nom de la premire entit
;; ;;Coul (acad_colordlg 0)
;; coul 256
;; )
;; (while NomEnt
;; (setq AncLst (entget NomEnt))
;; (if (assoc 62 AncLst)
;; (setq NvLst (subst (cons 62 Coul) (assoc 62 AncLst) AncLst))
;; (setq NvLst (cons (cons 62 Coul) AncLst))
;; )
;; (entmod NvLst) ; Mets jour l'entit ds la df. de bloc
;; (setq NomEnt (entnext NomEnt))
;; )
;; (command "_REGEN")
;; (princ)
;;)
;CODING ENDS HERE
===================
Hi!
Do you have or do you know where i find some arx tutorial?
Pablo Barbosa
============
Firstly great site - I'm now writting and adapting lisp routines on as small scale.
Currently trying to write one that will give a simplified plot interface for our office.
Have looked at your example but would like to be able to select multiple layouts
at the same time. How can I list the layout tabs in the drawing?
Mark Shinkfiled
=============
Is it possible to create a popup list in which you can enter a text as well ??
(in case the list does not contain the right option)
Jaap Sluis
==========
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (11 of 14) [23/03/2005 05:49:35 p.m.]
In your Polyline Bulges By Stig Madsen, 2003
There is a line, (if (= (logand (cdr (assoc 70 entl)) 1) 1)
I am unable to locate anywhere where logand is used again or given a value.
I have not seen anywhere the part (= (logand (cdr (assoc 70 entl)) 1) 1)
What are the 1)1) for?
Kirk Crawford
===========
Hi Kenny:

Thanks for the Newsletter, its very interesting and I'm receiving it normally.
I have one question maybe somebody in the net can help out with this: the
case is there is a cadastral maps which has been created along the time
(many years- about 500K parcels); the parcels in some cases as normal has
been created using polylines, but some of them (quite large number) has been
created using polyface meshes - dont know why, and I simply do not understand
this crazy fact-, this off course create a lot of problems like file size, migration
problems to other software, applications development issues, etc. etc.. The need
of help is to convert the polyface meshes into standard colse polyline. I was be
able to get all the coordinates list but did not be able to found the logic to order
the points list so create a polyline from them. Has some body face wth this problem
so can provide some help or aoe idea on how to solve this?

Thanks in advance,

Alberto
======
You have a great page...and i like to ask a question.
I'm trying to know how to get the ang of a line or pline use this ang to place a
block on the line and break the line too. all these on VBA i know how to in Lisp
but i'm stack with the VBA function or call (break) thank you
Ramon Triana
=============
Things Weird and Wonderful
========================
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (12 of 14) [23/03/2005 05:49:35 p.m.]
Weird Sites :
http://now2000.com/weird/
And, The Weird Site :
http://www.theweirdsite.com/
===============
Miscellaneous Stuff that I almost Forgot
================================
Something we should all read and understand :
The Trusted Computing Push.
This Article is by Ross Anderson who is a Professor
at the University of Cambridge Computer Laboratory
http://www.cl.cam.ac.uk/~rja14/tcpa-faq.html
====================
The ISO 9000 Handbook :
http://www.qsuonline.com/cart/books.html#ISO9KHandbook
==================
The Back Stoep
=============
And from the desk of Michael Perry :
A Swiss scientist has invented a new bra!
It offers more support which will prevent a woman's breasts from bouncing around,
and will keep her nipples hidden.... even in cold temperatures....
After announcing his invention, the scientist was taken outside where a large group
of men beat the sh*t out of him.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (13 of 14) [23/03/2005 05:49:35 p.m.]
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
The More you Drink, the Better We Sound!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-23
http://www.afralisp.com/newsletter/2003/2003-23.htm (14 of 14) [23/03/2005 05:49:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
=========================
AfraLisp Newsletter No 2003-24
=========================
Tuesday 21th October 2003
=========================
http://www.afralisp.com
mailto:afralisp@mweb.com.na
=========================
AutoCAD to PDF?
Pop along to CADzation
http://www.cadzation.com
***********************************
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
=========================
"Bother", said Pooh, as he loaded his last round.
=========================
The Front Stoep.
==============
And the winner of "The Competition" is?
Mmmm........
You'll find out a wee bit further on.................
Next week I'm off on business to Johannesburg and then Cape Town.
I arrive back in Oranjemund on the Thursday and immediately leave for
Windhoek to participate in the "Rock Festival" with the band.
(participate!! - more likely all-fall-down.)
Anyway, because of this punishing schedule of drinking and general
debauchery, I'm afraid there will be no Newsletter next week!!
Sorry about that, but beer drinking and music tends to come first.
Oh, and my wife has gone to visit her mother in Plettenberg Bay
so I'm a "bachelor" for a few weeks. :-))))))))))))))))))))
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (1 of 32) [23/03/2005 05:49:38 p.m.]
=================
And the winner is????
Read on................
Pearls of Wisdom
===============
98% of all constipated people don't give a crap
===============
Coding
=======
Kenny
Having found your site a while ago I now find it a great source of
information. I'm not in the league of some of the guys who use it but I at
least try to keep informed of some of what's happening.
Anyway the time has come to repay some debts and I've included 2 routines I
find useful. Being an amateur there may be better ways of writing these, but
since I'm not getting paid for this and they work for me, they'll do!
One is an automatic layer creation routine, and the other a dimension style
routine.
I'd appreciate any comments you have.
Cheers
Paddy
======
And here's the automatic layer creation routine :
//DCL CODING STARTS HERE
//dcl_settings : default_dcl_settings { audit_level = 0; }
xx : dialog {
label = "Structural Layering Routine";
: text {
label = "Version 2.0 by P Cooney";
}
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (2 of 32) [23/03/2005 05:49:38 p.m.]
: row {
:column {
: boxed_column {
label = "Element";
: list_box {
key = "element";
width = 15;
height = 10;
}
} //close boxed column
: toggle {
key = "reinf";
label = "Reinforcement";
}
}//colse column
: boxed_column {
label = "Sub Elemnent";
: list_box {
key = "subelement";
width = 15;
height = 22;
}
} //close boxed column
: boxed_column {
label = "Line Weight";
: list_box {
key = "lineweight";
width = 15;
height = 22;
}
} //close boxed column
: boxed_column {
label = "Line Type";
: list_box {
key = "linetype";
width = 15;
height = 22;
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (3 of 32) [23/03/2005 05:49:38 p.m.]
}
} //close boxed column
} // close row
ok_cancel_help;
: errtile {
width = 5;
}
}
//DCL CODING ENDS HERE
Save this as "XX.DCL".
Now the AutoLisp coding :
;LISP CODING STARTS HERE
;Automatic Layer creator
;By P.Cooney 22.09.03 pacooney@yahoo.ie
;This routine is by no means perfect but works satisfactorly
;for my use also it's the best I'll do for free!!!
(defun C:xx(/ colour
el
el-list
lineweight-list
linetype
linetype-list
linetype-list1
linetype-list2
linetype-list3
lineweight
ltype
lw
prefix
rein
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (4 of 32) [23/03/2005 05:49:38 p.m.]
reinf
sub_el-list_type
sub-el
subel-list
subelement)
(setq WHAT_NEXT 2)
(while (>= WHAT_NEXT 2)
(setq dcl_id (load_dialog "xx"))
(if (not (new_dialog "xx" dcl_id)) (exit))
;;BUILD ELEMENT LIST
(setq el-list (list "Concrete" "Steel" "Furniture" "Standard" "Line"))
;;
;;BUILD LINE WEIGHT LIST
(setq lineweight-list (list "Red" "Yellow" "Green" "Cyan" "Blue" "Magenta"
"White" "Grey" "L. Grey" "Shade 251" "Shade 252" "Shade 253" "Shade 254"))
;;
;;BUILD LINETYPE LIST
(setq linetype-list1 (list "continuous" "border" "centre"
"dash dot" "dashed"
"divide" "dot" "hidden" "phantom" ))
(setq linetype-list2 (list "----------" "border2" "centre2"
"dash dot2" "dashed2"
"divide2" "dot2" "hidden2" "phantom2" ))
(setq linetype-list3 (list "----------" "borderx2" "centrex2"
"dash dotX2" "dashedx2"
"dividex2" "dotx2" "hiddenx2" "phantomx2" ))
(setq linetype-list (append linetype-list1 linetype-list2 linetype-list3))
;;
(start_list "element")
(mapcar 'add_list el-list)
(end_list)
(start_list "lineweight")
(mapcar 'add_list lineweight-list)
(end_list)
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (5 of 32) [23/03/2005 05:49:38 p.m.]
(start_list "linetype")
(mapcar 'add_list linetype-list)
(end_list)
(action_tile "element" "(progn (setq sub_el-list_type (atoi $value))
(do_element-list))")
(action_tile "subelement" "(progn (setq subelement (atoi $value)))")
(action_tile "lineweight" "(progn (setq lineweight (atoi $value)))")
(action_tile "linetype" "(progn (setq linetype (atoi $value)))")
(action_tile "rules" "(done_dialog 4)")
(action_tile "accept" "(do_rein)(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq WHAT_NEXT (start_dialog))
(cond
((= WHAT_NEXT 0) (EXIT))
((= WHAT_NEXT 5) (do_help))
);end cond
);end while
(unload_dialog dcl_id)
(do_lineweight)
(do_linetype)
(do_subelement)
(do_layer-construct)
)(PRINC)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_element-list()
;CONCRETE
(if (= sub_el-list_type 0)
(progn
(setq el "c")
(setq subel-list (list "CONCRETE" "Abutment" "Approach Slab" "Barrier" "Beam"
"Bearing" "Blinding" "Box" "Column" "Deck" "Footing" "Grout" "Headstock"
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (6 of 32) [23/03/2005 05:49:38 p.m.]
"Pier" "Pile" "Pile Cap" "Ret. Wall" "Slab" "Stair" "Wall" ))
(start_list "subelement")
(mapcar 'add_list subel-list)
(end_list)
);end progn
)end if
;STEEL
(if (= sub_el-list_type 1)
(progn
(setq el "s")
(setq subel-list (list "STEEL" "Beam" "Bolt" "Brace" "Caldding" "Column"
"Fly Bracing" "Hanger" "Panel" "Pipe" "Pile" "Purlin" "Railings" "Stair"
"Strut" "Truss"))
(start_list "subelement")
(mapcar 'add_list subel-list)
(end_list)
);end progn
)end if
;FURNITURE
(if (= sub_el-list_type 2)
(progn
(setq el "f")
(setq subel-list (list "Barrier" "Bus Stop" "Fence" "Lightpole"
"Sign" "Traffic Light" ))
(start_list "subelement")
(mapcar 'add_list subel-list)
(end_list)
);end progn
)end if
;STANDARD
(if (= sub_el-list_type 3)
(progn
(setq el "")
(setq subel-list (list "_barscale" "_dims" "_grid" "_hatch" "_legends"
"_notes" "_rev" "_schedules" "_symbols" "_text" "_text18" "_text25"
"_text30" "_text35" "_text50" "_text70" "_xref" "defpoints" ))
(start_list "subelement")
(mapcar 'add_list subel-list)
(end_list)
);end progn
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (7 of 32) [23/03/2005 05:49:38 p.m.]
)end if
;LINE
(if (= sub_el-list_type 4)
(progn
(setq el "line")
(setq subel-list (list ))
(start_list "subelement")
(mapcar 'add_list subel-list)
(end_list)
);end progn
)end if
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_rein()
(setq rein (get_tile "reinf"))
(if (= rein "1")(setq reinf "-reinf" ))
(if (= rein "0")(setq reinf "" ))
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_lineweight()
(if (= 0 lineweight) (progn (setq lw "50") (setq colour "1")))
(if (= 1 lineweight) (progn (setq lw "35") (setq colour "2")))
(if (= 2 lineweight) (progn (setq lw "50") (setq colour "3")))
(if (= 3 lineweight) (progn (setq lw "70") (setq colour "4")))
(if (= 4 lineweight) (progn (setq lw "70") (setq colour "5")))
(if (= 5 lineweight) (progn (setq lw "25") (setq colour "6")))
(if (= 6 lineweight) (progn (setq lw "25") (setq colour "7")))
(if (= 7 lineweight) (progn (setq lw "10") (setq colour "8")))
(if (= 8 lineweight) (progn (setq lw "18") (setq colour "9")))
(if (= 9 lineweight) (progn (setq lw "251") (setq colour "251")))
(if (= 10 lineweight) (progn (setq lw "252") (setq colour "252")))
(if (= 11 lineweight) (progn (setq lw "253") (setq colour "253")))
(if (= 12 lineweight) (progn (setq lw "254") (setq colour "254")))
(if (= lineweight nil) (progn (setq lw "25") (setq colour "7")))
)(princ)
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (8 of 32) [23/03/2005 05:49:38 p.m.]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_linetype()
(if (= 0 linetype) (progn (setq linetype "continuous") (setq ltype "")))
(if (= 1 linetype) (progn (setq linetype "border") (setq ltype "-b")))
(if (= 2 linetype) (progn (setq linetype "center") (setq ltype "-c")))
(if (= 3 linetype) (progn (setq linetype "dashdot") (setq ltype "-dd")))
(if (= 4 linetype) (progn (setq linetype "dashed") (setq ltype "-d")))
(if (= 5 linetype) (progn (setq linetype "divide") (setq ltype "-di")))
(if (= 6 linetype) (progn (setq linetype "dot") (setq ltype "-do")))
(if (= 7 linetype) (progn (setq linetype "hidden") (setq ltype "-h")))
(if (= 8 linetype) (progn (setq linetype "phantom") (setq ltype "-p")))
(if (= 9 linetype) (progn (setq linetype "continuous") (setq ltype "")))
(if (= 10 linetype) (progn (setq linetype "border2") (setq ltype "-b2")))
(if (= 11 linetype) (progn (setq linetype "center2") (setq ltype "-c2")))
(if (= 12 linetype) (progn (setq linetype "dashdot2") (setq ltype "-dd2")))
(if (= 13 linetype) (progn (setq linetype "dashed2") (setq ltype "-d2")))
(if (= 14 linetype) (progn (setq linetype "divide2") (setq ltype "-di2")))
(if (= 15 linetype) (progn (setq linetype "dot2") (setq ltype "-do2")))
(if (= 16 linetype) (progn (setq linetype "hidden2") (setq ltype "-h2")))
(if (= 17 linetype) (progn (setq linetype "phantom2") (setq ltype "-p2")))
(if (= 18 linetype) (progn (setq linetype "continuous") (setq ltype "")))
(if (= 19 linetype) (progn (setq linetype "borderx2") (setq ltype "-bx2")))
(if (= 20 linetype) (progn (setq linetype "centerx2") (setq ltype "-cx2")))
(if (= 21 linetype) (progn (setq linetype "dashdotx2") (setq ltype "-ddx2")))
(if (= 22 linetype) (progn (setq linetype "dashedx2") (setq ltype "-dx2")))
(if (= 23 linetype) (progn (setq linetype "dividex2") (setq ltype "-dix2")))
(if (= 24 linetype) (progn (setq linetype "dotx2") (setq ltype "-dox2")))
(if (= 25 linetype) (progn (setq linetype "hiddenx2") (setq ltype "-hx2")))
(if (= 26 linetype) (progn (setq linetype "phantomx2") (setq ltype "-p")))
(if (= linetype nil) (progn (setq linetype "continuous") (setq ltype "")))
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_subelement()
(setq prefix "st_")
(cond
((= sub_el-list_type 0) (do_concrete))
((= sub_el-list_type 1) (do_steel))
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (9 of 32) [23/03/2005 05:49:38 p.m.]
((= sub_el-list_type 2) (do_furniture))
((= sub_el-list_type 3) (do_standard))
((= sub_el-list_type 4) (do_line))
)
);end defun
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_concrete()
(cond
((= subelement 0) (setq sub-el "-conc"))
((= subelement 1) (setq sub-el "-abut"))
((= subelement 2) (setq sub-el "-aslab"))
((= subelement 3) (setq sub-el "-barrier"))
((= subelement 4) (setq sub-el "-beam"))
((= subelement 5) (setq sub-el "-bearing"))
((= subelement 6) (setq sub-el "-blinding"))
((= subelement 7) (setq sub-el "-box"))
((= subelement 8) (setq sub-el "-column"))
((= subelement 9) (setq sub-el "-deck"))
((= subelement 10) (setq sub-el "-footing"))
((= subelement 11) (setq sub-el "-grout"))
((= subelement 12) (setq sub-el "-headstock"))
((= subelement 13) (setq sub-el "-pier"))
((= subelement 14) (setq sub-el "-pile"))
((= subelement 15) (setq sub-el "-pilecap"))
((= subelement 16) (setq sub-el "-retwall"))
((= subelement 17) (setq sub-el "-slab"))
((= subelement 18) (setq sub-el "-stair"))
((= subelement 19) (setq sub-el "-wall"))
)
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_steel()
(cond
((= subelement 0 ) (setq sub-el "-steel"))
((= subelement 1 ) (setq sub-el "-beam"))
((= subelement 2 ) (setq sub-el "-bolt"))
((= subelement 3 ) (setq sub-el "-brace"))
((= subelement 4 ) (setq sub-el "-cladding"))
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (10 of 32) [23/03/2005 05:49:38 p.m.]
((= subelement 5 ) (setq sub-el "-column"))
((= subelement 6 ) (setq sub-el "-flybrace"))
((= subelement 7 ) (setq sub-el "-hanger"))
((= subelement 8 ) (setq sub-el "-panel"))
((= subelement 9 ) (setq sub-el "-pipe"))
((= subelement 10 ) (setq sub-el "-pile"))
((= subelement 11 ) (setq sub-el "-purlin"))
((= subelement 12 ) (setq sub-el "-railings"))
((= subelement 13 ) (setq sub-el "-stair"))
((= subelement 14 ) (setq sub-el "-strut"))
((= subelement 15 ) (setq sub-el "-truss"))
)
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_furniture()
(cond
((= subelement 0 ) (setq sub-el "-barrier"))
((= subelement 1 ) (setq sub-el "-bus stop"))
((= subelement 2 ) (setq sub-el "-fence"))
((= subelement 3 ) (setq sub-el "-lightpole"))
((= subelement 4 ) (setq sub-el "-sign"))
((= subelement 5 ) (setq sub-el "-trafficlight"))
)
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_standard()
(setq ltype "")(setq lw "")(setq prefix "")
(cond
((= subelement 0) (setq sub-el "_barscale"))
((= subelement 1) (setq sub-el "_dims"))
((= subelement 2) (setq sub-el "_grid"))
((= subelement 3) (setq sub-el "_hatch"))
((= subelement 4) (setq sub-el "_legends"))
((= subelement 5) (setq sub-el "_notes"))
((= subelement 6) (setq sub-el "_rev"))
((= subelement 7) (setq sub-el "_schedules"))
((= subelement 8) (setq sub-el "_symbols"))
((= subelement 9) (setq sub-el "_text"))
((= subelement 10) (setq sub-el "_text18"))
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (11 of 32) [23/03/2005 05:49:38 p.m.]
((= subelement 11) (setq sub-el "_text25"))
((= subelement 12) (setq sub-el "_text30"))
((= subelement 13) (setq sub-el "_text35"))
((= subelement 14) (setq sub-el "_text50"))
((= subelement 15) (setq sub-el "_text70"))
((= subelement 16) (setq sub-el "_xref"))
((= subelement 17) (setq sub-el "defpoints"))
)
)(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_line()
(setq sub-el "")(setq prefix "")
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_layer-construct()
(progn
(setq nlayer (strcat prefix el sub-el reinf lw ltype))
(command ".layer" "m" nlayer "c" colour "" "lt" linetype "" "")
);end progn
(prompt "\n Layer ") (princ nlayer) (prompt " is the current layer.")
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun do_help (/ alrt1 alrt2 alrt3 alrt4 alrt5 alrt6 alrt7 alrt8 alrt9
alrt10 alrt11 alrt12 alrt13)
(setq alrt1 "\nLayer construction built on following convention.")
(setq alrt2 "\nPrefix of 'st_' denotes structural layer")
(setq alrt3 "\ncolumn 1 - denotes element category")
(setq alrt4 "\ncolumn 2 - denotes sub element category")
(setq alrt5 "\ncolumn 3 - denotes line weight")
(setq alrt6 "\ncolumn 4 - denotes line type")
(setq alrt7 "\n\nReinforcement check box adds annotation of 'reinf'")
(setq alrt8 "\nto layer name to denote reinforcement layer")
(setq alrt9 "\n\nPreferably always check one item in each column.")
(setq alrt10 "\n")
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (12 of 32) [23/03/2005 05:49:38 p.m.]
(setq alrt11 "\nIf you don't like this don't use it!")
(setq alrt12 "\n\nTry and use a layer convention that makes sence!")
(setq alrt13 "\n")
(alert (strcat alrt1 alrt2 alrt3 alrt4 alrt5 alrt6 alrt7 alrt8 alrt9 alrt10
alrt11 alrt12 alrt13))
(princ)
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;LISP CODING ENDS HERE
======================
Okay, serious this time.
THE WINNER IS...................
=============
The question was.........
I will make in a valve block wich can do triming
automatic in a line command.
=========
This how i do it
My blocks are build up from 2 blocks 1 grapic block (used for trim function) a
nd the final block with attributes end the grapical block the grapical block has
the same name as the final block with "G_" in front of it, so as the final block is
named "VALVE" the grapic block is named "G_VALVE"
(example block T9Y1100.dwg)

When this function is called after inserting a block it first finds out wich block
was inserted last then it chesk's if this block has a grapical block if so it inserts
the grapical block and draws a boundery box around it this boundery box is
used as a fence for the trim function both vertical as horizontal

To use this function load insbreek- insert your block - (breek_sym_S)
[to get the blockname and it's insertionpoint] -(insbreek_S) [the actual trim function]
(the remarks (comments) in this file are in dutch but it works fine - the uservar's
I use to interact with VBA but that is a different story)

R.F. (Rob) Hemelop
================
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (13 of 32) [23/03/2005 05:49:38 p.m.]
;CODING STARTS HERE
;*************************************************************************************
;************ extra trim functie die lijnen onder geplaatste blokken trimt************
;************ 11-02-2002 rfheme ************
;*************************************************************************************
;---------------------------------------------------------------------
;hulpfunctie t.b.v. insbreek_S (slaat de naam op van het geplaatse blok)
;---------------------------------------------------------------------
(defun breek_sym_S()
;*******************************************************************
;BLOK NAAM OPVRAGEN VAN LAATST GEPLAATSTE SYMBOOL
;*******************************************************************
(Setq LAST_BLOCK_NAME (CDR(ASSOC 2 (ENTGET(ENTLAST)))))
;************************************************************************
;INSERTIE PUNT OPVAGEN VAN LAATST GEPLAATSTE SYMBOOL
;************************************************************************
(Setq INS_POINT(CDR (ASSOC 10(ENTGET(ENTLAST)))))
(setq ins_x (nth 0 ins_point))
(setq ins_y (nth 1 ins_point))
)
;---------------------
;hoofdfunctie insbreek_S
;---------------------
(defun INSBREEK_S ( / vname minExt maxExt)
(vl-load-com)
(setq old_osmode (getvar "osmode"))
(setvar "osmode" 0)
;**********************************************************
;BLOK NAAM GRAFISCH SYMBOOL SAMEN STELLEN
;**********************************************************
(if (/= (getvar "users5") "Nothing")
(progn
(Setq GR_BLOCK_NAME_1 (STRCAT LAST_BLOCK_NAME "_G"))
(Setq GR_BLOCK_NAME_2 (STRCAT "G_" LAST_BLOCK_NAME))
)
(progn
(Setq GR_BLOCK_NAME_1 (STRCAT "Nothing" "_G"))
(Setq GR_BLOCK_NAME_2 (STRCAT "G_" "Nothing"))
(setvar "users5" "Ok")
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (14 of 32) [23/03/2005 05:49:38 p.m.]
)
)
;**************************************************************
;Nagaan of het laatst geplaatste een grafisch blok bevat
;**************************************************************
(setq GR_BLOK_1 (tblsearch "block" GR_BLOCK_NAME_1))
(setq GR_BLOK_2 (tblsearch "block" GR_BLOCK_NAME_2))
(if (/= GR_BLOK_1 nil)
(setq GR_BLOCK_NAME GR_BLOCK_NAME_1)
)
(if (/= GR_BLOK_2 nil)
(setq GR_BLOCK_NAME GR_BLOCK_NAME_2)
)
(IF (or (/= GR_BLOK_1 nil)(/= GR_BLOK_2 nil))
(Progn
;************************************************************
;GRAFISCH BLOK INSERTEN t.b.v. BREKEN VAN DE LIJN
;************************************************************
(COMMAND "-INSERT" GR_BLOCK_NAME INS_POINT "1" "1" "0.0")
(setq ename (entlast))
(setq vname (vlax-ename->vla-object ename))
(vla-GetBoundingBox vname' minExt 'maxExt)
;**********************************************************************************
;Minext is het punt dat de onder/boven waarde bevat t.o.v. het insertiepunt
;**********************************************************************************
(setq minExt (vlax-safearray->list minExt))
(Setq min_x (nth 0 minExt))
(Setq min_y (nth 1 minExt))
;*********************************************************************************
******************
;Maxext is het punt dat de breedte van het symbool aan geeft op lijn met het
insertie punt
;*********************************************************************************
******************
(setq maxExt (vlax-safearray->list maxExt))
(Setq max_x (nth 0 maxExt))
(Setq max_y (nth 1 maxExt))
;**************************************
;Grafisch symbool weer weghalen
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (15 of 32) [23/03/2005 05:49:38 p.m.]
;**************************************
(SETQ OLD_USERS5 (GETVAR "USERS5"))
(SETVAR "USERS5" "NO")
(COMMAND ".ERASE" "L" "")
(SETVAR "USERS5" OLD_USERS5)
(setq Layer_aanwezig (tblsearch "layer" "insbreak"))
(if (= Layer_aanwezig nil)
(command "-layer" "m" "insbreak" "c" "1" "insbreak" "")
(command "-layer" "s" "insbreak" "")
)
(COMMAND "_rectang" minExt maxExt)
(Setq EDGE_BOX (entlast))
(COMMAND "-Layer" "LO" "insbreak" "")
(command "-layer" "s" "0" "")
;**********************************************************************************
;Selectiepunt samenstelen t.b.v. trimmen van de lijnen onder het symbool
;**********************************************************************************
(Setq F_POINT_1 (Strcat (RTOS(+ MIN_X (/ (- MAX_X MIN_X) 2))) "," (RTOS MAX_Y)))
(Setq F_POINT_2 (Strcat (RTOS(+ MIN_X (/ (- MAX_X MIN_X) 2))) "," (RTOS MIN_Y)))
(Setq F_POINT_3 (Strcat (RTOS MAX_X) "," (RTOS(+ MIN_Y (/ (- MAX_Y MIN_Y) 2)))))
(Setq F_POINT_4 (Strcat (RTOS MIN_X) "," (RTOS(+ MIN_Y (/ (- MAX_Y MIN_Y) 2)))))
(Setq I_POINT (STRCAT (RTOS INS_X) "," (RTOS INS_Y)))
(IF (OR(= I_POINT F_POINT_1)(= I_POINT F_POINT_2)(= I_POINT F_POINT_3)
(= I_POINT F_POINT_4))
(PROGN
(COMMAND "Trim" "L" "" "F" minExt maxExt "" "")
)
(PROGN
(COMMAND "Trim" "L" "" "F" F_POINT_1 F_POINT_2 "" "F" F_POINT_3 F_POINT_4 "" "")
)
)
(COMMAND "-Layer" "U" "insbreak" "")
(SETQ OLD_USERS5 (GETVAR "USERS5"))
(SETVAR "USERS5" "NO")
(COMMAND ".ERASE" EDGE_BOX "")
(SETVAR "USERS5" OLD_USERS5)
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (16 of 32) [23/03/2005 05:49:38 p.m.]
) ; end progn
) ; end if
(setvar "osmode" old_osmode)
) ; end defun insbreek_S
)
;CODING ENDS HERE
==================
Or, you could have a wee read here :
http://www.afralisp.com/lispa/lisp52.htm
==================
Working with maps in Autocad, I repeatedly have the problem of some idiot
inserting the same block (say a street name) in the exact same spot multiple
times. It creates a real hassle when you move one block out of the way only
to discover 3 more underneath. I wasn't able to find any routines to fix
this problem, so I wrote my own.
David Weffald
============
;;CODING STARTS HERE
;;Objective: Find all doubled blocks and move them to a new layer called
;;DUPLICATE_BLOCKS. (c) 2003 David J. Weffald
;;ashburndesign@qwest.net
(defun compare (ss_entity ss_chk_entity)
(setq blk_ctr 0)
(setq chk_blk_ctr 0)
(setq e1(entnext ss_entity))
(setq a1(entget e1))
(setq i1(cdr (assoc 1 a1)))
(setq chk_e1(entnext ss_chk_entity))
(setq chk_a1(entget chk_e1))
(setq chk_i1(cdr (assoc 1 chk_a1)))
(while (/= i1 nil)
(setq e1(entnext e1))
(setq a1(entget e1))
(setq i1(cdr (assoc 1 a1)))
(setq chk_e1(entnext chk_e1))
(setq chk_a1(entget chk_e1))
(setq chk_i1(cdr (assoc 1 chk_a1)))
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (17 of 32) [23/03/2005 05:49:38 p.m.]
(if (/= i1 "")(setq blk_ctr (1+ blk_ctr)))
(if (/= chk_i1 "")(setq chk_blk_ctr (1+ chk_blk_ctr)))
)
(if (<= blk_ctr chk_blk_ctr)(setq dup_obj ss_entity)
(setq dup_obj ss_chk_entity))
(Command "layer" "M" "DUPLICATE_BLOCKS" "")
(setq dup_obj (entget dup_obj))
(setq dup_obj (subst (cons 8 "DUPLICATE_BLOCKS")
(assoc 8 dup_obj) dup_obj ))
(entmod dup_obj)
); end defun compare
;; Main Program
(defun C:DUPBLKF (/)
(SetVar "CMDECHO" 0)
(setq ss_initial(ssget "_x"))
;;Collects all entities in drawing.
(setq ss_blocks(ssadd))
;;Creates an empty Selection Set to add the Blocks to.
(setq sslen(sslength ss_initial))
;;Determines how many entities were collected.
(setq ctr 0)
(while (< ctr sslen)
;;Will run until counter reaches the number of entities collected.
(setq ss_initial_name(ssname ss_initial ctr))
;; Returns entity name for item ctr in ss_initial.
(setq blk1(entget ss_initial_name))
;; Returns complex info for entity.
(setq is_blk(cdr (assoc 0 blk1)))
;; Extracts text string indicating the entity type.
(if (= is_blk "INSERT") (progn
;; Verifies object is a block.
;; Do this once object is verified as a block.
(ssadd ss_initial_name ss_blocks)
;; Add object to ss_blocks
); End progn
); End if
(setq ctr (+ ctr 1))
); End while
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (18 of 32) [23/03/2005 05:49:38 p.m.]
(setq ss_initial nil)
(setq ctr 0)
(setq sslen(sslength ss_blocks))
(while (< ctr sslen)
(setq ss_entity(ssname ss_blocks ctr)
;; Returns entity name for item ctr in ss_blocks.
ss_name(entget ss_entity)
;; Returns complex info for entity.
coords (cdr (assoc 10 ss_name))
;; Returns coordinates info for entity.
rotation (cdr (assoc 50 ss_name))
;; Returns rotation angle info for entity.
name (cdr (assoc 2 ss_name))
;; Returns block name for entity.
x (rtos (nth 0 coords) 2 4)
;; Sets x coordinate as a string.
y (rtos (nth 1 coords) 2 4)
;; Sets y coordinate as a string.
coords (strcat x "," y)
;; Sets x,y coordinates as a string.
ang (angtos rotation 0 2)
;; Sets rotation angle as a string.
eval_ctr (+ ctr 1)
)
;; Start the evaluation process
(while (< eval_ctr sslen)
(setq ss_chk_entity(ssname ss_blocks eval_ctr)
;; Returns entity name for item ctr in ss_blocks.
ss_chk_name(entget ss_chk_entity)
;; Returns complex info for entity.
chk_coords (cdr (assoc 10 ss_chk_name))
;; Returns coordinates info for entity.
rotation (cdr (assoc 50 ss_name))
;; Returns rotation angle info for entity.
chk_name (cdr (assoc 2 ss_name))
;; Returns block name for entity.
x (rtos (nth 0 chk_coords) 2 4)
;; Sets x coordinate as a string.
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (19 of 32) [23/03/2005 05:49:38 p.m.]
y (rtos (nth 1 chk_coords) 2 4)
;; Sets y coordinate as a string.
chk_coords (strcat x "," y)
;; Sets x,y coordinates as a string.
chk_ang (angtos rotation 0 2)
;; Sets rotation angle as a string.
)
(if (= coords chk_coords)(progn
(if (and (= ang chk_ang)(= name chk_name))(progn
(compare ss_entity ss_chk_entity)
)
)
)
)
(setq eval_ctr (+ eval_ctr 1))
); End nested while
(setq ctr (+ ctr 1))
); End while
;; Free up memory
(setq a1 nil
ang nil
blk_ctr nil
blk1 nil
chk_a1 nil
chk_ang nil
chk_blk_ctr nil
chk_coords nil
chk_e1 nil
chk_i1 nil
chk_name nil
coords nil
ctr nil
dup_obj nil
e1 nil
eval_ctr nil
i1 nil
is_blk nil
name nil
rotation nil
ss_blocks nil
ss_chk_entity nil
ss_chk_name nil
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (20 of 32) [23/03/2005 05:49:38 p.m.]
ss_entity nil
ss_initial_name nil
ss_name nil
sslen nil
x nil
y nil
)
(SetVar "CMDECHO" 1)
(princ)
);; end defun DUPBLKF
(princ)
;CODING ENDS HERE
==================
Scenario :
You are working in Model Space and decide that you
need to enlarge or reduce a certain portion of your drawing
to create a detail view. Unfortunately, your dimension values
will now all be changed according to the scale value you choose.
This wee program will help alleviate that.
Simple, but it works and could even be expanded upon.
Any suggestions/volunteers???
First the DCL coding :
//DCL CODING STARTS HERE
scaledim : dialog {
label = "Detail Scale Dim";
: column {
: boxed_radio_row {
fixed_height = true;
label = "Scale Type :";
: radio_button {
label = "&Enlarge";
key = "rb1";
value = "1";
}
: radio_button {
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (21 of 32) [23/03/2005 05:49:38 p.m.]
label = "&Reduce";
key = "rb2";
}
}
: spacer {
}
: edit_box {
label = "&Scale Factor :" ;
key = "eb1" ;
edit_width = 8 ;
}
: spacer {
}
: boxed_row {
label = "New Scale :";

: text_part {
key = "txt2";
}
: button {
key = "nscale";
label = "&Calc...." ;
fixed_width = true;
}
}
: spacer {
}
: boxed_row {
label = "Drawing Scale :";

: text_part {
key = "txt1";
}
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (22 of 32) [23/03/2005 05:49:38 p.m.]
: button {
key = "dscale";
label = "&Reset " ;
fixed_width = true;
}
}
: spacer {}
:spacer { width = 1;}

ok_cancel ;

}
}
//DCL CODING ENDS HERE
Save this as "ScaleDim.dcl"
========
And the AutoLisp coding :
;AUTOLISP CODING STARTS HERE
(defun C:scaledim ( / userclick scaletype dcl_id dscale oscale thescale)
(setq userclick T)
(setq scaletype "up")

(setq dcl_id (load_dialog "scaledim.dcl"))
(if (not (new_dialog "scaledim" dcl_id) ) (exit))

(set_tile "rb1" "1")
(set_tile "eb1" "1")
(mode_tile "eb1" 2)
(setq dscale (strcat "1 : " (rtos (getvar "dimscale"))))
(set_tile "txt1" dscale)
(setq oscale (* (getvar "dimscale") (getvar "dimlfac")))
(setq oscale (strcat "1 : " (rtos oscale)))
(set_tile "txt2" oscale)
(action_tile "rb1"
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (23 of 32) [23/03/2005 05:49:38 p.m.]
"(setq scaletype \"up\") (mode_tile \"eb1\" 2)")
(action_tile "rb2"
"(setq scaletype \"down\") (mode_tile \"eb1\" 2)")

(action_tile "cancel"
"(done_dialog)(setq userclick nil)")
(action_tile "accept"
(strcat
"(progn (setq nscale (atof (get_tile \"eb1\")))"
"(done_dialog) (setq userclick T))")
)
(action_tile "dscale"
"(setvar \"DIMLFAC\" 1.0) (set_tile \"eb1\" \"1\") (calcscale) ")
(action_tile "nscale"
"(calcscale)")

(start_dialog)
(unload_dialog dcl_id)

(if userclick
(progn
(if (= scaletype "up")
(setvar "DIMLFAC" (/ 1.0 nscale))
(setvar "DIMLFAC" nscale)
);if
);progn

);if

(princ)

);defun
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (24 of 32) [23/03/2005 05:49:38 p.m.]
(defun calcscale ( )
(setq thescale (atof (get_tile "eb1")))
(if (= scaletype "up")
(setq thescale (/ (getvar "dimscale") thescale))
(setq thescale (* (getvar "dimscale") thescale))
);if
(setq thescale (strcat "1 : " (rtos thescale)))
(set_tile "txt2" thescale)
)
;;;*-------------------------------------------------------------------------
(princ)
;AUTOLISP CODING ENDS HERE
Save this as "ScaleDim.lsp".
Copy a portion of your drawing and scale it up by say 2.
Now run "ScaleDim" and enter "2" as your scale factor.
Select the "Calc" button and you will get the new scale
for your detail. Now dimension your detail and see what happens.
Select the "Reset" button to return to your normal scale.
=============
Kenny,
I was reading your tutorial on Bulges,
http://www.afralisp.com/lisp/Bulges1.htm
and remembered I had these maths functions.
I think someone will find them very usefull.
Mike
=====
;CODING STARTS HERE
;Tangent (X) = cos(X) / sin(X)
;
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (25 of 32) [23/03/2005 05:49:38 p.m.]
(defun Tan (X)
(if (zerop (cos X))
(prompt "Tangent error.")
(/ (sin X) (cos X))))
;----------------------------------------------------------
;Inverse Cosine Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + pi/2
;
(defun arccos (cs)
(cond
((> (abs cs) 1.0) (prompt " Arc-cosine error."))
((equal cs 1.0 0.000000001)
0.0)
((equal cs -1.0 0.000000001)
pi)
(t
(-
(/ pi 2)
(atan (/ cs (sqrt (- 1 (* cs cs)))))))))
;----------------------------------------------------------
;Inverse Sine Arcsin(X) = Atn(X / Sqr(-X * X + 1))
;
(defun arcsin (sn)
(cond
((> (abs sn) 1.0) (prompt " Arc-sine error."))
((equal (abs sn) 1.0 0.000000001)
(* sn (/ pi 2)))
((zerop sn)
0.0)
(t
(atan (/ sn (sqrt (- 1 (* sn sn))))))))
;----------------------------------------------------------
;Secant Sec(X) = 1 / Cos(X)
;
(defun Sec (X)
(if (zerop (cos X))
(prompt "Secant error.")
(/ 1.0 (cos X))))
;----------------------------------------------------------
;Cosecant Cosec(X) = 1 / Sin(X)
;
(defun CoSec (X)
(if (zerop (sin X))
(prompt "Cosecant error.")
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (26 of 32) [23/03/2005 05:49:38 p.m.]
(/ 1.0 (sin X))))
;----------------------------------------------------------
;Cotangent Cotan(X) = 1 / Tan(X)
;
(defun CoTan (X)
(if (zerop (Tan X))
(prompt "Cotangent error.")
(/ 1.0 (Tan X))))
;----------------------------------------------------------
;VectMag (V) = sqrt(V1^2 + V2^2 + V3^2)
;
(defun VectMag (V)
(sqrt
(apply '+
(mapcar '* V V))))
;----------------------------------------------------------
;UnitVect (V) = V/VectMag(V)
;
(defun UnitVect (V / TMP)
(setq TMP (VectMag V))
(mapcar '(lambda (X) (/ X TMP)) V)
)
;----------------------------------------------------------
;VectAdd (Pt V)
;
(defun VectAdd (Pt V)
(mapcar '+ PT V))
;----------------------------------------------------------
;VectAngle (V) = angle in XY plane
;
(defun VectAngle (V)
(angle '(0 0 0) V))
;----------------------------------------------------------
;ApplyCoeff (Clist X)
; f(x) = Clist(0) +
; Clist(1) * X +
; Clist(2) * X^2 + ...
; Clist(n) * X^n
;
(defun ApplyCoeff (Clist X / I Res)
(setq Res 0.0
I 0)
(foreach CC Clist
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (27 of 32) [23/03/2005 05:49:38 p.m.]
(setq Res (+ Res
(* CC (expt X I)))
I (1+ I)))
RES)
;----------------------------------------------------------
;CODING ENDS HERE
==================
Trumpets trumpet, drums drum, nubile young wenches throw
themselves at your feet, the sun comes out, the rain stops,
the grass is green and the swallows swallow.
Why?????
'COS THE WINNER IS...............
**************************
*****Joop Moelee*****
mailto:J.F.Moelee@heineken.nl
**************************
A couple off years ago my boss assigned me to hold a field check in a
production factory for the process lines and electrical installations.
I also had to make floor-plans including the equipment.
Making cad drawings of everything.
A big job, about 2,5 or 3 years.
When I started they told me they didnt have a real archive so I walked
around the compound to get accustemed to the (very old) buidings and the
people, finding out where all the drawings were.
About day five or six a man named Johnny, who worked ther for over fourty
years and liked a stiff drink every time of the day and did take them, told
me that in the past they did have a central place where they kept all kinds
off documents. It was on the attick off the oldest building.
After spending an hour searching for the key I kicked the door open.
O yeah, it was an archive, but also the home of about thirty rats and fifty
or so bats.
I inmediatly turned around, ran outside and emtied my stomach.
The smell, the stench, you won't belief it.
After my internal organs calmed down and my eyes dried up I looked for
Johnny who always carried a bottle with some home made stuff around to get
myself some medicine, put a hanckerchief over my mouth and nose and went
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (28 of 32) [23/03/2005 05:49:38 p.m.]
back inside. A man has to do what a man has to do. Right?
I tried not to tuch anything, because everything was covered with the
excrements and dead bodys of the rats and bats.
Later I organized myself a coverall, a box of disposable gloves and some
mouth caps and started to get all the archive boxes (or what was left of
it) out of there.
During that time Jhonny became a very close friend, or was it his bottle?
Never mind.
We put the boxes in a open shed in the (vainly) hope to get rid of most of
the stench.
When we got everything out I started to open the boxes and visiting Johnny
often.
The rats made havoc of the paper drawings, but strangely they did almost
nothing to the calques.
When after two weeks of air treatment the stench was reduced a little, we
found a company who was willing to phototype the drawings, against a cost
rise of fifty percent.
After that we burned all off the stinking, filthy remains and I could start
my field check.
Eventuallie I finished the job having a good time.
I still see Johnny now and then for a friendly discussion with his bottle.
===========
Congratulations Joop. Your prize is on it's way.
Thanks to everyone who entered, both of my fellow judges,
Andy Canfield and Paul Cistoldi, and a BIG THANK YOU to :
*********CADzation************
http://www.cadzation.com
***********************************
for their generous sponsorship of this competition.
***********************************
Hey, that was good fun.
We need to do something similar again.
Ideas???
========
Things Weird and Wonderful
========================
The Zombie Survival Guide :
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (29 of 32) [23/03/2005 05:49:38 p.m.]
http://www.randomhouse.com/crown/zombiesurvivalguide/
Pop along here for a Private Message from me to you :
http://www.bloodyfingermail.com/message.php?id=324370
Miscellaneous Stuff that I almost Forgot
================================
Load and run this :
;CODING STARTS HERE
(defun C:Layer-Dump ( / theList acadDocument theLayers)
(vl-load-com)
(setq theList '())
(setq acadDocument
(vla-get-activedocument
(vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'vlax-dump-object)
(princ)
);defun
(princ)
;CODING ENDS HERE

This will dump all properties of all the Layer objects in your
drawing to the console screen.
================
"Delusions of Grandeur is a Good Thing"
Just a thought.........
=================
The Back Stoep
=============
And this weeks final word is from the desk
of Georges Bolssens
Ship High In Transit
=================
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (30 of 32) [23/03/2005 05:49:38 p.m.]
In the 16th and 17th centuries, everything had to be transported by ship.
It was also before commercial fertilizer's invention, so large shipments of
manure were common. It was shipped dry, because in dry form it weighed
a lot less than when wet, but once water (at sea) hit it not only became heavier,
but the process of fermentation began again, of which a by-product is methane gas.
As the stuff was stored below decks in bundles, you can see what could (and did)
happen.
Methane began to build up below decks and the first time someone came below
at night with a lantern, BOOOOM! Several ships were destroyed in this manner
before it was determined just what was happening. After that, the bundles of
manure were always stamped with the term "Ship High In Transit" on them which
meant for the sailors to stow it high enough off the lower decks so that any water
that came into the hold would not touch this volatile cargo and start the production
of methane.
Thus evolved the term "S.H.I.T," which has come down through the centuries and
is in use to this very day. You probably did not know the true history of this word.
Neither did I, I always thought it was a golf term.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
If you can still hear the music, it's not loud enough!
http://www.BedrockBand.com
----------------------------------------------------------
AfraLisp is generously supported by :
"Corbimite.com"
http://www.corbimite.com
----------------------------------------------------------
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (31 of 32) [23/03/2005 05:49:38 p.m.]
AutoCAD to PDF?
Pop along to CADzation
http://www.cadzation.com
***********************************
To subscribe or unsubscribe to the AfraLisp
Newsletter pop along here:
http://www.afralisp.com/newsletter/newsletter.htm

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2003-24
http://www.afralisp.com/newsletter/2003/2003-24.htm (32 of 32) [23/03/2005 05:49:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
--------------------------------------------------
AfraLisp Newsletter No 2002-01
--------------------------------------------------
Thursday 3rd January 2002
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
--------------------------
The Front Stoep
--------------------------
Welcome to the year 2002. I hope you had a jolly Xmas and New Year. I
know I did, or so my wife tells me!!! (Hey, I didn't get arrested this
year). I've got a lot in store for this next couple of months. I'm going to
be looking at Visual Lisp and attributes, followed by getting AutoCAD
to talk with other applications such as Excel and Access using Visual
Lisp. And then I'm going to have a wee peek at dictionaries. End of
January, the 2002 upgrades should have arrived, so I'll have that lot to
plough through and probably lot's of system tweeking to deal with.
On top of all that, we're just about to start recording the bands new CD.
So, I've got my work cut out for me, but it keeps me out of trouble. (and
the pub).
Anyway, enough waffle and on with the Newsletter.........
------------------------
The Site
------------------------
I've been a bit lazy over the festive season and didn't manage to do
much in the way of work. I started I don't know how many times, but
gave up after the second beer.
Anyway, not to worry, I'm back at work on Monday and will soon have
one or two new goodies written and posted.
-------------------------
Michael Demott has very kindly designed an AfraLisp Link button. So,
if you've got your own website, and would like to link to AfraLisp, you
can grab the button from here :
http://www.afralisp.com/images/afra-but.gif
-------------------------
I don't know if you've popped along to have a look at
http://www.cadchat.com yet, but it's well worth the visit. Most of you
should be familiar will Dave Whynot, but just in case you're not, here's
a brief bio :
David Whynot is the founder and owner of CADchat.com, an AutoCAD
hacker since 1988. He is the creator of the original CADsyst website
(now CADdepot - http://www.caddepot.com) which he still is involved
as librarian. David's "real" job is IT manager, website developer and
AutoCAD draftsman for Halsall Associates Ltd - http://www.halsall.com
, a consulting engineering firm. Self taught in the ways of AutoCAD,
website development and NT networking, David enjoys the opportunity
to learn from others, hence one of the reasons for creating
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (1 of 9) [23/03/2005 05:49:40 p.m.]
CADchat.com. "I found the newsgroups I visited too congested with
spam and other irrelevant distractions" says David, "I hope this
website offers a safe haven of pure information dedicated to the
various CAD programs available".
This site does not just deal with AutoCAD, but with all types of CAD
software. So, if you feel like slagging off the Bentley boys, then this is
the place to be.
By the way, I'm "Moderating" under the AutoCAD programming
section. I get to delete all the jokes and keep them for this Newsletter.
--------------------------------
The following function displays an Input Box similar to the VBA Input
Box
function.
Syntax : (inputbox "prompt" "title" "default")
e.g. (inputbox "Enter Number" "AfraLisp Inputbox" "342.34")
Returns a variable "inputvalue" containing the value of the
Edit Box.
DCL Coding :
//CODING STARTS HERE
inputbox : dialog {
key = "title";
: text {
key = "prompt";
}
: edit_box {
key = "eb1";
}
ok_cancel;
}
//CODING ENDS HERE
--------------------------------------------
Save this as "Inputbox.dcl"
Now the Coding :
;CODING STARTS HERE
(defun inputbox (prompt title default)
(setq dcl_id (load_dialog "inputbox.dcl"))
(if (not (new_dialog "inputbox" dcl_id))
(exit)
)
(set_tile "prompt" prompt)
(set_tile "title" title)
(set_tile "eb1" default)
(mode_tile "eb1" 2)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
(action_tile
"accept"
"(setq inputvalue (get_tile \"eb1\"))
(done_dialog)
(setq result T)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (2 of 9) [23/03/2005 05:49:40 p.m.]
(princ)
;CODING ENDS HERE
Save as "Inputbox.lsp"
-------------------------------------------
Here's how to design and code a Popup Listbox in DCL :
//DCL CODING STARTS HERE
popup : dialog {
label = "AfraLisp Popup List" ;
: popup_list {
label = "Choose Name:";
key = "selections";
value = "5" ;
edit_width = 12;
}
ok_cancel ;
}
//DCL CODING ENDS HERE
--------------------------------------------
Save this as "Popup.dcl"
Now the AutoLisp Coding
;AUTOLISP CODING STARTS HERE
(defun C:popup ()
;define function
(setq NAMES '("Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday")
);setq
;define list
(setq dcl_id (load_dialog "popup.dcl"))
;load dialog
(if (not (new_dialog "popup" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(start_list "selections")
;start the list box
(mapcar 'add_list NAMES)
;fill the list box
(end_list)
;end list
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))"
;get list selection
"(done_dialog) (setq userclick T))"
;close dialog
);strcat
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (3 of 9) [23/03/2005 05:49:40 p.m.]
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog
(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(progn
;if it was do the following
(setq SIZ (fix SIZ))
;convert to integer
(setq SIZ (nth SIZ NAMES))
;get the Day
(alert (strcat "You Selected: " SIZ))
;display the Day
);progn
);if userclick
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
-----------------------------------------------------
Save this as "Popup.lsp"
Load and Run. Select a day from the Popup Listbox.
It should be displayed.
I have not declared any variables to allow you to view them.
------------------------
The Questions
------------------------
I am creating a VBA routine to do a batch .dwg or .dxf
file conversion to previous releases, as well as purging
and binding xrefs.
Your Drawing Backup application has all the right functionality
for file selection and the selection of a target location.
I have also found it difficult, impossible so far, to bind unloaded
xrefs so I also need the ability to generate an error log for
incomplete bindings.
Any code greatly appreciated.
thanks
Michael de Glanville
----------------------------------------
Hi Kenny,
I am a novice at VBA for CAD but I was looking at your site and was
wondering if you could help me?
I can insert a block into a drawing ok:
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (4 of 9) [23/03/2005 05:49:40 p.m.]
but I want to click to insert the block not define it in the macro as x,y,z.
If you can help me it would be appreciated.
regards
Richard MIchael
Australia
----------------------------------
Dear Sir/Madam
I appreciate your efforts in design of this website, so i recommend it to
my
collegues who are interested in lisp coding..
I work at a project office focusing on structural design and drafting of
high rise buildings and towers, as a structral engineer. The basic
principals in the office depend on the lisp based programmes. So far, i
have
found the oppurunity in processing data in Cad enviroment.
Yet i have question that i couldnt find a solution:
i want to apply a program to many numbers of drawings in a folder. i
wrote a
scpript and i managed to do it.. i opened the drawings one by one by
open
command, and load the program, do it and save the drawing and open
the other
dwg and so on..but i wrote all the dwg names and repeated it many
times.. it
could be done with a repeat command in lisp very elegantly and much
more
time and space consuming..
but when i wanted to it with a lisp i failed to do it:
By the help of your routines with the title "Dir Command", i managed to
get
a list of the drawings in a specified drawing and get the oppurtunity of
applying commands in those drawings.
(temp.txt is created by dos dir command..)
i wrote like..:
(setq data "temp.txt")
(repeat total ;total is the total number of lines in the temp.txt
(setq dwgname (read-line data)
(command "open" dwgname)
(load "myprogram")
(command "save")
);(there may be errors, i just write it from mind just for case show, ;dont
interperet it as compelete and true..)
but when i opened the drawing, the loaded lisp is no more valid so the
rest
of the program does not work.. i tried to use "start_app" or something
like
that and opened a new AutoCad session.(i have AcadR14 so a drawing
is opend
once in a session.. you know..) but i cant
apply my commands to the second (new) session of Autocad. so it will
be
allright if the lisp targets its commands to the new drawing.
i hope i managed to express my problem.. i will be gratefull if you help
me..
Yours Sincerely
Omer Yalcin
Istanbul/Turkey
p.s: happy new year to you all there..
-------------------------------------------
Is there any way to delete layers using AutoLISP in version 2002?
There isn't a command line option to do so.
Russ Johnston
Quite a few difficult questions this week, so come on folks, let's give
them a hand.
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (5 of 9) [23/03/2005 05:49:40 p.m.]
-----------------------
The Answers
-----------------------
I get material from your site quite often, and I think it is time to give
something back. I am sending a routine in lisp to project-align TEXT
and
BlOCK entities upon an existing line. Quite useful when drawing
parking
stalls, etc.
Rogelio Bravo
;CODING STARTS HERE
;; project/align texts and blocks upon preexistent line
(defun C:aligne ()
(prompt "\nPick base line upon which project/align objects:")
(setq ent (entsel))
(setq pt2 (cadr ent))
(setq nlin (car ent))
(setq pt2 (osnap pt2 "Nea"))
(prompt "\nSelect texts/blocks to project/align: ")
(setq conj (ssget))
(setq num 0)
(setq con (ssadd))
(setq lon (sslength conj))
(repeat lon
(setq name (ssname conj num))
(setq lst (entget name))
(setq tip (cdr (assoc 0 lst)))
(if (or (= tip "TEXT")(= tip "INSERT")) ;seleccion objetos texto o bloque
(ssadd name con)
)
(setq num (+ 1 num))
) ; end repeat
(setq lon1 (sslength con))
(setq num1 0)
(repeat lon1
(setq e1 (entget (ssname con num1))) ; lista de la primera entidad
(setq pt1 ( cdr (assoc 10 e1))) ;punto insercin texto o bloque
(setq name (cdr (assoc -1 e1)))
( command "line" pt1 (osnap pt2 "per") "")
;obtencin punto final de la recta perpendicular
(setq pfin (cdr (assoc 11 (entget (entlast)))))
(command "_erase" (entlast) "")
(command "_move" name "" pt1 pfin)
(setq num1 (+ 1 num1))
);end repeat
(initget "Yes No")
(setq what (getkword "\nErase base line? (Y/N) <Y>: "))
(if (= what nil)(setq what "Yes"));end if
(cond
((= what "Yes")(command "_erase" nlin ""))
); end cond
(princ)
) ; end defun
;CODING ENDS HERE
Thanks Rogelio, much appreciated.....
--------------------------------------------------------------
If you're interested in DCL, this is worth a wee look at :
I posted a zip file image4.zip on my website under
www.cad-code.com/archive.htm
under image4.zip at the bottom of the page.
It creates a dialog that has two image buttons and if you
select the buttons the image changes.
As far as the location selected on the image, you can get the
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (6 of 9) [23/03/2005 05:49:40 p.m.]
x and y coordinates of the selection point from $X and $Y
just like the $value returned from edit boxes.
Peter Jamtgaard
www.cad-code.com
---------------------------------------
Kenny -
I love your newsletter! It is extremely well done and it is *required*
reading for my programming staff.
I was checking out the tutorial you wrote on error handling with vlisp,
when I caught a common mistake in your code. Now, it might be that
you are showing every step for the beginner to follow. If that is the
case, please disregard and pitch this email into the electronic waste
basket.
In the error code, you are making repeated calls to the interpreter to
determine the meaning of setq. Not only is it redundant, it takes time
for the interpreter to evaluate the expression. In a program of small to
medium size, this is not an issue. In larger programs, there is a
noticable difference when only a single call is made to setq as in:
(setq x 1)
(setq y 2)
(setq z 3)
(setq x 1 y 2 z 3)
Now, even in small projects you can regain some speed depending
upon the complexity of the program. Take for instance the following
lines from the error handler:
(if (vl-catch-all-error-p result)
(progn
(setq int (abs int))
(setq result (vl-catch-all-apply 'sqrt (list int)))
);progn
);if
This can be simplified to:
(if(vl-catch-all-error-p result)
(setq int (abs int)
result (vl-catch-all-apply 'sqrt (list int)))) ; setq/if
Here, less time is spent evaluating the lisp expressions because
removing the second setq removes the need for the progn statement.
And, again, I realize that this is nano seconds but the time does add up
on large projects.
Keep up the great work! Best Regards,
Mike Tuersley
Thanks Mike, this is definitely something that needs to be pointed out
to newer Lispers.
-------------------------------
If you enjoy good music, then visit
"BedRock - The Band in the Sand"
Disturbing The Peace Since 1994!
http://www.BedrockBand.com
---------------------------
The Back Stoep
---------------------------
For a change from programming, I thought that I would let you in on a
special recipe for the best ever rum cake. Try this out :
1 or 2 quarts of rum
1 cup butter
1 tsp sugar
2 large eggs
1 cup dried fruit
Baking powder
1 tsp baking soda
lemon juice
brown sugar
nuts
Before you start, sample the rum to make sure it is of the highest
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (7 of 9) [23/03/2005 05:49:40 p.m.]
quality. If it's alright continue as follows :
Select a large mixing bowl, measuring cup etc. Check the rum again to
make sure it hasn't gone off. To be sure that it is adequate for the cake
pour one level cup of rum into a glass and drink it as fast as you can.
Repeat...pause...With an electric mixer beat 1 cup of butter in a large
flufft bowl. Add 1 seaspoon of thugar and beat again. Meanwhile make
sure the rum is of the highest quality. Try another cup. Open 2nd quart
if necessary. Add 2 arge leggs, 2 cups drilled fruit and beat til high. If
drilled fruit gets stuck in beaters, just pry it loose with a drewscriver.
Sample the rum again, checking for tincisticity. Next sift 3 cups of salt
or pepper (it really doesn't matter which). Sample the rum again. Sift
1/2 pint lemon juice. Fold in chopped butter and strained nuts. Add one
babblespoon of brown sugar or whatever colour you can find. Wix mel.
Crease over and turn cake pan into the coven and bake at 350 gredees.
Check the rum again and go to bed.
Highly recommended.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
Disturbing The Peace Since 1994!
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye...........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (8 of 9) [23/03/2005 05:49:40 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-01
http://www.afralisp.com/newsletter/2002/2002-01.htm (9 of 9) [23/03/2005 05:49:40 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, January 13, 2002 7:47
--------------------------------------------------
AfraLisp Newsletter No 2002-02
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
--------------------------
The Front Stoep
--------------------------
Friends, Romans and Gentlemen. How are you? Well I hope, and
recovered nicely from the over indulgences of the festive season?
I've had a few requests from subscribers to include the e-mail
addresses of those of you that send in questions or answers. I used to
do the this, but stopped it when a certain weird gentleman decided that
this was a good way of contacting people to tout for business. As it's
your Newsletter as much as mine, I've decided to reinstate e-mail
addresses, but only if the contributor expresses a wish for me to do so.
So, please remember, if you send me anything to include in this
Newsletter, please mention whether or not you would like your e-mail
to be published.
E-mail addresses will NOT be included in the web version posted in the
AfraLisp Archives :
http://www.afralisp.com/newsletter/newsletter.htm
---------------------------------------------------------------------------------------
Quote of the Day : "I love animals - They taste great!"
---------------------------------------------------------------------------------------
------------------------
The Site
------------------------
**This is interesting**
I've updated the tutorial on the (eval) function to show how you can
use this as an alternative to the (cond) function. You can find this at :
http://www.afralisp.com/lispa/lisp44.htm
------------------------
Would you like a dialog complete with slider?
I thought you would.....
//DCL CODING STARTS HERE
slide : dialog {
label = "Slider Example" ;
: edit_box {
key = "eb1" ;
label = "Slot &Length (O/All Slot)" ;
edit_width = 6 ;
}
: slider {
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (1 of 7) [23/03/2005 05:49:41 p.m.]
key = "myslider" ;
max_value = 100;
min_value = 0;
value = "50";
}
ok_cancel ;
}
//DCL CODING ENDS HERE
Save this as "Slide.dcl". Now the AutoLisp Coding :
;CODING STARTS HERE
(defun C:Slide ()
;define function
(setq lngth 50.0)
;preset slot length
(setq dcl_id (load_dialog "slide.dcl"))
;load dialog
(if (not (new_dialog "slide" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(set_tile "eb1" "50")
;put data into edit box
(mode_tile "eb1" 2)
;switch focus to edit box
(action_tile "myslider"
;if user moves slider
"(slider_action $value $reason)")
;pass arguments to slider_action
(action_tile "eb1"
;if user enters slot length
"(ebox_action $value $reason)")
;pass arguments to ebox_action
(defun slider_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "eb1" val)))
;update edit box
(defun ebox_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "myslider" val)))
;update slider
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (2 of 7) [23/03/2005 05:49:41 p.m.]
"(progn
(setq lngth (get_tile \"eb1\"))"
;get slot length
"(done_dialog)(setq userclick T))"
;close dialog, set flag
);strcat
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog
(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected: " lngth))
;display the selected length.
);if userclick
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
Save this as "Slide.lsp".
------------------------
The Questions
------------------------
Hi Kenny,
I'm one of the person who is getting benefited from your Afralisp site
for
autolisp & VBA. I'm currently working on Autocad2000 VBA.
I'm developing a VBA program for storing the entity properties in an
ExcelSheet. I have a block of 32 entities and I have to get the entity
property of a particular entity of the block. I don't want the block to be
exploded. I tried (as per your tutorial) in Autolisp & found it worked
well.
Is it possible to get the list properties of a selected entity of a block
in VBA? Or How can I manipulate the list properties of an entity in a
block?
Your advice in this regard is greatly appreciated.
Thanks,
Rajesh.
-------------------------------------------------
My problem is this, I have a number of drawings with hatched regions
shown.
Is there a LISP or VB program that can query these hatched regions
and
display their areas?
If not, is there a LISP or VB program where you can pick a point inside
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (3 of 7) [23/03/2005 05:49:41 p.m.]
an
irregular, inclosed region (like creating a hatch) and extract the area?
Regards,
Bret
I sent Bret this link :
http://www.afralisp.com/lisp/area.htm
-----------------------------------------------
How I obtain to have access an entity selected with the SelectionSet
of the VBA and as I can have access the properties of this entity?
Atenciosamente,
Anderson A. Campos
------------------------------------------------------
Have you said "Hi" to "The Wonder Llama" lately?
http://www.vbdesign.net
Don't mention my name!!!!
Would you like to rate Randall's nose?
Take your pick. (excuse the pun)
[1] mailto:rwrath75@worldnet.att.net?subject=Rubbish-Nose
[2] mailto:rwrath75@worldnet.att.net?subject=Terrible-Nose
[3] mailto:rwrath75@worldnet.att.net?subject=Disgusting-Nose
[4] mailto:rwrath75@worldnet.att.net?subject=Pickable-Nose
[5] mailto:rwrath75@worldnet.att.net?subject=BIG-Nose
-----------------------
The Answers
-----------------------
Happy B'day Kenny -
You can't be old 'cause you Rock....
(if (not (2 old (2 RocknRoll)))
(then (2 young (2 die)))
) ;end if
...Just press `PLAY'
G.Nelson
--------------
Yep, it was my birthday on the 9th
"Too old To Rock and Roll" - never!
Too young to die" - damn right..."
-----------------------------------------------------------
The AugAfrica - AutoCAD Users Group Africa - is now up and running.
You can find their new website at :
http://www.AugAfrica.com
or e-mail them at :
mailto:AugAfrica@augafrica.com
---------------------------------------------
The system variable LTSCALE controls the global LineType Scale of all
entities within a drawing.
But do you know that you can change the LTSCALE of individual
entities?
Manual Method :
Open the Properties dialog.
Select a line.
Change the value of the LineType Scale property.
LTSCALE should change.
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (4 of 7) [23/03/2005 05:49:41 p.m.]
If it doesn't, make Rum Cake.....
Automated Method :
;AUTOLISP CODING STARTS HERE
(prompt "\n Type LTCHG to run.....")
(defun c:ltchg ( / ssets acadDocument newsset ctr item newscale)
(setq newscale (getreal "\nEnter New Linetype Scale : "))
;load the visual lisp extensions
(vl-load-com)
;retrieve a reference to the documents object
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
;retrieve a reference to the selection sets object
(setq ssets (vla-get-selectionsets acadDocument))
;add a new selection set
(setq newsset (vla-add ssets "SS1"))
;select your new selection set objects
(vla-selectOnScreen newsset)
;set the counter to zero
(setq ctr 0)
;count the number of objects and loop
(repeat (vla-get-count newsset)
;retrieve each object
(setq item (vla-item newsset ctr))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p item "LinetypeScale" T))
;if it can
(if check
;change it's color
(vlax-put-property item 'LinetypeScale newscale)
);if
;increment the counter
(setq ctr (1+ ctr))
);repeat
;delete the selection set
(vla-delete (vla-item ssets "SS1"))
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
Some very good news. My daughter Kyla, passed her final school
exams with flying colours and matriculated with university exemption.
Time to open the "bubbly".
---------------------------
A couple of hunters are out in the woods when one of them falls to the
ground. He doesn't seem to be breathing, his eyes are rolled back in
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (5 of 7) [23/03/2005 05:49:41 p.m.]
his
head. The other guy whips out his mobile phone and calls the
emergency
services.
He gasps to the operator, "My friend is dead! What can I do?"
The operator, in a calm soothing voice says, "Just take it easy.
First, let's make sure he's dead."
There's silence, then a shot is heard.
The guy's voice comes back on the line.
He says, "OK, now what?"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
You have subscribed to this Newsletter
using the following E-mail address :
mailto:
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
Disturbing The Peace Since 1994!
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye...........
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (6 of 7) [23/03/2005 05:49:41 p.m.]
You can stop reading now.
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-02
http://www.afralisp.com/newsletter/2002/2002-02.htm (7 of 7) [23/03/2005 05:49:41 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, January 19, 2002 10:19
--------------------------------------------------
AfraLisp Newsletter No 2002-03
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
This Newsletter is best read using a Human Brain.
(Release 1.0 Beta and above).
Click on the link below if you need to download one :
http://www.vh.org/Providers/Textbooks/BrainAnatomy/Ch1Text/Section02.html
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Good Morning.
Well it's morning here in the middle of the desert. I'm sat here contemplating
my navel and wondering why my daughter would say "Dad, you're weird!"
I don't know where she got that impression from. It's like my doctor. I went to
see him the other day and he said, "Hi Kenny, I haven't seen you for a long
time. And I said, "I know I've been sick". He also looked at me weird.
Then, at work the other day, I was leaving the office and my boss said to me,
"Where are you going Kenny?"
"To get my haircut" I told him.
"What during working hours?"
"Well it grows during work time."
"Not all of it". he said.
"I'm not getting it all cut."
He also looked at me weird!!!
Strange people??
Thought of the day :
"There are basically three kinds of people in the world.
Those who can count and those that can't."
------------------------
The Site
------------------------
Here's something that you could maybe build on :
Would you like to add a note to any object or entity in your drawing?
;AUTOLISP CODING STARTS HERE
(prompt "\nType AddNote to run.")
(defun C:AddNote ( / ss1 pt1 pt2 ar ao thenote)
(setq ar "I")
(setq ao "O")
(setq ar (getstring "\nRemove/Insert <I> : "))
(if (= (strcase ar) "R")
(progn
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (1 of 6) [23/03/2005 05:49:43 p.m.]
(setq ss1 (ssget))
(command "-HYPERLINK" "R" ss1 "" "*")
);progn
(progn
(setq ao (getstring "\nArea/Object <O> : "))
(if (= (strcase ao) "O")
(progn
(setq ss1 (ssget))
(setq thenote (getstring T "\nEnter Note : "))
(command "-HYPERLINK" ar ao ss1 "" "" "" thenote)
);progn
(progn
(setq pt1 (getpoint "\Enter first point : "))
(setq pt2 (getcorner pt1 "\nEnter second point "))
(setq thenote (getstring T "\nEnter Note : "))
(command "-HYPERLINK" ar ao pt1 pt2 "" "" thenote)
);progn
);if
);progn
);if
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
Save this as "AddNote.lsp"
------------------------
The Questions
------------------------
I was looking at your website last night and all the
useful information that it has and I have a question
for you. This is going to be an awkward question,
but I was wondering if you would/could send me all of
your tutorials on your site for my own reference rather
than me having to copy and paste them. I would
greatly appreciate and wouldn't hesitate to return the favor
if asked. Keep up the good work. Thank you.
Mark
I've been thinking about this.
How does an electronic book sound?
PDF format?
Let me know everyone.
Then I'll think about it some more!!
-----------------------
Hi Kenny,
I was hoping you could help me finish my first lisp?
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (2 of 6) [23/03/2005 05:49:43 p.m.]
The lisp is design to insert a plant callout block from my blocks file into the
drawing onto a new titled layer and color that is in the lisp code, then ask for
the insertion scale, then ask for the text info, and final the insertion point.
Here is what I got so far.
(defun c:ptco ( / player txt1 txt2 txt3 inspt sc1)
(command ".undo" "begin")
(setq player (getvar "clayer"))
(setvar "cmdecho" 0)
(command "-LAYER" "M" "L-PLT_CALLOUT" "C" "3" "L-PLT_CALLOUT" "")
(setq txt1 (getstring T "\nQuantity: "))
(setq txt2 (getstring T "\nGenus and species: "))
(setq txt3 (getstring T "\nSize: "))
(while (not (setq inspt (getpoint "\nPick insertion point: "))))
(setq sc1 (getvar "dimscale"))
(command "-insert" "c:/cadd/blocks/pltg-co" inspt sc1 sc1 "")
(command "-ATTEDIT" "n" "n" "" "" "" "Qty" txt1)
(command "-ATTEDIT" "n" "n" "" "" "" "Name" txt2)
(command "-ATTEDIT" "n" "n" "" "" "" "Size" txt3)
(setvar "clayer" player)
(setvar "cmdecho" 1)
(graphscr)
(command ".undo" "end")
(princ)
);defun
I am using 2002 and the lisps does work but not 100%.
When the lisp has finished and I have enter my text info, the inserted block
shows the following:
attedit for Qty,
n for Genus & Species, and
n for Size
I also don't know how to have it ask for the scale factor I.E. 96 for 1/8",
240 for 20 scale.
If you can help, I would be grateful
thanks,
Kyle Crooke
Try adding these lines before and after the "Insert" :
(setvar "ATTREQ" 1)
(setvar "ATTDIA" 1)
(initdia)
(command "-insert" "c:/cadd/blocks/pltg-co" inspt sc1 sc1 "")
(setvar "ATTREQ" 0)
(setvar "ATTDIA" 0)
-----------------------
hi Kenny...
i would like to know what wrong with this....
(defun c:fss ()
(setq fich1 (getfiled "Ouvrir un Nouveau Plan:" "" "dwg" 8))
(setvar "filedia" 0)
(command "filedia" "0" "open" fich1)
(setvar "filedia" 1)
)
is not working......why ???
Andrea Andreetti
-----------------------
Kenny
Try this. Copy drawing from Acad2002 into PowerPoint. I am using
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (3 of 6) [23/03/2005 05:49:43 p.m.]
PowerPoint
97. On my system it automatically shuts down Autocad. I Used this adnausem
in Acadr14, without any problems
Yours?
Cameron Mocke
-----------------------
Hi Kenny.
First of all let me say you site is just fantastic. I use it all the time for some
coding examples.
What I am trying to do is at the moment is write a vb program that edits the
attributes in a block. I have managed to do this just fine.
What I am have trouble with is I am trying to overwrite the default AutoCAD
function that is called up when you double click a block.
I want to double click my block and run my edit program. not AutoCAD's
attedit one. Can you help please?
Regards Stuart.
------------------------------------------------------
Hi, Kenny:
Im lost, as the little dog, trying to get the dim value expresed with decimals, I
try at DDUNITS, and UNITS at the DDIM dialog box but despite the changes I
made to it, when I DIM angles or lines, the values becomes as integers.
Any help please.
Gabriel Cals De Vit
----------------------
The Answers
-----------------------
Hi Kenny
In regards to the question about changing the LTSCALE of individual entities,
the
"Manual Method" is correct, but I think it needs to be pointed out that you are
actually changing the CELTSCALE of the Entity NOT! the LTSCALE (As noted
in the question this controls the Global LineType Scale of all Entities). Sorry if
this seems to be splitting hairs, just thought this should be made clear.
From a personal point of view, I would discourage CAD users from altering
the
CELTSCALE of Entities (Should always be 1) unless it is TOTALLY
unavoidable
to do so, let the LTSCALE do the work. We had a CAD user here that would
set LTSCALE to 1 then change all Entities CELTSCALE in a drawing just so
the dashes & dots looked right when switching between ModelSpace &
PaperSpace.
Made sense to them (don't ask me), but when others opened a drawing done
in
this way, TOTAL confusion (I couldn't blame them).
Will have to starting taking a look at the Visual LISP Extensions, as it seems
more
and more of you "LISP Yoda's" are using them to accomplish the task's you
require; so can't possibly comment on the "Automated Method".
Have a good one,
Mike Perry
----------------------------------
Dear Sirs:
I send You my new LISP program to create analytical
curves and spirals as polylines (spaced vertexes),
include -involute, -cycloid, -hyperbola, -sine, -power func, etc.
It was developed just in 2002. Feel free to test it.
Could You please distribute this software as a freeware.
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (4 of 6) [23/03/2005 05:49:43 p.m.]
Sincerelly
Eugeny Kalney
You can download this application at :
http://www.afralisp.com/zip1/curves.zip (183kb)
----------------------------------
Hi Kenny!
Since you've got a couple of other foreign language AutoLISP Links -- I
thought You might like to get a wee peek at this one.
http://www.cadmagazine.net/programming.html
Mike DeMott
We think is Arabic. Could anybody confirm this?
---------------------------
The Back Stoep
---------------------------
This weeks Back Stoep is a couple of contributions from you.
First one from Pete Willem :
A man runs home and bursts in yelling :
"Pack your bags sweetheart, I've just won the lottery, all six numbers!"
She says :
"Oh wonderful! Should I pack for the beach or the mountains?"
He replies :
"I don't care ... just pack and shove off!"
-------------------------------
Gabriel Cals De Vit sent me this little gem. He did ask me to correct the
grammar, etc, but I think it's a cracker just as is.
Once upon a time a little fox terrier dog get lost at the middle of the jungle.
Looking the way to going back home, he see a pair of red eyes surrounded by
a black head.
It was a big black panther.
The dog feel that he will be the panthers breakfast, so looking for a help he
take an old bone from ground and chewing it say, "Oh , what a good panther I
had for breakfast!"
Seeing this, the panther goes back step to jungle, but as always is, a little
monkey see the scene and going after the panther he reach and tell him about
the dogs trick.
The panther said, "I go back where the dog is and this time I will eat him".
The monkey ask to ride the panther so he will see how it will happen.
The litle dog was still lost but he see the panther with the monkey coming to
him.
Giving his back to them , the dog says, "I wonder where damm is the monkey.
About half an hour I ask him to bring me another panther for lunch.!!!!!!!!!!!!!"
Thanks Gabriel, and no offence meant. I wish I could speak Argentinouwenies
as well as you speak English.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (5 of 6) [23/03/2005 05:49:43 p.m.]
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
Disturbing The Peace Since 1994!
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye...........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-03
http://www.afralisp.com/newsletter/2002/2002-03.htm (6 of 6) [23/03/2005 05:49:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: January 25, 2002 09:07
--------------------------------------------------
AfraLisp Newsletter No 2002-04
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
This line intentionally left blank.
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Hi Kenny, remember the electronic book containing all the tutorials on
AfraLisp that I was yapping on about last week? I did say that I would
think
about it. Well, I'm still thinking about it!! I've only got a wee brain and
major decisions like this take time to filter through and get processed.
(even Randall Rath has been begging, but he'll just have to wait).
The Newsletter is going out early this week as I'm recording all
weekend and
will be subsequently tied up with artistic endeavours of the musical
kind.
So, start saving now 'cos as soon as our new CD is finished I'll be
bugging
you all to buy a copy.
Anyway, on with this weeks show, but first a commercial break :
***Advertisement***
Join the army.
Travel to exotic foreign lands.
Meet interesting people.
And kill them.
------------------------
The Site
------------------------
The site. You may well ask. I haven't added much lately 'cos I'm in the
middle of a major technical upgrade. (clean up). You won't notice much
of a
difference except in speed, but I'm busy re-doing and re-formatting all
the
pages. (and there's lot's). I had a problem with indexing (not to mention
my
spelling) because I was a bit lazy at the beginning, but the time came
when
I had to bite the bullet and fix things up. Please be patient, normal
service will be resumed as soon as possible.
*Stop Press*
For a complete listing of AutoCAD System Variables, have a wee look
here :
http://www.afralisp.com/sysvar1.htm
---------------------------
This routine draws a rectangle corresponding to the current settings of
LIMMIN and LIMMAX. The rectangle is erased by a redraw/regen or by
running
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (1 of 7) [23/03/2005 05:49:44 p.m.]
the routine again.
;CODING STARTS HERE
(defun C:LR (/ pt1 pt2 r1 r2)
(setq pt1 (getvar "LIMMIN")
pt2
(getvar "LIMMAX")
)
(grvecs (list 256
(list (car pt1) (cadr pt2))
pt2
256
(list (car pt2) (cadr pt1))
pt1
256
pt1
(list (car pt1) (cadr pt2))
256
pt2
(list (car pt2) (cadr pt1))
)
)
(grdraw pt1 pt2 -1)
(grdraw (list (car pt1) (cadr pt2))
(list (car pt2) (cadr pt1))
-1
)
(princ "Limit rect info : ")
(setq r1 (rtos (car (getvar "limmin")))
r2
(rtos (cadr (getvar "limmin")))
)
(prompt (strcat "\nLower left : " r1 "," r2))
(setq r1 (rtos (car (getvar "limmax")))
r2 (rtos (cadr (getvar "limmax")))
)
(prompt (strcat "\nUpper right : " r1 "," r2))
(if (= (getvar "LIMCHECK") 0)
(setq linf "off")
(setq linf "on")
)
(prompt (strcat "\nLimits are " linf))
(princ)
);defun
(princ)
;CODING ENDS HERE
-----------------------
And a present from the Wonder Llama :
'CODING STARTS HERE
Public Sub Oomph()
Dim textObj As AcadText
Dim textString As String
Dim returnPnt1 As Variant
Dim height As Double
' Return a point using a prompt
returnPnt1 = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
' Define the text object
'///A Zen Moment From Me to You////
height = ThisDrawing.Utility.GetReal("Text height: ")
textString = "Place object here"
' Create the text object in model space
Set textObj = ThisDrawing.ModelSpace.AddText(textString, returnPnt1,
height)
End Sub
'CODING ENDS HERE
Ralph
Wonder Llama
http://www.vbdesign.net
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (2 of 7) [23/03/2005 05:49:44 p.m.]
------------------------
The Questions
------------------------
Two questions for you regarding the time and date stamping article
from the
web page - http://www.afralisp.com/lispa/lisp40a.htm
First, how would I add to the info that the lisp puts on the page, the
dwg
name and path? Second, how would I specify which text to use when
doing the
plot stamp? How would add any additional info in the code and what
not?
Thanks for your help.
Mark
----------------
First you would need to create a block containing additional attributes
other than the 3 attributes, namely "Date", "Time" and "Who By", called
for
in the tutorial.
Let's name these two attributes "Drg" and "Note".
To retrieve that drawing name and path, use the following :
(setq drg (strcat (getvar "dwgprefix") (getvar "dwgname")))
To get a custom string from the user, do this :
(setq note (getstring T "\nEnter Note : "))
Now add the 2 new attribute variables to the (command) function :
(command "Insert" "Stamp" "0,0" "" "" "" thedate thetime plotby drg
note)
To specify the text to use, you would accomplish this when you create
the
attribute.
----------------------
P.S. What goes "Mark, Mark?
A dog with a lisp!!!
----------------------
Kenny,
I've on to your web site since the beginning, and haven't asked any
questions. Well that's changed now. I'm attempting to create a lisp
routine
to set a standard dimension style, make a layer for it and a certian style
of text. My routine runs through fine if the style exists and is currently
set. If I run it on a new drawing it works fine except it creates the
Dimstyle as an override. If run the routine and the dimstyle is not
current,
errors out on me. Any suggestions for this type of lisp checking for
dimstyles?
I'm using ACAD 2002 and would like this routine to be accessed
through a
toolbar so that everyone in the office can have access to it.
Thanks
Mark Bross
-------------------
Mark,
Another dog with a lisp!!! To check for the existence of a Layer, Style
or a
Dimstyle can be achieved in a couple of ways. To achieve it using plain
old
AutoLisp and the (tblsearch) function, have a look here:
Working with Layers, DimStyles and Styles
http://www.afralisp.com/lispa/lisp31.htm
eg.
(defun C:Lon ()
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (3 of 7) [23/03/2005 05:49:44 p.m.]
(if (tblsearch "LAYER" "STEEL")
(command "layer" "on" "STEEL" "")
(princ "\nLayer STEEL not found")
)
(princ)
)
If you would like to achieve it the "new" way, (and the preferable way I
must admit) have a look at doing it using Visual Lisp :
Visual Lisp Collections
http://www.afralisp.com/vl/collect1.htm
eg.
(defun c:layerAdd ()
(vl-load-com)
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object))
theLayers (vla-get-layers acadDocument)
newLayer (vla-add theLayers "Steel"))
(vla-put-color newLayer 5)
(vla-put-linetype newLayer "Dashed2")
(princ)
);defun
This routine creates a new Layer named "Steel" with Color "5" and a
Linetype
of "Dashed2". If the Layer already exists, this routine simply does
nothing.
Visual Lisp may seem a bit daunting at first, but believe me, it's the way
to go..
---------------------
Hi Kenny, thanks for yours concepts on my English and the little dog
tale.
Question : 1
Which is the system variable at SETVAR that handle the back ground
color, I
often change it from original dwg in black to light gray such 250, and to
white 255 when I do a copy and paste to other program , or to *.wmf.
Question : 2
What's the way to export a file in graphic mode not so heavy as *.bmp
and
not so particular as *.wmf, say at any format as jpg, gif, in a such mode
it
can be handled by image, photshop, paint or so.
GABRIEL CALOS DE VIT
---------------------
Hi Kenny, I was wondering if you could give me any advice on securing
plain
Autolisp files.
Is it possible for autolisp to read and write to the registry or ini files?
Can Autolisp read motherboard or hardrive etc serial No's?
One of my problems is that the program will be running on machines
that run
LT 2000i with an add-on that enables it to use lisp files. That rules out
DosLib which as you know uses arx so any protection will have to be
plain
lisp. What I would like to do is try and make the routines run so that
they
will only run on a particular computer, hence the trying to get the
hardrive
serial.
Mick
---------------------
Kenny,
How can I delete page setups in one drawing and insert new ones from
another
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (4 of 7) [23/03/2005 05:49:44 p.m.]
drawing automatically? Let me 'splain. Recently we went through
updating
our network. This means that our printers now have new addresses. I
have
created a single drawing which I use for creating Page Setups for
sending
the same drawing to various printers. This allows me the flexibility to
copy a group of page setups from my "master" drawing into a new
drawing. I
then have the ability to click on one page setup and have the drawing
go to
an 11x17 printer. I can then click on another page setup and have the
drawing go to our full size printer, and so on. I have since modified that
one "master" page so my different Page Setups for the different
printers have been updated. However, the drawings I am currently
working on,
all 250+ of them, have page setups in them referring to the old printer
address. I would like to be able to go into a drawing, run a program,
and
have the program delete all of the current page setups
and install new ones which I have established in another drawing. Is
this
possible?
Thanks!
Marty Kriewall
----------------------
The Answers
-----------------------
Kenny,
Over the weekend I came up with a strong solution for password
protecting
attributes.
Download LOCKBLOCK.zip from my website :
http://www.cad-code.com/archive.htm
Let me know what you think.
Peter Jamtgaard
--------------------
Thanks Peter.
This site is well worth a visit......
---------------------------
Hi Kenny,
http://www.cadmagazine.net/programming.html
The site referred is Arabic. I took a look at it.
I think it is good enough to add it to your links.
Sherko
------------------------------
Kenny,
My wife also thinks you're weird.
She just don't standunder.
She thinks that I'm lysdectic.
Les
---------------------------
The Back Stoep
---------------------------
In my teens, I lived in Zambia for quite a few (interesting) years. There,
the local brew (beer) was known as "chibuku". The locals though,
never
referred to "chibuku" as a drink, but rather as animals! This used to
confuse me terribly until the day I plucked up some courage and
declared my
ignorance by asking the question........
What are "chibuku?"
"Chibuku" are really cute little animals with an intoxicating, liquid gait
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (5 of 7) [23/03/2005 05:49:44 p.m.]
and a very frothy, heady personality. They have sparkling amber eyes.
They are very active in the afternoon and through the night. In a big
enough
herd they lead you to seeing other game such as unusual elephants. In
those
circumstances, (especially in the morning), they have been known to
come
back and pound on your head with their little hooves.
They have a terrible habit of getting themselves trapped in bottles, but
that's OK, because blokes in particular are willing to spend most of
their
lives freeing them from bottles and spending time with them. Alas, if
you
leave them out too long without interacting with them they become dull
and
flat and rather sour.
Their Aussie counterparts have names such as "fosters" - Australian
for
"chibuku".
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
You have subscribed to this Newsletter
using the following E-mail address :
kramage@namdeb.com.na
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
If we're to Loud, you're to Old!
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye...........
*****************************************************************************
The information contained in this e-mail is confidential and may
be subject to legal privilege. If you are not the intended recipient,
you must not use, copy, distribute or disclose the e-mail or any
part of its contents or take any action in reliance on it. If you have
received this e-mail in error, please e-mail the sender by replying
to this message. All reasonable precautions have been taken to
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (6 of 7) [23/03/2005 05:49:44 p.m.]
ensure no viruses are present in this e-mail and the sender cannot
accept responsibility for loss or damage arising from the use of this
e-mail or attachments.
*****************************************************************************
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-04
http://www.afralisp.com/newsletter/2002/2002-04.htm (7 of 7) [23/03/2005 05:49:44 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
--------------------------------------------------
AfraLisp Newsletter No 2002-05
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
This line has writing in it.
--------------------------------------------------
Have you visited here yet?
VBA Expresso
"Lost in Stupid Parenthetheeth"
http://www.vbdesign.net/~rrath/cgi/ikonboard/ikonboard.cgi
If not, Why not?
-------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Here's a wee bit of advice that was given to me by a wrinkled, grey
haired, old man who turned out to be twenty three and died a year later
from a mixture of rattlesnake poisoning and cirrhosis of the liver :
"Always have a bottle of whiskey in your pocket in case of snakebite.
Furthermore, always have a small snake in your other pocket."
------------------------------------------------------------------
On his death bed, his last words to me before he shuffled off the mortal
coil were, "Always be prepared".
To be honest, what he really said was,
"Ulfaays pee prapaairet - hicc".
------------------------------------------------------------------
So, I'm going to take his advice and ask you to participate in a bit of a
survey.
There are lot's of AutoCAD newsletters like this this, and quite few
sites like AfraLisp.
I would like to ask you what you DO NOT like about them. You don't
have to go into heavy details and that sort of thing, but I would
appreciate if you would let me know your thoughts and feelings. I
promise to publish the lot, warts and all. (I'll only take out the swear
words.) So, come on, let me know what you really think. Pass this on to
your friends and colleagues. If they don't have access to email, don't
worry! Ask them to write their comments on the back of a postcard,
stick a stamp on, make their way to to an Internet Cafe, copy what
they've written on the postcard into email, and then send it to me.
Simple hey?
-------------------------------------
Quotation of the Week
-------------------------------------
I am not a vegetarian because I love animals;
I am a vegetarian because I hate plants.
------------------------
The Site
------------------------
I've finally finished with the technical update on the site (phew-wipe's
sweat off brow). The indexing is now working, so you should be able to
search the site correctly, or should I say, get meaningful results from
the search. As well, the Site Map is catalogued, which should make the
site a lot easier to navigate. http://www.afralisp.com/sitemap.com
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (1 of 6) [23/03/2005 05:49:45 p.m.]
I can now hopefully, forget about the technical issues of the site and
get back into some coding. Hey, I'm also trying to record a CD!!!!
(excuses, excuses - Kenny's Mum)
------------------------
The Questions
------------------------
I enclose a lisp routine which I find quite useful. It draws an arc tangent
to an existing line, beginning in any designated point on the line and
ending through a designated point exterior to the line. It draws any of
the
two possible solutions. I would like that it should be able to draw the
arc
tangent, not only to a line, but also to a straight segment of a
lwpolyline.
For that, I would need a method of picking a straight segment of
lwpolyline,
and getting as output the two extreme points (vertex) of that segment.
Rogelio Bravo
;CODING STARTS HERE
(defun C:arctg ( / rec pt1 pt2 ang pt3 pt4 resp ref)
;draw arc tangent to existing line,
; beginning in designated point on the line
; and ending through a designated point exterior to the line
(setq rec (entget (car (entsel "\nPick base line:"))))
(setq pt1 (cdr (assoc 10 rec)));punto inicial recta
(setq pt2 (cdr (assoc 11 rec)));punto final recta
(setq ang (angle pt1 pt2)); angulo recta
(setq ref (getvar "osmode"));almacena valor inicial de osmode
(command "_osnap" "_end,_nea");establece nuevos refent
(setq pt3 (getpoint "\nPick, on the line, the initial point of arc: "))
(setvar "osmode" ref);restablece valores iniciales de osmode
(setq pt4 (getpoint "\nPick final point of arc: "))
(command "_arc" pt3 "_e" pt4 "_d" (/ (* 180.0 ang) pi))
(initget 6 "Yes No")
(if (null (setq resp (getkword "\nIs arc correctly oriented? (Y/N)<Y>:" )))
(setq resp "Yes")
)
(while (/= resp "Yes")
(setq ang (+ ang pi))
(command "_erase" "_l" "")
(command "_arc" pt3 "_e" pt4 "_d" (/ (* 180.0 ang) pi))
(initget 6 "Yes No")
(if (null (setq resp (getkword "\nIs arc correctly oriented? (Y/N)<Y>:" )))
(setq resp "Yes")
)
);end while
)
;CODING ENDS HERE
-----------------------------------
Hey Kenny....
Is there any way to check the status of a LAYER. ei. is it frozen, off,
locked etc...
Thanks
Russ Johnston
------------------------
Russel,
First create the layer STEEL then type the following :
(setq t (tblsearch "LAYER" "STEEL"))
The entity list of the layer STEEL should be returned :
((0 . "LAYER") (2 . "STEEL") (70 . 64) (62 . 7) (6 . "CONTINOUS"))
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (2 of 6) [23/03/2005 05:49:45 p.m.]
The first part of the entity list is '0', indicating Associative 0.
In this case it's an entry in the "LAYER" Table.
Associative 2 indicates the name of the layer. STEEL in our case.
Associative 70 is the state of the entity. 1 is Frozen, 2 is Frozen on new
paper space view ports and 4 is locked. These numbers are added to
64. In this case the layer is neither frozen nor locked.
Associative 62 is the colour of the layer. Ours is white which is colour
number 7. If the colour number is a negative number then the layer is
off.
Associative 6 is the linetype of the layer, in this case, "CONTINUOUS".
If the (tblsearch) had not found the layer then it would have returned
'nil' and you would know that the layer did not exist.
Therefore, all you have to do is test for the relevant associative code
value to determine the status of your layer.
----------------------
How do you permanently save AutoLISP variables in the drawing file?
For example, userr1-5 system variables are saved in drawing file.
Thanks
Rusty
-------------
Rusty,
There are a few ways of permanently save variable data within a
drawing file. You could use Extended Entity Data -
http://www.afralisp.com/lispa/lisp21.htm or you could give Application
Data a try - http://www.afralisp.com/lispa/lisp12.htm
---------------------
Hi Kenny,
I saw my remark about the Arabic CAD website in your newsletter. I
became very popular these days. This is the second time you publish
my name in your newsletter. THANX
I have a little question :
First take a look at this code;
;CODING STARTS HERE
(defun QQQQ ()
(princ "\nThis is function QQQQ")
(princ)
)
(defun I_do_not_know_how ()
(setq var1 "QQQQ")
;;; I want to call QQQQ using the variable var1
;;; var1 holds the name of the function I want to call
;;; an urgent call to Kenny :-)
(princ "\nIs there a way to do this ? ")
(princ)
)
;CODING ENDS HERE
Is my question clear ?
By the way I am using AutoCAD 2002
Yours
Sherko
---------------------------
First we need to rewrite the QQQQ function :
(defun QQQQ (message )
(princ message)
(princ)
)
Load "QQQQ" into AutoCAD.
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (3 of 6) [23/03/2005 05:49:45 p.m.]
Now type this at the command line :
(setq var1 "QQQQ")
Followed by this :
((eval (read var1)) "This is function QQQQ")
----------------------
Is it possible to have a message box open when a pop down menu is
called from the top of the screen in acad2000, to inform users of new
additions to the menu?
Thanks,
Kevin
----------------------
The Answers
-----------------------
The question was :
> What's the way to export a file in graphic mode not so heavy as *.bmp
and
> not so particular as *.wmf, say at any format as jpg, gif, in a such
mode it
> can be handled by image, photshop, paint or so.
>
> GABRIEL CALOS DE VIT
And the answer is :
Hi Kenny
Hope the recording goes well, I hear you need it ;-)
[cheeky swine, he won't say that when I'm a rich and famous Rock Star
surrounded by a flock of big breasted beauties - Kenny]
If the above user is using >AutoCAD 2000 they can set up a
Printer/Plotter to accomplish the task of creating a .jpg or other image
file formats that are supported when you choose the "Raster File
Formats" option from within the Add-A-Plotter Wizard window.
The PUBLISHTOWEB command uses Printers/Plotters set up this way,
so you could just choose "PublishToWeb JPG.pc3" from the drop
down window on the Plot Device Tab within the Plot dialog box to get a
.jpg file.
Have a great weekend,
Mike Perry
--------------------------
Funny, when I was in Kenya the brew of choice(?) was Tuskers.
Garry
------------
Nice beer, I've had a few gallons of that.
--------------------------
;;;REVIEW STARTS HERE;;;
William Kishonti asked me to have a look at this. I didn't have much
time, but it's well worth trying out. Pop along and and have a look at
the demo version. Unfortunately, he wants money for the real thing :-(((
Hurricane PowerTool for AutoCAD
http://www.74mph.coat
;;;REVIEW ENDS HERE;;;
---------------------------
The Back Stoep
---------------------------
The Top 5 Reasons Dogs Don't Use Computers
20) Can't stick their heads out of Windows 2000.
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (4 of 6) [23/03/2005 05:49:45 p.m.]
19) Fetch command not available on all platforms.
18) Hard to read the monitor with your head cocked to one side.
17) Too difficult to "mark" every website they visit.
16) Can't help attacking the screen when they hear "You've
Got Mail."
15) Fire hydrant icon simply frustrating.
14) Involuntary tail wagging is dead giveaway they're browsing
www.pethouse.com instead of working.
13) Keep bruising noses trying to catch that MPEG frisbee.
12) Not at all fooled by Chuckwagon Screen Saver.
11) Still trying to come up with an "emoticon" that signifies
tail-wagging.
10) Oh, but they WILL... with the introduction of the
Microsoft Opposable Thumb.
9) Three words: Carpal Paw Syndrome
8) 'Cause dogs ain't GEEKS! Now, cats, on the other hand...
7) Barking in next cube keeps activating YOUR voice
recognition software.
6) SmellU-SmellMe still in beta test.
5) SIT and STAY were hard enough, GREP and AWK are out
of the question!
4) Saliva-coated mouse gets mighty difficult to manuever.
3) Annoyed by lack of newsgroup, alt.pictures.master's.leg.
2) Butt-sniffing more direct and less deceiving than
online chat rooms.
and the Number 1 Reason Dogs Don't Use Computers...
1) TrO{gO DsA[M,bN HyAqR4tDc TgrOo TgYPmE WeIjTyH P;AzWqS,. *
(* 1) Too Damn Hard To Type With Paws.)
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
The more you drink, the better we sound!
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
VBA Expresso
"Lost in Stupid Parenthetheeth"
http://www.vbdesign.net/~rrath/cgi/ikonboard/ikonboard.cgi
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye...........
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (5 of 6) [23/03/2005 05:49:45 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-05
http://www.afralisp.com/newsletter/2002/2002-05.htm (6 of 6) [23/03/2005 05:49:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, February 09, 2002 15:38
--------------------------------------------------
AfraLisp Newsletter No 2002-06
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
Space left for you to enter notes.
--------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band
http://www.BedrockBand.com
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Hey , this Newsletter must be good 'cos, even though only a couple of
readers responded to last weeks request, NOBODY slagged off
AfraLisp. It just goes to show you what good taste you have. But, I
would still like your comments on what you dislike about AutoCAD
websites and Newsletters. So please take a minute out of your life and
drop me a line. Next week I publish!!!! Promise. No excuses. On pain of
death. Cross my heart and hope to die.
Content is always a problem with me. I tend to look for the more
unusual and obscure type of information. A good example is the type
of links I publish. I mean, who else let's you know where to find an
Arabic, or a Spanish speaking AutoCAD website? (I found a good
Japanese Visual Lisp site the other day).
The same goes for the type of coding I post. I try to look for something
different that's not available from other sources. I really wouldn't like to
produce a Newsletter that explains, yet again, something like how to
create a selection set, on screen, using VBA. And to do that week after
week would drive me to drink. (sic)
Political correctness also plays a big part. I've written stuff and
thought, whoa Kenny, that's a heavy. I must say, I normally bounce it
off Randall first 'cos he's got some good judgement in that respect. (he
normally says, "Post it", and then sits back and watches me take the
flack). Seriously though, you have to take every bodies politics,
religion, race, sense of humour, etc into account with every word you
write. It does get a wee bit difficult. That's why I ask for feedback. It's
hard to gauge what the reader wants AND what he expects. Somebody
did once mention that they don't like being given only a partial answer
to their query. I must admit, I'm very guilty of that but for a reason. I
don't feel that I should write the solution for you. I think that you
should be made to use your brain. I'll point you in the correct direction
and then you should take it from there. Remember the old saying "Give
a man a fish and he'll eat it then starve. But show him HOW to fish......."
Which brings me to the main gist of this post. I try and encourage
active participation in my website and my newsletter.
So , let me know what you want, what you don't like and what you
would like to see in the future. Ask Randall, you get a letter from
someone asking if it would be possible to run AutoCAD from your
wristwatch whilst diving at 200m. Hey, I'll try to do it, and hopefully,
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (1 of 9) [23/03/2005 05:49:47 p.m.]
have a laugh at the same time. Or, would you prefer me to post the
latest announcements from AutoDesk?
What "I" don't like!!!
1) Websites full of inane announcements in regards to how great their
product is and how everybody in the whole wide world is now using it.
2) Slooooooow websites.
3) Navigating hundreds of pages, only to find out that the FREE offer is
really shareware (and costs me lot's to download).
4) Websites that a not really free. (send us money and we'll give you
further access.)
5) Newsletters FULL of advertisements.
6) Newsletters that copy and paste from AutoCAD help and other
newsletters and then pretend that they've discovered something new.
7) Websites/Newsletters/Forums that take themselves too seriously. (a
lot of so called "Moderators" are extremely guilty of that).
My philosophy in two words.
"Provide information".
-------------------------------------
Quotation of the Week
-------------------------------------
"You can't be a real country unless you have a national beer and a
national airline.
It helps if you have some kind of a football team, or some nuclear
weapons, but at the very least you need a beer".
Frank Zappa
------------------------
The Site
------------------------
With a lot of help and input from a lot of people (this means I
"borrowed" most of it), I've added a complete listing of AutoCAD
System Variables for your reference.
http://www.afralisp.com/lisp/acadvar.htm
If you would like to print it out and have it next to you whilst you
whistle and work, you can download the list in PDF format :
http://www.afralisp.com/zip1/acadvar.zip
Or, in RTF format :
http://www.afralisp.com/zip1/acadvar1.zip
Now don't say I'm not nice you!!
------------------------
Want to Load and Run an AutoLisp routine from VBA?
Sub RunLisp()
ThisDrawing.SendCommand "(Load ""Alispfile"")" & vbCr & "Alispfile"
& vbCr
End Sub
------------------------
The Questions
------------------------
Hi Kenny,
Thanks for all your efforts on your website Afralisp. It is so good to be
able to find out quality info on Autocad.
I have a question to ask you in regards to Autocad 2000, I am trying to
find out some information on how to go about designing a program to
perform automated parts nesting and G code production for use with a
cnc cutting machine. I have done some searching on the web and have
found several stand alone programs but I have not been able to find
out how they work or even how they operate in principle. I was hoping
that you might have had some experience with this in the past or knew
someone who could explain the algorithm to me. I understand how a
manual nest can be created from ployline shapes inserted onto a
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (2 of 9) [23/03/2005 05:49:47 p.m.]
material blank but the automation of this process and the generation of
G code eludes me. Any help would be gratefully received.
Thanks
Steve Reid
I mentioned to Steve that I know nothing about G code. I passed him
on to James Bond who then introduced him to M. Unfortunately G was
at the dentist.
Can anybody else help Steve?
----------------------
Kenny,
Yet another question. I was wondering if you had
or could quickly develop a routine or something that
would batch bind xrefs to drawings simply that runs
outside of autocad. Similar to pack and go and with
any other goodies that you think could go along with
this? Thanks.
=====
Mark
Mark.
Have a look at this Batch Slide application. It should be simple enough
for a man of your calibre and good looks to modify the coding to bind
any xrefs in the drawing instead of making slides. Any problems, drop
me a line.
(it's a pity you can't e-mail six packs!!)
http://www.afralisp.com/lispa/lisp59a.htm
----------------------
Hi Kenny,
You articles and tutorials are great! I have made several routines that I
couldn't have made without you tutorials.
I'm still using AutoLisp for some (small) routines that I make.
Now I'm trying to make a routine that will read data from an Ascii-file
and inserts it in the drawing. ATOF does the job, but when I use
numbers like "201823.52" ATOF returns "201824.0" (yes, I see it's eight
places).
Is there a setting that I've missed?
Gerrit
Are you using the number for anything else than internal calculations?
ATOF returns the precise number but the display is limited to the
eternally irritating cut-offs (wasn't there once a sysvar that controlled
display of decimals?).
Try evaluating (- (atof "201823.52") (fix (atof "201823.52"))) - it should
return 0.52
Stig Madsen
----------------------
And to reinforce Stigs theorem :
Command: (setq a "201823.52")
"201823.52"
Command: (setq b (atof a))
201824.0
Command: (setq c (* b 2.0))
403647.0
Command: (setq d (rtos c))
"403647.0400"
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (3 of 9) [23/03/2005 05:49:47 p.m.]
----------------------
Help! I need a routine to draw a pline around an existing hatch that was
created with bhatch and consequently has no selectable boundary.
Bruce
-----------------------
;CODING STARTS HERE
(defun mosta-theway ()
(setq ENT (entget (car (entsel "\nPick hatch! :"))))
(setq POINTS (massoc 11 ENT))
(command "PLINE")
(foreach P POINTS
(command p)
);end foreach
(command "c" "")
);end defun
;MASSOC by Jaysen Long
(defun massoc (key alist / x nlist)
(foreach x alist
(if
(eq key (car x))
(setq nlist (cons (cdr x) nlist))
);end if
);end foreach
(reverse nlist)
);end defun
(princ)
;CODING ENDS HERE
Al Paca
----------------------
The Answers
-----------------------
Would you like a listing of AutoCAD User Groups?
Then make your way here :
AutoCAD Resource site
http://www.llpsite.com/
There's also LOTS more......
--------------------------
Note : A#
---------------------------
Want to print out your VB code?
Want to add line numbers?
Check out "PrettyCode"
http://www.vbcity.com/page.asp?p=home
Free, :-)) but you will need to register.
----------------------------------------------------------
Peter Jamtgaard very kindly gave me permission to publish this.
Have you ever had a gazillion drawings open in mdi mode and just
wanted to shut down a bunch of them, but not all of them quickly.
This program displays a dialog box with all of the open acad
documents listed. You can multiple select the ones you want to close
and pick o.k. It has some kinda cool stuff in it for everyone.
//DCL CODING STARTS HERE
dddwgs : dialog {
label="Select Documents to close";
:list_box { key = "dwgs";
height = 20;
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (4 of 9) [23/03/2005 05:49:47 p.m.]
width = 30;
multiple_select = true;
allow_accept = true;
}
ok_only;
}
//DCL CODING ENDS HERE
Save this as "CLOSE_DWG.DCL"
;AUTOLISP CODING STARTS HERE
(defun C:CLOSE_DWG (/ ACADOBJ DOCOBJ DOCSOBJ FULL NAME
PATH)
(vl-load-com)
(get_docs_list)
(ddcloser)
(if DWGLST
(progn
(setq CNT (- (length DWGLST) 1))
(repeat (length DWGLST)
(setq DOCOBJ (vlax-invoke-method DOCSOBJ "item" (nth CNT
DWGLST))
CNT (1- CNT)
PATH (vlax-get-property DOCOBJ "path")
NAME (vlax-get-property DOCOBJ "name")
FULL (strcat PATH "\\" NAME)
)
(if (= (vlax-get-property DOCOBJ "active") :vlax-false)
(vla-close DOCOBJ :vlax-true FULL)
(princ (strcat "\nDrawing " FULL " is still active: "))
)
(vlax-release-object DOCOBJ)
)
(vlax-release-object DOCSOBJ)
(vlax-release-object ACADOBJ)
)
)
(princ)
)
(defun GET_DOCS_LIST ()
(setq ACADOBJ (vlax-get-acad-object)
DOCSOBJ (vlax-get-property acadobj "Documents")
DOCSLIST nil
)
(vlax-for FOR-ITEM DOCSOBJ
(setq DOCSLIST (cons
(strcat (vlax-get-property FOR-ITEM "Path") "\\"
(vlax-get-property FOR-ITEM "Name")
)
DOCSLIST
)
)
)
(setq DOCSLIST (reverse DOCSLIST))
(princ)
)
(defun DDCLOSER (/ DWGS DWGNUM IDD )
(setq IDD (load_dialog "close_dwg.dcl"))
(new_dialog "dddwgs" IDD)
(start_list "dwgs")
(mapcar 'add_list DOCSLIST)
(end_list)
(action_tile "dwgs" "(setq DWGLST (read (strcat \"(\" $value \")\")))")
(setq start (start_dialog))
(setq ddone (done_dialog))
)
(princ "\nC:CLOSE_DWG")
(princ)
;AUTOLISP CODING ENDS HERE
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (5 of 9) [23/03/2005 05:49:47 p.m.]
Save this as "CLOSE_DWG.LSP"
---------------------------
Kenny,
Just want to thank you for a great site with all its info. I am new to lisp
and have Been trying to modify some existing routines. Your tutorials
and other material have been a big help.
I am a pipefitter and welder, and for the last 3 years, a piping detailer
using Autocad. The more I discover about lisp, the more I realize how
routines can simplify and speed up the creation of drawings.
Attached is a routine similar to your cumdist.lsp only this will calculate
slope up or down and post elevation tags at selected points. This really
comes in handy doing layout for plumbing drains and DI water and
other piping systems that have to drain completely. I didn't write the
original code, but have done my best to sort it out and clean it up along
with adding the up/down routine and some additional tagging. Any
suggestions you may have would be greatly appreciated. Please feel
free to share it with your readers if you desire.
Thanks again
Jim Exler
;;;CODING STARTS HERE
;;;SLOPE / DISTANCE
;;;Routine to calculate elevation change up or down
;;;from user entered elevation and % slope
;;;and place elev tags at selected points.
;;;Modified by Jim Exler to add new features.
(defun C:SD (/ d0 d1 e0 e1 e2 p1 p2 s0 s1 s2 t1 t2 v1 v2) ;main routine
(if (= e2 nil)
(setq e2 0.0)
);set first-time global elevation value to 0.0
(setq e0 (getdist (strcat "Starting Elevation: (" (rtos e2) ") ")))
(if (= e0 nil)
(setq e1 e2)
(setq e1 e0)
);if nil, use last elev, else use inputed
(if (= s2 nil)
(setq s2 1.0)
);set default slope to 1 %
(prompt (strcat "@ " (rtos s2 2) "%"))
(princ)
(if (= t1 nil)
(setq t1 "N")
);set default tag ? to N
(setq p2 0);gives p2 a value, if p2 ever equals nil, end routine
(setq d1 0)
(princ "\nEnter Slope %: <")
(princ s2)
(princ "> ")
(setq s0 (getREAL));get % input
(if (= s0 nil)
(setq s0 S2)
);end if
(setq S2 s0)
(setq s1 (/ s2 100));conv to decimal
(setq v1 "Y")
(setq v2 (strcase
(getstring (strcat "\nSlope Downward? Y/N [" v1 "] "))
)
);get direction of elev chg
(if (= v2 "")
(setq v2 nil)
)
(if (= v2 nil)
(setq v1 v1)
(setq v1 v2)
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (6 of 9) [23/03/2005 05:49:47 p.m.]
)
(if (= v1 "Y")
(setq direct "d")
(setq direct "u")
);set var to indicate up or down
(setq p1 (getpoint "First point: "))
;routine to determine if you want to place a tag at start elevation
(setq
t2 (strcase
(getstring (strcat "\nPlace Elevation Tag? Y/N [" t1 "] "))
)
)
(if (= t2 "")
(setq t2 nil)
)
(if (= t2 nil)
(setq t1 t1)
(setq t1 t2)
)
(if (= t1 "Y")
(progn;place tag if Yes
(command "leader" p1 pause "" (rtos e1) "")
(princ)
)
)
(if ;start if #1
(progn ;start progn #1
(while p2
(if ;start if #2 if no next pt given, exit
(setq p2 (getpoint p1 "\nNext pt: ")) ;get next point
(progn ;start progn #2
(setq d1 (+ d1 (setq d0 (distance p1 p2)))
p1 p2
)
(setq e2 (* d1 s1)) ;calculates drop from last point.
(if (= direct "d")
(setq e2 (- e1 e2))
(setq e2 (+ e1 e2)) ;subtracts or adds drop
); from last elevation.
(princ (strcat "\nDist from last pt: " (rtos d0)))
;display interim values
(princ (strcat " Cumulative dist: " (rtos d1)))
(princ (strcat "\nElevation: " (rtos e2)))
;displays elevation
; routine to determine if you want to place a tag
(setq
t2 (strcase
(getstring
(strcat "\nPlace Elevation Tag? Y/N [" t1 "] ")
)
)
)
(if (= t2 "")
(setq t2 nil)
)
(if (= t2 nil)
(setq t1 t1)
(setq t1 t2)
)
(if (= t1 "Y")
(progn ;place tag if Yes
(command "leader" p1 pause "" (rtos e2) "")
(princ)
)
)
) ;end progn #2
) ;end if #2
) ;end while
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (7 of 9) [23/03/2005 05:49:47 p.m.]
(if (/= d1 0) ;start if #3
(eval d1)
(princ)
) ;end if #3
) ;end progn #1
(princ)
) ;end if #1
;);end MD
(princ (strcat "Cumulative dist: " (rtos d1)))
;at end, display cumulative dist.
(princ (strcat "\nElevation Change: " (rtos (- e2 e1))))
;at end, displays total elevation chg.
(princ)
)
(princ)
;;;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
Me! A male chauvinist pig? Never!!
I always give both sides of the story.
Are Computers Male or Female?
A teacher divided an adult education class into 2 groups; male and
female. They were asked to determine what gender was appropriate for
a PC.
The males decided that they must be female because:
No one but their creator understands their internal logic.
The native language that they use to communicate with other
computers is incomprehensible to everyone else.
Even your smallest mistakes are stored in long term memory for later
retrieval.
As soon as you make a commitment to one, you find yourself spending
half your earnings on accessories for it.
So what gender did the ladies think PCs should be?
Inevitably they decided that a computer was male because:
In order to get their attention you have to turn them on.
They have a lot of data but are still clueless.
They are supposed to help you solve your problems but half the time,
they ARE the problem.
As soon as you commit to one, you realise that, if you had waited a
little longer, you could have had a better model.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less or more than 42 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (8 of 9) [23/03/2005 05:49:47 p.m.]
"BedRock - The Band in the Sand"
A Rock 'n Old Band
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
-----------VBA Expresso---------------
"Lost in Stupid Parenthetheeth"
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
We'll be checking!!!
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Night, Night.....
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-06
http://www.afralisp.com/newsletter/2002/2002-06.htm (9 of 9) [23/03/2005 05:49:47 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, February 17, 2002 7:27
--------------------------------------------------
AfraLisp Newsletter No 2002-07
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
Have you visited this site yet?
-----------VBA Expresso---------------
"Lost in Stupid Parenthetheeth"
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
I will be checking!!!
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
I hope your cattle are sitting well in the fields and your corn is free
from elephant tracks. (a well known Zulu greeting).
--------------------------------
Quote of the week
--------------------------------
"You know you're drunk when you fall off the floor."
---------------------------------------------------------------------------------------------
What do you HATE about AutoCAD Websites/Newsletters?
---------------------------------------------------------------------------------------------
Wow, what a response!!! Thank's to everybody for your feedback.
For the newcomers to this Newsletter (welcome by the way), and the
geriatrics among the rest of you who have forgotten, I asked the above
question in last weeks Newsletter. This week I'm posting your
responses.
I'm not going to post the total contents of your e-mails 'cos of space
constrictions, and I'm also not going to say who said what. But, I
haven't changed a thing. (you lie Kenny, you fixed up a couple of
spelling mistakes.) Alright, I admit that I had to fix up a lot of Randall
Rath's spelling errors but, other than that, this is what you wrote. I
must apologise for the fact that this subject is taking up so much
space in this weeks Newsletter that could have been filled with coding.
But, believe me, it's very important to me to find out that what I'm
doing, and that the way I'm doing it, is on the right track. I'll make it up
to you next week. OK, over to you...........
--------------
A good site is a site that adds something at least twice a month. Most
of the sites I visit do no change or add anything for months. Some of
them do not change at all.
---------------
Many sites are there just to sell you some product. They do not give
you any help. A good site knows what the surfer wants and try to
balance
---------------
I don't mind if the code gets long but the information leading up
to it needs to be more to the point.
---------------
I think the personality of the person composing the e-mail makes a
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (1 of 8) [23/03/2005 05:49:49 p.m.]
difference.
It always helps to have something to laugh about at the end and
sometimes beginning of the newsletter.
---------------
The only suggestion I have for the site is in the autolisp section.
The differences in code from r10 to r2002 have caused some trouble
when
running a particular lisp routine that's not compatible with the version
it was written for. It would be nice to see what the listed lisp routine
will run correctly on. Also I wish you could come up with a good way to
debug the older lisp routines to work with the latest revision. (The
lisp analyser in migration tools hasn't done us a lot of help).
----------------
Och there laddie, twoud' be mean of meself not to respond to thoust
request, so here it be in good faith and full of the crap that I am;
needless to say I am sober.
Cannot find any begrudgings about 'others' sites or newsletters, cos I
only allow my mail room to accept the ones I want.
I have a favourites list of hundreds of sites but only visit when I want
and which I want. Now, if I didnt have your site with which to roam, I
would truely be
lost in my own lounge room.
For you, tara the noo, and the vote for Fosters.
-------------------
The lisps are quite good andI've been trying to learn more especially in
customization of AutoCAD. I still would like to have lisps/routines for 3
dimensional objects, how to integrate lets say 3D object like a tank,
pumps given the technical specifications to generate models of plants
for presentations. I've been using add-ins to AutoCAD they seem to
work well but not the way I would like to do. I would like when I
produce a model of a plant then sent it in either
power point for presentation and still extract data to an excel to
generate Bill of materials.
--------------------
A friend of mine asks me to publicize his dilemma, and would like to
know if he is the only one to suffer it.
He is a 55 years old civil engineer (slide-rule generation), in a
management more that a technical role, and so when 10 years ago his
firm discarded manual drafting and began using Autocad 10 he really
was not obliged to learn it, but felt it was his duty to understand this
new tool and so speak with draftmen, suppliers, etc. in the same lingo.
As Autocad was not his primary duty, he spent only a few hours
(mostly, at home) with it, so he needed almost four years to feel
relatively comfortable with it. At that point he knew enough about
Autocad (Version 11, if I remember well) to appreciate that, without
customizing it, its usefulness was quite limited, so he began studying
Autolisp, neglected his family, wrestled with parenthesis and defuns
and now, five more years and two autocad versions later, is the proud
owner of about 150 homemade lisp routines, and many more
downloaded from Webs (Afralisp, primarily) which allow him to draw
his sketches in a fast and efficient way, and begin reaping, at last, the
harvest of 10 years of hard labor.
Alas, the Autodesk folks tracked mercilessly this development (with
CIA and Microsoft help, I suppose), and just, now, when he has spent
10 years and countless hours the learn the vagaries of Autocad and the
subtetlies of Autolisp, the guys change the rules, publish three new
Autocad versions in two years (2000, 2000i, 2002) make clear that
Autolisp is dead but, graciously, announce that old dinosaurs like my
friend need only invest a few more years to master Visual Basic (which,
needless to say, will be, in 5-8 years time, replaced by Aural Basic,
Sensual Basic or who know what) to rebuild the routines which,
essentially, will do the same they already do.
Well, sorry, you win. I can't follow. Stop the world, I am leaving.
By the way, you all know already that my friend is me.
-----------------------
I like to go to web page where I can learn something that can make my
daily
work easier and more proficient. I visit those web pages as read my
e-mail
between 5 to 6:30 am almost every day.
So returning to your question, and sorry about my personal info, I like
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (2 of 8) [23/03/2005 05:49:49 p.m.]
web
pages where I can find ways to do specific things like: how to insert a
Word
document into AutoCAD?, or how to treat Xrefs, Biding them, attaching
or
overlaying?, or stuff that makes my life easier.
I really like AutoCAD; I hate that about the time that you feel that you
have almost learn any AutoCAD release, there is a new upgrade, with
enough
changes to make your life miserable, so you need to learn new ways,
(where I
work almost each client ask us to work with the latest update); and
then
you'll find that you need to update your PC because the new programs
require
more power, this is sad amigo.
----------------
I think my main gripe with web sites is the slow ones. and the ones we
have to wade through a load of rubbish to get to the meat.
----------------
This is a belated reply to your first request for feedback. It may be the
start of a new year but I fell asleep - took a while for the after effects of
the festive season to catch up on me.
I had been quite interested in a number of other sites relating to
AutoCAD and Lisp but found the info to be not exactly what I was
looking for.
Nothing turns me off more than having to pay for anything. The best
things in life are free, thats why I got married - I guess.
------------------------
So many times I think I'm getting something great, only to find I have to
pay for it. Then again, I get great ideas from these pay-for-it routines -
ie get up off my lazy backside and write my own routines, with a lot of
help and tips from AfraLisp site!!!.(Whats it they say..... you can't steal
something thats already been stolen??)
-------------------------
What I don't like about CAD related websites.
Those darn pop up advertisements...
-------------------------
Add this to my list of things I hate...broken links
-------------------------
Here in Brazil we didn't have good books in Portuguese. I had to read
the "AutoCad reference guide" and the tutorials to learn something...
Everything in English....Too hard and boring.
I like English, but in my opinion the Autodesk didn't believe in Brazil
--------------------------
Something that you should cover on your site is more in depth on
polylines.
--------------------------
Only few words to tell you that it could be better if the Lisp routines
were written using the 'international style' with the '_' (Underscore)
character before the commands.
If you make so the Lisp routines can run on AutoCAD in all languages.
---------------------------
Really though, I hate boring, humorless content. Like at the AutoDesk
Forum.
---------------------------
I hate it when you can't download an attachment even when you're
logged in on a site! Not to name names <cough autodesk cough>
---------------------------
I hate the news letters that don't really say anything useful have lots of
ads and demos but no code or they aren't doing Q & A.
It's refreshing not to be talked down at or told something is stupid.
Lots of the other forums have Know-it-alls that don't even help. Here
most everyone is helpful and if they are making fun of you it is really all
just fun not condescending.
-----------------------------
I have the type of personality that doesnt' allow me to put up with bs
websites, so those I find that are worth something I hang around,
which is why I don't remember the 2 dozen or so others i tried to get
information out of 3 months ago.
-----------------------------
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (3 of 8) [23/03/2005 05:49:49 p.m.]
Newsletters that don't have an easy way to opt out of them. Most any
newsletter that has you email them with the word unsubscribe,
unsuscribe, remove me, removeme, rererererereremeoveme or
something like that is very annoying. If you are going to have a news
letter I suggest you make the unsubscribe link a link to a website to
remove addresses. Not to mention make sure the link works!
I might have more later. I just charged myself up into a lather!
----------------------------
Ok you asked for it. My first comment is I don't like the message
following
the cursor on AfraLisp. The affects on main page are very cool but
maybe you should have
it as a toggle, sometimes people just want to hurry through for
information.
----------------------------
I HATE newsletters that:
Don't have enough content or have too much content.
Don't have any humor or have too much chicken related humor. (you
know who you are)
Don't answer the exact question that I was thinking of just then.
Have ads that demand my attention by flashing, moving or skin.
Promote product more than they promote education.
Don't make me think.
----------------------------
For my 2 cents, I really hate the sites where, if you disagree with
another participant, you are relegated to a ranking slightly below whale
excrement. Not only do you know nothing of the subject at hand, but
you are taking up way too much space on earth.
------------------------------
------------------------------
Thank's again to everyone for their constructive response.........
-----------------------------
-----------------------------
To make up for this weeks shortage of coding, here's a free gift.
(Well it's free 'cos I didn't have to pay for it!!!)
"I thought you guys might want to use this lisp routine I made. It is
used for replacing old blocks with a new block, like updating old
drawings to new standards".
Rodney Nelson
CODING STARTS HERE
;;
;; Function to replace selected block with another...
;; Another Bad Ass thing by Rodney Nelson
;;
(defun c:blkswitch (/ BENT BENTL BNAME X ANG SS1 N1 D IND ENT
XVAL ELIST BP)
(initerr)
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "undo" "be")
(setq BENT (entsel "\nPick old block you want to replace: "))
(if (null BENT)
(while (null BENT)
(princ "\nNothing selected, Pick old block you want to replace or press
^C to quit: ")
(setq BENT (entsel))
);while
);if
(setq BENTL (entget (car BENT)))
(setq BNAME (cdr (assoc 2 BENTL)))
(if (= BNAME NIL)
(progn
(alert "Entity selected is not a block. ")
);progn
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (4 of 8) [23/03/2005 05:49:49 p.m.]
(progn
(setq newblk (entsel "\nPick new block to replace old: "))
(if (null newblk)
(while (null newblk)
(princ "\nNothing selected, Pick new block to replace old or press ^C
to quit: ")
(setq newblk (entsel))
);while
);if
(setq newblkl (entget (car newblk)))
(setq newblkname (cdr (assoc 2 newblkl)))
(if (= newblkname NIL)
(progn
(alert "Entity selected is not a block. ")
);progn
(progn
(setq newblklay (cdr (assoc 8 newblkl)))
(prompt "\nSearching database for blocks...")
(setq SS1 (ssget "x" (list (cons 2 BNAME))))
(setq N1 (sslength SS1))
(setq D "t")
(while D
(setq IND (- N1 1))
(setq ENT (ssname SS1 IND))
(setq edat (entget (ssname SS1 IND)))
(entdel (ssname SS1 IND))
(setq blklay (cdr (assoc 8 edat)))
(setq inspt (cdr (assoc 10 edat)))
(setq xscl (cdr (assoc 41 edat)))
(setq yscl (cdr (assoc 42 edat)))
(setq blkrot (cdr (assoc 50 edat)))
(setvar "clayer" newblklay)
(command "-insert" (strcat blockpath newblkname) inspt blkscale ""
(rtd blkrot))
(setq N1 (- N1 1))
(if (= N1 0)
(setq D NIL)
);if
);while
);progn
);if
(prompt (strcat "\nAll done! " (rtos (sslength SS1) 2 0) " <" BNAME ">
blocks were replaced with <" newblkname "> blocks"))
);progn
);if
(command "undo" "e")
(reset)
(princ)
);defun blkswitch
(defun rtd (radval / )
(* radval (/ 180.0 PI))
)
;;
;; Global error checking routine
;;
(defun error()
(prompt "\nGlobal Error Trap Loaded")
(princ)
);defun
;;;*error checking routine
;;;
(defun initerr ()
(setq oldlayer (getvar "clayer"))
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (5 of 8) [23/03/2005 05:49:49 p.m.]
(setq oldsnap (getvar "osmode"))
(setq oldpick (getvar "pickbox"))
(setq oldorth (getvar "orthomode"))
(setq echo (getvar "cmdecho"))
(setq olddia (getvar "attdia"))
(setq oldfile (getvar "filedia"))
(setq oldang (getvar "snapang"))
(setq temperr *error*)
(setq *error* trap)
(princ)
)
;;;*
(defun trap (errmsg)
(command nil nil nil)
(if (not
(member errmsg
'("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg))
)
(setvar "clayer" oldlayer)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(setvar "orthomode" oldorth)
(setvar "cmdecho" echo)
(setvar "attdia" olddia)
(setvar "filedia" oldfile)
(setvar "snapang" oldang)
(princ "\nError Detected, Resetting Original Enviroment ")
(terpri)
(setq *error* temperr)
(princ)
)
;;;
(defun reset ()
(setq *error* temperr)
(setvar "clayer" oldlayer)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(setvar "orthomode" oldorth)
(setvar "cmdecho" echo)
(setvar "attdia" olddia)
(setvar "filedia" oldfile)
(setvar "snapang" oldang)
(princ)
)
;;;
(princ)
;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
And another great free contribution ...............
"No Question or insights, just thought you might enjoy this bit of
humor..."
The Parrot :
A lady was walking down the street to work and she saw a parrot on a
perch
in front of a pet store. The parrot said to her, "Hey lady, you are really
ugly." Well, the lady is furious! She stormed past the store to her work.
On the way home she saw the same parrot and it said to her, "Hey lady,
you
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (6 of 8) [23/03/2005 05:49:49 p.m.]
are really ugly." She was incredibly ticked now.
The next day the same parrot again said to her, "WOW lady, you are
still
really ugly."
The lady was so ticked that she went into the store and said that she
would
sue the store and kill the bird. The store manager replied profusely and
promised he would make sure the parrot didn't say it again.
When the lady walked past the store that day after work the parrot
called
to her, "Hey lady." She paused and said, "Yes?"
The bird said, "You know."
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less or more than 42 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band
http://www.BedrockBand.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
The End............

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (7 of 8) [23/03/2005 05:49:49 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-07
http://www.afralisp.com/newsletter/2002/2002-07.htm (8 of 8) [23/03/2005 05:49:49 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, February 22, 2002 3:00
--------------------------------------------------
AfraLisp Newsletter No 2002-08
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
I'm trying out a new e-mail system this week, so please keep your fingers crossed and
hope everything goes well for my sake. The old method was getting a wee bit
cumbersome to maintain as well as taking up quite a lot of my time.
-----------------
As promised, lot's of coding in this weeks letter, so without further adieu, let the show
start.
-----------------
Quick one. I'm looking for the word "Hello" in every language in the world.
Can anybody help?
--------------------------------
Quote of the week
--------------------------------
Here's to cheating, stealing, fighting, and drinking.
If you cheat, may you cheat death.
If you steal, may you steal a woman's heart.
If you fight, may you fight for a brother.
And if you drink, may you drink with me.
--------------------------------
The Site
--------------------------------
If you are a student of history, or even better, a professor in mathematics in regards to
statistics and probabilities, you will be aware of the fact that certain actions have a habit
of repeating themselves without any external stimuli whatsoever. In a forum like this
Newsletter, this phenomena is definitely present in the form of the same
question/questions being asked time after time. To alleviate the time spent on, first
asking the question, and then answering the question and, after major research and
development, the "FAQ", or "Frequently Asked Questions" page was invented.
Here, you can find answers to the more commonly asked questions that tend to surface
within the AutoLISP/VBA world.
So, if you have a problem in regards to AutoLISP, Visual Lisp or VBA, this should be
your first stop. If you have no luck there, then send me an e-mail and I'll try and answer,
or post your question.
You may even have an answer to a question that you feel should be part of the FAQ
page. If that's the case, please feel free to e-mail me, along with your FAQ answer, and I'll
ensure that it's timorously posted.
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi?act=FAQ
And the Question is : Why is it the FAQ page on the VBDesign site and not on AfraLisp?
And the Answer is : 'Cos Randall has to maintain it, not me. (manic giggle from moi).
The real reason is 'cos he thought of it first.....bounder!!
--------------------------------
The Questions
--------------------------------
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (1 of 11) [23/03/2005 05:49:51 p.m.]
I am a beginner of Autolisp programming. I am trying to write a program to read a file
which contain X,Y coordinate and reform data of polygon onto Autocad platform.
However, the file that I retrieve is a string. I would like to know how to convert to LIST?
Thank you for your attention.
Li
--------------------------
This function will search an external text file for a list of values and import the values. It
will then assign each value in the list to a variable.
First copy and paste this into Notepad :
*LIST1
1.0,2.0,3.0
*LIST2
4.0,5.0,6.0
*LIST3
7.0,8.0,9.0
*LIST4
10.0,11.0,12.0
Save this as "AFILE.TXT"
This is your point data.
Now copy and paste this into Notepad and save it as "Grab.lsp"
;CODING STARTS HERE
(defun grab (SIZA)
(setq dlist nil
size (strcat "*" SIZA)
file (findfile "AFILE.TXT")
fp (open file "r")
item (read-line fp)
)
(while item
(if (= item size)
(setq data (read-line fp)
item nil
)
(setq item (read-line fp))
)
)
(if data
(progn
(setq maxs (strlen data)
count 1
chrct 1
)
(while (< count maxs)
(if (/= "," (substr data count 1))
(setq chrct (1+ chrct))
(setq numb (atof (substr data (1+ (- count chrct)) chrct))
dlist (append dlist (list numb))
chrct 1
)
)
(setq count (1+ count))
)
(setq numb (atof (substr data (1+ (- count chrct))))
dlist (append dlist (list numb))
)
)
)
(close fp)
(mapcar 'set '(val1 val2 val3) dlist)
)
;CODING ENDS HERE
----------------------------------------
Usage :
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (2 of 11) [23/03/2005 05:49:51 p.m.]
(grab LIST1) will return (1.0 2.0. 3.0)
VAL1 will contain 1.0
VAL2 will contain 2.0
VAL3 will contain 3.0
(grab LIST4) will return (10.0 11.0. 12.0)
VAL1 will contain 10.0
VAL2 will contain 11.0
VAL3 will contain 12.0
--------------------------
I enclose a lisp routine which I find quite useful. It draws an arc tangent to an existing
line, beginning in any designated point on the line and ending through a designated
point exterior to the line. It draws any of the two possible solutions. I would like that it
should be able to draw the arc tangent, not only to a line, but also to a straight segment
of a lwpolyline.
For that, I would need a method of picking a straight segment of lwpolyline, and getting
as output the two extreme points (vertex) of that segment. . If you, or anybody else, know
how to do it, please answer to mailto:rbravocos@terra.es
Rogelio Bravo
;CODING STARTS HERE
(defun C:arctg ( / rec pt1 pt2 ang pt3 pt4 resp ref)
;draw arc tangent to existing line,
; beginning in designated point on the line
; and ending through a designated point exterior to the line
(setq rec (entget (car (entsel "\nPick base line:"))))
(setq pt1 (cdr (assoc 10 rec)));punto inicial recta
(setq pt2 (cdr (assoc 11 rec)));punto final recta
(setq ang (angle pt1 pt2)); angulo recta
(setq ref (getvar "osmode"));almacena valor inicial de osmode
(command "_osnap" "_end,_nea");establece nuevos refent
(setq pt3 (getpoint "\nPick, on the line, the initial point of arc: "))
(setvar "osmode" ref);restablece valores iniciales de osmode
(setq pt4 (getpoint "\nPick final point of arc: "))
(command "_arc" pt3 "_e" pt4 "_d" (/ (* 180.0 ang) pi))
(initget 6 "Yes No")
(if (null (setq resp (getkword "\nIs arc correctly oriented? (Y/N)<Y>:" )))
(setq resp "Yes")
)
(while (/= resp "Yes")
(setq ang (+ ang pi))
(command "_erase" "_l" "")
(command "_arc" pt3 "_e" pt4 "_d" (/ (* 180.0 ang) pi))
(initget 6 "Yes No")
(if (null (setq resp (getkword "\nIs arc correctly oriented? (Y/N)<Y>:" )))
(setq resp "Yes")
)
);end while
)
;CODING ENDS HERE
--------------------------
Good morning Mr. Ramage!
It is 3:00 am and I am QUITTING! There must be an easy answer to my problem but I can't
find it! What would be the VBA code to put on a command button to simply erase
everything on my Autocad drawing? I will be very grateful if you can take a minute to
answer my question.
Pierre Desmarais
------------------------
Pierre,
ThisDrawing.EraseAll
Sorry, now seriously :
This will erase everything except xrefs, active layer, active style, etc....
Public Sub EraseAll(Doc As AcadDocument)
Dim Entity As AcadEntity
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (3 of 11) [23/03/2005 05:49:51 p.m.]
Dim Layout As AcadLayout
For Each Layout In Doc.Layouts
For Each Entity In Layout.Block
Entity.Delete
Next
Next
Call Doc.PurgeAll
Set Entity = Nothing
Set Layout = Nothing
End Sub
-------------------------
Kenny,
Have you ever heard of a program or anything that would do the following? That Drawing
Explorer thingy on PointA sucks and doesn't do anything inside ACAD.
Click open drawing. Highlight a drawing in the dialog box and have it show a 'tool tip'
containing a list of the drawing properties or show the properties on the right side under
the thumbnail view. It would show the same information as right clicking on a drawing
file, selecting properties and going to the summary tab. Just trying to eliminate steps to
get drawing info.
Thanks man.
Jeff Crawford
-------------------------
The Answers
--------------------------
LISP developers, you can download at :
www.afitec.com/upload/texte_vecteur_demo.zip
a demo version of TEXTE_VECTEUR, a LISP routine to display any text string as vectors.
Use in your own programs to:
* display entities properties, such as layer, block name, lines length...etc
* display information or warning messages
* display points coordinates without the need to use ordinate dimensioning
Patrick EMIN
mailto:pemin@club-internet.fr
-------------------------
In you examples you repeatedly disable OSNAP by setting it's value to 0. a better way is
to add 16384 to the old OSNAP value, this merely turn OSNAP off ( the same as pressing
the OSNAP button or F3), setting the OSMODE system variable clears any settings, the
method below allows the user to quickly re-enble OSNAP if they wish rather than having
to reset the snap settings.
(setq osmode (getvar "osmode"))
;store existing OSNAP value
(if (< osmode 16384)
;tests if OSNAP enabled
(setvar "osmode" (+ osmode 16384))
;disables OSNAP
)
(setvar "osmode" osmode)
;resets OSNAP to original value OR
(if (> (getvar "osmode") 16384)
;test if OSNAP is enabled
(setvar "osmode" (- (getvar "osmode") 16384))
;enables OSNAP with current settings
)
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (4 of 11) [23/03/2005 05:49:51 p.m.]
Michel Loftus
--------------------------
Kenny,
I finished a good Beta of the hatch-pline routine...(an almost-there if you will)
It may be a bit long for the newsletter but feel free to post on your website or wherever...
Tony Lukasz
mailto:tlukasz@engineeringstudio.com
;CODING STARTS HERE
;Draws polyline boundaries around hatches.
;--------------------------------------------------------------------------
(defun c:hatch-pl (/ ent numpts plst osmo stpt lstpt arcflag pldat bdst mdpt bpt nxtpt
pllst)
(setvar "CMDECHO" 0)
(command "UNDO" "BEGIN")
(setq numpts -1 plst nil
osmo (getvar "OSMODE")
stpt nil lstpt nil
arcflag 0 *error* err1
ent (entsel "\nPick Hatch:")
)
(if ent (progn
(setq ent (entget (car ent)))
(setvar "OSMODE" 0)
(foreach pldat ent
(if (= (car pldat) 93)(progn
(if (= numpts 0)(if (= arcflag 1)(arc-sub)(vert-sub)))
(setq numpts (cdr pldat))
)
)
(if (and (= (car pldat) 10) (>= numpts 0))
(if (= arcflag 1)(arc-sub)(vert-sub))
)
(if (= (car pldat) 42)(progn
(if (= (cdr pldat) 0.0)(setq arcflag 0)
(setq arcflag 1 bdst (* 0.5 (cdr pldat)))
)
)
)
)
))
(command)
(command "UNDO" "END")
(setvar "OSMODE" osmo)
(setvar "CMDECHO" 1)
(prin1)
)
;--------------------------------------------------------------------------
(defun vert-sub ()
(setq numpts (1- numpts))
(if (>= numpts 0)
(if plst
(progn
(setq lstpt (cdr pldat))
(if (null stpt)(setq stpt (cdr pldat)))
(command lstpt)
)
(progn
(setq stpt (cdr pldat) plst 1)
(command "PLINE")
(command stpt)
)
)
(progn
(command stpt)
(command "")(command)
(setq pllst (entlast))
(setq numpts -1 plst nil stpt nil lstpt nil)
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (5 of 11) [23/03/2005 05:49:51 p.m.]
(keep-pl)
)
)
)
;--------------------------------------------------------------------------
(defun arc-sub ()
(setq numpts (1- numpts))
(if (= numpts -1)(setq nxtpt stpt)(setq nxtpt (cdr pldat)))
(setq arcflag 0
bdst (* bdst (distance nxtpt lstpt))
mdpt (polar lstpt (angle lstpt nxtpt)(/ (distance lstpt nxtpt) 2.0))
bpt (polar mdpt (+ (/ pi 2.0) (angle nxtpt lstpt)) bdst)
)
(if (>= numpts 0)
(if plst
(progn
(setq lstpt (cdr pldat))
(command "A" "S" bpt lstpt "L")
)
)
(progn
(command "A" "S" bpt stpt)
(command "")(command)
(setq pllst (entlast))
(setq numpts -1 plst nil stpt nil lstpt nil)
(keep-pl)
)
)
)
;--------------------------------------------------------------------------
(defun keep-pl (/ kpstr)
(princ "\nNew boundary found - Keep new boundary? (<Y>/N):")
(command "SELECT" pllst)
(initget "Y y N n")
(setq kpstr (getkword))
(if (or (= kpstr "")(= kpstr " ")(null kpstr))(setq kpstr "Y"))
(if (= (strcase kpstr) "N")(progn (command)(command "ERASE" pllst "")))
(command)
)
;--------------------------------------------------------------------------
(defun err1 (emsg)
(command)
(command "UNDO" "END")
(command "UNDO")
(command)
(setvar "OSMODE" osmo)
(princ "\nERROR - ")(princ emsg)(princ "... ")
(setq *error* nil)
(prin1)
)
(prin1)
;CODING ENDS HERE
--------------------------
Would you like to switch ON or OFF a list of Layers?
Then look no further :
;CODING STARTS HERE
;Switch OFF a list of Layers
(defun mlayoff ( LLST / BOB RT)
(foreach L LLST
(setq BOB (entget(tblobjname "layer" L)))
(setq rt (- (cdr(assoc 62 BOB))))
(setq BOB
(subst (cons 62 rt)
(assoc 62 BOB)
BOB)
)
(entmod BOB)
)
(princ)
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (6 of 11) [23/03/2005 05:49:51 p.m.]
)
;--------------------------------------
;Switch ON a list of Layers
(defun mlayon ( LLST / BOB RT)
(foreach L LLST
(setq BOB (entget(tblobjname "layer" L)))
;reset next line
(setq rt (abs (cdr(assoc 62 BOB))))
(setq BOB
(subst (cons 62 rt)
(assoc 62 BOB)
BOB)
)
(entmod BOB)
)
(princ)
)
(princ)
;---------------------
Usage :
(setq a '("2" "3"))
(mlayoff a)
Switches OFF Layers "2" and "3"
(mlayon a)
Switches ON Layers "2" and "3"
;CODING ENDS HERE
---------------------------
Dear Kenny,
I am a subscriber to your newsletters. I must say that I like your site because it is not
annoying and is loading fast. LISP & VBA programmers can find many useful things.
Some time ago I issued in English a book "AutoCAD Developer's Guide to Visual LISP",
see www.cad.dp.ua/poleschuk_e.html or
www.alistpublishing.com/books/acad_lis/info.htm
There are sample programs published in it. Maybe something will be interesting for you
and your visitors. I attach two texts, ffp.lsp and flp.lsp, written ... by my wife (she is a
programmer too). These programs help to find the first or the last point of an entity (for
POLYLINE, LWPOLYLINE, SPLINE, LINE, ARC).
Best wishes,
Nikolai Poleshchuk
;CODING STARTS HERE
;**********************************************************************
;**** In the current coordinate system, find the first point of
;**** an entity of type LINE, POLYLINE, LWPOLYLINE, ARC, or SPLINE.
;**** V.Savelieva, 2000
;**********************************************************************
;**** No globals.
;**** No arguments.
;**** The locals:
;**** w - the list returned by the entsel function;
;**** e - the specified entity;
;**** le - the list of the e entity;
;**** ten - the type of the e entity;
;**** ca10 - the value of the dotted pair (DXF code is 10);
;**** pt - the point to be found.
;**** The return value:
;**** a list of three coordinates of the points or nil
;**** (if an entity of another type was specified).
;**********************************************************************
;
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (7 of 11) [23/03/2005 05:49:51 p.m.]
(defun ffp ( / w le e ten ca10 pt)
; Request for an object
(setq w
(entsel
"\nSpecify an object of type LINE, ARC, POLYLINE, LWPOLYLINE, or SPLINE: "
);entsel
)
; Check if an object is specified
(while (null w) (setq w (entsel "\nNo object is selected, repeat: ")))
; Read the entity's data, get the values for the DXF codes 0 and 10
(setq
le (entget (setq e (car w)))
ten (cdr (assoc 0 le))
ca10 (cdr (assoc 10 le))
);setq
; Display the type of the entity
(princ (strcat "\n" ten " "))
; Find the first point of the object in its own coordinate system
(setq pt
(cond
; LINE and SPLINE
((or (= ten "LINE")(= ten "SPLINE")) ca10)
; LWPOLYLINE (append the third coordinate to ca10)
((= ten "LWPOLYLINE") (append ca10 (list (cdr (assoc 38 le)))))
; ARC (find the point by the center, the radius, and the angle
((= ten "ARC")
(list
(+
(car ca10)
(* (cdr (assoc 40 le)) (cos (cdr (assoc 50 le))))
);+
(+
(cadr ca10)
(* (cdr (assoc 40 le)) (sin (cdr (assoc 50 le))))
);+
(caddr ca10)
);list
)
; POLYLINE (read the first vertex of the polyline)
((= ten "POLYLINE")(cdr (assoc 10 (entget (entnext e)))))
; For all other types display a message and return nil
(T
(princ "\nInvalid entity type. ")
nil
);T
);cond
);setq pt
; Transform the coordinates to the current UCS
(if pt (trans pt e 1))
);defun
;CODING ENDS HERE
;CODING STARTS HERE
;**********************************************************************
;**** In the current coordinate system, find the last point of
;**** an entity of type LINE, POLYLINE, LWPOLYLINE, ARC, or SPLINE.
;**** V.Savelieva, 2000
;**********************************************************************
;**** No globals.
;**** No arguments.
;**** The locals:
;**** w - the list returned by the entsel function;
;**** e - the specified entity;
;**** le - the list of the e entity;
;**** ten - the type of the e entity;
;**** ca10 - the value of the dotted pair (DXF code is 10);
;**** pt - the point to be found.
;**** The return value:
;**** a list of three coordinates of the points or nil
;**** (if an entity of another type was specified).
;**********************************************************************
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (8 of 11) [23/03/2005 05:49:51 p.m.]
;
(defun flp ( / w e le ten ca10 e1 pt)
; Request
(setq w
(entsel
"\nSpecify an object of type LINE, ARC, POLYLINE, LWPOLYLINE, or SPLINE: "
);entsel
);setq
; Check if an object is specifie
(while (null w) (setq w (entsel "\nNo object is selected, repeat: ")))
; Read the entity's data
(setq
le (entget (setq e (car w)))
ten (cdr (assoc 0 le))
ca10 (cdr (assoc 10 le))
)
; Display the type of the entity
(princ (strcat "\n" ten " "))
; Find the last point of the object in its own coordinate system
(setq pt
(cond
; LINE
((= ten "LINE") (cdr (assoc 11 le)))
; SPLINE
((= ten "SPLINE") (cdr (assoc 10 (reverse le))))
; LWPOLYLINE (append the third coordinate)
((= ten "LWPOLYLINE")
(append
(if (= 1 (cdr (assoc 70 le))); closed?
ca10; last = first
(cdr (assoc 10 (reverse le)))
);if
(list (cdr (assoc 38 le)))
);append
);LWPOLYLINE
; ARC (find the point by the center, the radius, and the angle
((= ten "ARC")
(list
(+
(car ca10)
(* (cdr (assoc 40 le)) (cos (cdr (assoc 51 le))))
);+
(+
(cadr ca10)
(* (cdr (assoc 40 le)) (sin (cdr (assoc 51 le))))
);+
(caddr ca10)
);list
);ARC
; POLYLINE (read the vertices of the polyline up to the SEQEND entity
((= ten "POLYLINE")
(if (= 1 (cdr (assoc 70 le))); closed?
(cdr (assoc 10 (entget (entnext e)))); last=first
(progn
(setq e1 (entnext e))
(while (= "VERTEX" (cdr (assoc 0 (entget (entnext e1)))))
(setq e1 (entnext e1))
);while
(cdr (assoc 10 (entget e1)))
);progn
);if
);POLYLINE
; For all other types display a message and return nil
(T
(princ "\nInvalid entity type. ")
nil
);T
);cond
);setq
; Transform the coordinates to the current UCS
(if pt (trans pt e 1))
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (9 of 11) [23/03/2005 05:49:51 p.m.]
);defun flp
;CODING ENDS HERE
--------------------------
Kenny,
You might like to recommend your readers to download Bubble, a new free utility for
AutoCAD :
http://www.bubblecad.com
Bubble displays an object's properties within AutoCAD at any time. There's no need to
run a command or go to a toolbar. Just move the cursor over an object, and voil! The
information related to that object will come up immediately.
Don' t miss this new great tool!!
Regards,
Neus Olmedo
ASUNI CAD
mailto:neus@asuni.com
---------------------------
The Back Stoep
---------------------------
Well, that's it for another week Ladies, and Gentlemen. Have a nice weekend and don't
do anything I wouldn't do. I leave you with this :
If Computer Companies made Toasters?
If Xerox made toasters... you could toast one-sided or double-sided.
Successive slices would get lighter and lighter. The toaster would jam your
bread for you. You would sometimes find bent paperclips within your toast!!
People would toast there bums on them at office parties.
If Cray made toasters... they would cost $16 million but would be
faster than any other single-slice toaster in the world.
If Sony made toasters... the Toast-Man would barely be larger than
the single piece of bread it was designed to toast, and it could be
conveniently attached to your belt.
If IBM made toasters... they would have one big toaster where people
bring bread to be submitted for overnight toasting. IBM would claim a
worldwide market for five, maybe six toasters.
If Apple made toasters... they'd claim their toaster was compatible
with all brands and styles of bread, but when you got it home you'd discover
the Bagel Engine was still in development, the Croissant Extension was three
years away, and that indeed the whole appliance was just blowing smoke.
And, of course, if Microsoft made toasters... every time you bought
a loaf of bread, you would have to buy a toaster. You wouldn't have to take
the toaster, but you'd still have to pay for it anyway. Toaster-XP would
weigh 15,000 pounds (hence requiring a reinforced steel countertop), and
draw enough electricity to power a small city, take up 95 per cent of the
space in your kitchen, would claim to be the first toaster that lets you
control how light or dark you want your toast to be, and would secretly
interrogate your other appliances to find out who made them. Everyone would
hate Microsoft toasters, but nonetheless would buy them since most of the
good bread only works with their toasters.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
The more you drink,
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (10 of 11) [23/03/2005 05:49:51 p.m.]
The better we sound.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
Or, send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+kenny@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-08
http://www.afralisp.com/newsletter/2002/2002-08.htm (11 of 11) [23/03/2005 05:49:51 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, March 01, 2002 9:50
--------------------------------------------------
AfraLisp Newsletter No 2002-09
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
38 degees Centigrade for over a week now. And that's in the fridge!! I'm telling you, it's
been a wee bit hot in this part of the world. I keep on taking my ice cold beer and rubbing
it along the back of neck to try and and cool the old conduit to the brain down. But, to no
avail. My family, friends, workmates and total strangers still say I'm weird??????
--------------------------------
Quote of the week
--------------------------------
"I was recently on a tour of Latin America, and the only regret I have was that I didn't
study Latin harder in school so I could converse with those people."
--------------------------------
The Site
--------------------------------
I've been a bit busy with the band I'm afraid to find time to post anything new BUT, yes
BUT!!!
Watch This Space..........
Hey, have you downloaded the new version of DosLib yet?
Very Nice.......
http://www.mcneel.com/
AND, why not join a pleasant and civilised conversation pertaining to AutoLisp :
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
Look for the "There is no VBA " Board...
--------------------------------
The Questions
--------------------------------
I'm trying to learn Autolisp and I would like to know how I should go about
remaning the layers in my drawings with a prefix or suffix. Would this be
better accomplished with VBA?
---------------
Liam,
No need to use VBA. Try this :
;CODING STARTS HERE
;This routine will place a Prefix in front of all Layer names
;and rename them.
;Of course, it will not rename Layer "0" or "Defpoints".
(prompt "\nType ChLayName to run.........")
(defun C:ChLayName ( / acadDocument theLayers layName)
(vl-load-com)
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (1 of 10) [23/03/2005 05:49:53 p.m.]
(setq pre (getstring "\nEnter Layer Prefix : "))
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'layer-mod)
(princ)
);defun
(defun layer-mod (theLayer)
(setq layName (vlax-get-property theLayer 'Name))
(if (not (member layName '("0" "Defpoints")))
(vla-put-Name thelayer (strcat pre layName))
) ;if
);defun
(princ)
;CODING ENDS HERE
-----------------------------------
I was looking through your and some other sites and couldn't find what I was looking for.
I've seen it before but can't remember where.
Is there a way to make a Layer current just by picking an object from the drawing? The
routine would be nice to compliment a list of buttoned macros like this :
[_Button("TBlock On", "TB0001.bmp", "ICON_24_BLANK")]^C^C-LAYER;ON;TBLOCK;;
---------------------------------------------
Crikey, another layer question!! OK, here we go :
;CODING STARTS HERE
(defun C:MLay ( / entity name layername)
(setq entity (car (entsel)))
(setq name (entget entity))
(setq layername (cdr (assoc 8 name)))
(setvar "clayer" layername)
(princ)
);defun
(princ)
;CODING ENDS HERE
Save this as MLay.lsp
Your Toolbar Macro would look something like this :
[_Button("All Layers ON", "TB0003.bmp", "ICON_24_BLANK")]^C^C(if (not C:MLay) (load
"MLay"));MLay
------------------------------
I hope you don't mind me revising one of your routines to create another.
You helped me with one that makes a layer current by selecting an object from the screen.
I revised it to turn off a layer by selecting an object. I removed (setvar "clayer" layername)
and replaced it with (command "-layer" "off" layername"")
Thanks again, this is great stuff.
Kevin
------------------------------
; Layer-SF.lsp
;
; Turn off a layer by picking an object from the drawing
;
;CODING STARTS HERE
(defun C:Layer-SF ( / entity name layername)
(setq entity (car (entsel)))
(setq name (entget entity))
(setq layername (cdr (assoc 8 name)))
(command "-layer" "off" layername "")
(princ)
);defun
(princ)
;CODING ENDS HERE
------------------------------------
Has someone done a lisp which uses txt files as a database and can write this data into
attributes?
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (2 of 10) [23/03/2005 05:49:53 p.m.]
With best regards
Kari Ruotsalainen
----------------------------
Have a look at this tutorial :
"VBA and External Text Files".
http://www.afralisp.com/vba/extext.htm
This should help get you started.
----------------------------
Kenny
I don't know if you or one of your readers can help, but I am looking for a routine that will
allow me to search for files and be able to multiple select the files I want. Basically, I want
to do what 'getfiled' does, but with multiple files and have the result return a list of
drawings selected. The routine would have a many applications, But the main thing I am
trying to achieve is a routine for inserting multiple xrefs.
Thanks
Dennis.
------------------------
Dennis,
We could write an application but why re-invent the wheel when there is already
something available. Pop along to Robert Mcneel and Associates and download "Doslib"
http://www.mcneel.com
You will find a "getfiled" function within this application that allows you to select multiple
files. For an example of usage in batch processing, have a look here :
http://www.afralisp.com/lispa/lisp59a.htm
-------------------------
Morning Kenny
I enjoy reading your new letter.
Today I have a VB question.
What's new? That's not really the question.
What I want to know is how to create an object name to pass to another procedure.
Example the name of the switch is ToggleSwitch1 How can I create this name and assign
it to the control?
I have a user control I call ToggleSwitch and have placed 4 switches on my form. When I
want to turn then all to an on position I use
This works but its not how I want to write the Sub.
Private Sub Command1_Click()
Call ohno(toggleswitch1)
Call ohno(toggleswitch2)
Call ohno(toggleswitch3)
Call ohno(toggleswitch4)
End Sub
Private Sub ohno(toggle As ToggleSwitch)
toggle.onoff = "on"
End Sub
Private Sub Command1_Click()
Dim toggle As ToggleSwitch
Dim iCnt As Integer
For iCnt = 1 To 4
Set toggle = ToggleSwitch
(Here I would like to asign the name of the toggle switch
Buy cantenating ToggleSwitch with iCnt then pass that to the sub
Something like toggle.name = "ToggleSwitch" & iCnt)
Call ohno(toggle)
Next
Set toggle = Nothing
End Sub
I just can not figure out how to create an object name to pass to another procedure.
Any suggestions? Thanks for any Help.
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (3 of 10) [23/03/2005 05:49:53 p.m.]
Tom
-------------------------
The Answers
--------------------------
Rotate All Blocks
Version 1.0
Written by: Steven Papke
Written on: 2/16/02
This routine asks the user to select a block. With the block name extracted, the user then
inputs the rotation angle and the routine will rotate all blocks of the same name.
;CODING STARTS HERE
(defun *error* (msg)
(setvar "osmode" osm)
(setvar "cmdecho" cme)
(princ "error: ")
(princ msg)
(princ)
)
(defun c:rab ()
(setq osm (getvar "osmode"))
(setq cme (getvar "cmdecho"))
(setvar "cmdecho" 1)
(setvar "osmode" 255)
(command "undo" "mark")
(prompt "\nSelect source block: ")
(setq bkpic (entsel))
(setq bkpicmod (car bkpic))
(setq bknam (cdr (assoc 2 (entget bkpicmod))))
(initget 1)
(setq rotang (getreal "\nRotation Angle: "))
(setq count 0)
(prompt "\nSelect block(s) to rotate: ")
(setq ss (ssget))
(if ss
(progn
(setq count 0)
(setq chgblk 0)
(setq ssl (sslength ss))
(princ "\nIsolating Block ")
(princ bknam)
(princ " from selection set.")
(princ "\n")
(setvar "cmdecho" 0)
(while (< count ssl)
(setq blk (entget (ssname ss count)))
(setq sinspt (cdr (assoc 10 blk)))
(setq sblk (cdr (assoc 2 blk)))
(if (= bknam sblk)
(progn
(if (/= (substr (cdr (assoc 2 blk)) 1 8) "*")
(command "ROTATE" (ssname ss count) "" sinspt rotang)
)
(setq chgblk (+ 1 chgblk))
)
)
(setq count (+ 1 count))
)
)
)
(princ ssl)
(princ " objects found.")
(princ "\n")
(princ chgblk)
(princ " blocks rotated.")
(setvar "osmode" osm)
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (4 of 10) [23/03/2005 05:49:53 p.m.]
(setvar "cmdecho" cme)
(princ)
)
(princ)
;CODING ENDS HERE
--------------------------
Hi Kenny
You don't now me but I now about you.
Here is some input for your great news letter from Holland
Wanna get rid of that irritating properties box on your screen? (Acad 2002)
Put the following lines in your ACAD.DVB
'CODING STARTS HERE
'This module wil remove the properties box from
'your screen the moment you issue a command
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If ThisDrawing.GetVariable("opmstate") = 1 And CommandName <> "PSELECT" Then
'if the properties box is visible
ThisDrawing.SendCommand "'prclose" & vbCr
'close the properties box !
End If
End Sub
'CODING ENDS HERE
Hemelop, RF (Rob)
---------------------------
Kenny
Have you ever heard of a variable that will allow you to align text to a current ucs angle
and not the wcs. I have written a basic program to rotate text & mtext to zero angle, using
an entmod on assoc 50. The routine works a treat when set to world cs, but only the mtext
works in a user cs, the text still rotates as though wcs was set.
The code is below if anyone would find it useful:
(DEFUN C:ut(/ p l n e new as)
(command "undo" "be")
(prompt "\nSelect Text to rotate")
(setq p (ssget))
(setq n (sslength p))
(setq l 0)
(setq entit (cdr (assoc 0 (setq e (entget (ssname p l))))))
(while (< l n)
(if (OR (= "TEXT" entit)(= "MTEXT" entit))
(progn
(setq s (cdr (setq as (assoc 50 e))))
(setq new (cons 50 0))
(setq e (subst new (cons 50 s) e))
(entmod e)
(setq l (1+ l))
);PROGN
);IF
);WHILE
(command "undo" "END")
);defun
Thanks
Dennis.
---------------------------
Kenny,
I sent you a lisp about a week ago from replacing old blocks with new ones. I made a
revision to include replacing blocks with attributes, and to replace the blocks but keep
their original scale factor. The blocks with attributes get inserted with the default value,
but I could change it to set the attributes to the value of the new blocks attribute. One
other
thing that I changed that I think you should consider covering is the (entselect) function I
created. It is a very useful global function to use for testing the object selection by the
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (5 of 10) [23/03/2005 05:49:53 p.m.]
type of object and if you miss. It is foolproof and will keep looping until you get correct
selection. I just thought you would find it interesting.
sample call - (entselect "TEXT" "you want to replace") - "TEXT" is kind of object that you
want to pick, "you want to replace" is the words that you want to be prompted - will look
like -> Select a TEXT, you want to replace: The variable ENTITY is what you can use
to get data (cdr (assoc 0 (entget (car ENTITY))))
Thanks, Rodney Nelson
;CODING STARTS HERE
;; Function to replace selected block with another...
;; By Rodney Nelson C.D. - AutoLISP programmer/Drafter/Designer, need help
;;rodneyn10@hotmail.com>
;;-------------------------------------------------------------------
;; BY : Rodney Nelson
;; CREATED : 01-05-02
;; REVISED : 02-22-02
;; DEFUN : BS
;; VERSION : 1.1
;; COMMENTS : revised to include block with attributes, insert new block at original scale
;; OTHER : build in error handeler
;;===================================================================
(defun c:bs () (blkswitch))
(defun blkswitch (/ BENT BENTL BNAME X ANG SS1 N1 D IND ENT XVAL ELIST BP)
(initerr)
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setvar "attdia" 0)
(setvar "attreq" 0)
(command "undo" "be")
(entselect "INSERT" "you want to replace with new")
(setq BENTL (entget (car ENTITY)))
(setq BNAME (cdr (assoc 2 BENTL)))
(if (= BNAME NIL)
(progn
(alert "Entity selected is not a block. ")
);progn
(progn
(entselect "INSERT" "to replace old block")
(setq newblkl (entget (car ENTITY)))
(setq newblkname (cdr (assoc 2 newblkl)))
(if (= newblkname NIL)
(progn
(alert "Entity selected is not a block. ")
);progn
(progn
(setq newblklay (cdr (assoc 8 newblkl)))
(prompt "\nSearching database for blocks...")
(setq SS1 (ssget "x" (list (cons 2 BNAME))))
(setq N1 (sslength SS1))
(setq D "t")
(while D
(setq IND (- N1 1))
(setq ENT (ssname SS1 IND))
(setq edat (entget (ssname SS1 IND)))
(entdel (ssname SS1 IND))
(setq blklay (cdr (assoc 8 edat)))
(setq inspt (cdr (assoc 10 edat)))
(setq xscl (cdr (assoc 41 edat)))
(setq yscl (cdr (assoc 42 edat)))
(setq blkrot (cdr (assoc 50 edat)))
(setvar "clayer" newblklay)
(command "-insert" newblkname inspt xscl yscl (rtd blkrot))
(setq N1 (- N1 1))
(if (= N1 0)
(setq D NIL)
);if
);while
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (6 of 10) [23/03/2005 05:49:53 p.m.]
);progn
);if
(prompt (strcat "\nAll done! " (rtos (sslength SS1) 2 0) " <" BNAME "> blocks were
replaced with <" newblkname "> blocks"))
);progn
);if
(command "undo" "e")
(reset)
(princ)
);defun blkswitch
(defun rtd (radval / )
(* radval (/ 180.0 PI))
)
;;===================================================================
;; Function is a front end Object Selection filter to help idiot proof some routines...
;; By Rodney Nelson C.D. - AutoLISP programmer/Drafter/Designer, need help
<rodneyn10@hotmail.com>
;;-------------------------------------------------------------------
;; BY : Rodney Nelson
;; CREATED : 02-22-02
;; DEFUN : (entselect)
;; VERSION : 1.0
;; COMMENTS :
;; OTHER : sample call - (entselect "TEXT" "you want to replace") - "TEXT" is kind
;; of object that you want to pick, "you want to replace" is the words that you want to
;; be prompted - will look like -> Select a TEXT, you want to replace:
;; The variable ENTITY is what you can use to get data (cdr (assoc 0 (entget (car ENTITY))))
;;===================================================================
(defun entselect (OBJECTTYPE ACTIONPROMPT)
(setq OBJECTNAME OBJECTTYPE)
(if (= OBJECTTYPE "INSERT") (setq OBJECTTYPE "BLOCK"))
(setq ENTITY nil)
(setq SELECTPROMPT (strcat "\nSelect a " OBJECTTYPE ", " ACTIONPROMPT ": "))
(if (null ENTITY)
(and
(while (null ENTITY)
(setq ENTITY (entsel SELECTPROMPT))
(setq SELECTPROMPT (strcat "\nNothing selected, Pick a " OBJECTTYPE ", "
ACTIONPROMPT " or <Esc> to quit: "))
);while
(while (/= OBJECTNAME (cdr (assoc 0 (entget (car ENTITY)))))
(setq ENTITY (entsel (strcat "\nObject selected not a " OBJECTTYPE " , Try again or <Esc>
to quit: ")))
(while (null ENTITY)
(setq ENTITY (entsel (strcat "\nNothing selected, Pick a " OBJECTTYPE ", "
ACTIONPROMPT " or <Esc> to quit: ")))
);while
);while
);and
);if
(princ)
);defun entselect
;;===================================================================
;; Error checking routine
;;===================================================================
(defun error() ;load function
(prompt "\nGlobal Error Trap Loaded") ;inform user
(princ)
);defun
;;;*==========================================================
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (7 of 10) [23/03/2005 05:49:53 p.m.]
(defun initerr () ;Initialize Error Function
(setq oldlayer (getvar "clayer")) ;Save System Variables
(setq oldsnap (getvar "osmode"))
(setq oldpick (getvar "pickbox"))
(setq oldorth (getvar "orthomode"))
(setq echo (getvar "cmdecho"))
(setq olddia (getvar "attdia"))
(setq oldreq (getvar "attreq"))
(setq oldfile (getvar "filedia"))
(setq oldang (getvar "snapang"))
(setq temperr *error*) ;Save *error* Function
(setq *error* trap) ;Re-name *Error* Function
(princ) ;Exit Quietly
) ;defun
;;;*===========================================================
(defun trap (errmsg) ;If Error
(command nil nil nil) ;Cancel Everything
(if (not ;Check for Error Type
(member errmsg ;If not System Error
'("console break" "Function Cancelled")) ;User Cancelled
)
(princ (strcat "\nError: " errmsg)) ;Show Error Message
)
(setvar "clayer" oldlayer) ;Reset System Variables
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(setvar "orthomode" oldorth)
(setvar "cmdecho" echo)
(setvar "attdia" olddia)
(setvar "attreq" oldreq)
(setvar "filedia" oldfile)
(setvar "snapang" oldang)
(princ "\nError Detected, Resetting Original Enviroment ") ;Inform User
(terpri)
(setq *error* temperr) ;Restore *Error* Function
(princ)
) ;defun
;;;*===========================================================
(defun reset () ;If no Error Restore Settings
(setq *error* temperr) ;Reset *Error* Function
(setvar "clayer" oldlayer) ;Reset System Variables
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(setvar "orthomode" oldorth)
(setvar "cmdecho" echo)
(setvar "attdia" olddia)
(setvar "attreq" oldreq)
(setvar "filedia" oldfile)
(setvar "snapang" oldang)
(princ)
) ;defun
;;;*======================================================
(princ)
;CODING ENDS HERE
------------------------------------
Kenny,
Love your newsletter web site ain't that bad either. Here's a lisp that annotates lines with
their decimal distance :
;CODING STARTS HERE
(defun text_line (en txt side / txt_size el aa dd aa2 p1)
(if (null txt_size)(setq txt_size (getvar "textsize")))
(if (and (= (type txt) 'str)
(= (type en) 'ename))
(if (= "LINE"
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (8 of 10) [23/03/2005 05:49:53 p.m.]
(cdr (assoc 0
(setq el (entget en)))))
(progn
(setq aa (angle (cdr (assoc 10 el))
(cdr (assoc 11 el)))
dd (distance (cdr (assoc 10 el))
(cdr (assoc 11 el)))
)
(if (< (/ pi 2) aa (* pi 1.5))
(setq p1 (cdr (assoc 11 el))
aa (rem (+ aa pi)(* pi 2)))
(setq p1 (cdr (assoc 10 el))))
(setq p1 (polar
(polar p1 aa (/ dd 2))
(if (null side)
(+ aa (/ pi 2))
(- aa (/ pi 2)))
txt_size))
(command "text" "m" p1 txt_size (angtos aa) (strcat txt "'"))
txt))))
(defun C:an (/ en el)
(setvar "cmdecho" 0)
(setq en (car (entsel "\nPick a Line: "))
el (entget en))
(if (= (cdr (assoc 0 el)) "LINE")
(progn
(text_line en
(rtos (distance (cdr (assoc 10 el))
(cdr (assoc 11 el)))
)
nil)))
(setvar "cmdecho" 1)
(princ))
;CODING ENDS HERE
Adam Tullis
---------------------------
The Back Stoep
---------------------------
Mrs. Davidson's dishwasher quit working so she called a repairman. Since she had to go
to work the next day, she told him, "I'll leave the key under the mat. Fix the dishwasher,
leave the bill on the counter, and I'll mail you the check. By the way, don't worry about my
Doberman. He won't bother you. But, whatever you do, do NOT under ANY circumstances
talk to my parrot!"
When the repairman arrived at Mrs. Davidson's apartment the next day, he discovered the
biggest and meanest looking Doberman he had ever seen. But just as she had said, the
dog just lay there on the carpet, watching the repairman go about his business. However,
the parrot drove him nuts the whole time with his incessant yelling, cursing, and
name-calling. Finally the repairman couldn't contain himself any longer and yelled, "Shut
up, you stupid ugly bird!"
To which the parrot replied, "Get him, Spike!"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy good music, visit :
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (9 of 10) [23/03/2005 05:49:53 p.m.]
"BedRock - The Band in the Sand"
The more you drink,
The better we sound.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+afralisp@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-09
http://www.afralisp.com/newsletter/2002/2002-09.htm (10 of 10) [23/03/2005 05:49:53 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, March 08, 2002 10:22
--------------------------------------------------
AfraLisp Newsletter No 2002-10
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
This line was deleted.
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
My Lords, Ladies and Gentlemen!
Welcome to this weeks edition of the AfraLisp Newsletter brought to
you by "Insto Eyedrops". You put one drop in, and your eye drops out!!
It's been another busy week for me. Not much time for coding as I've
spent much of my week in recording. If you're interested in a running
commentary of BedRocks new CD, pop along to
http://www.bedrockband.com/studio.htm and have a wee read. It will
give you an inside view of how the rich and famous (that's me) live
their lives.
--------------------------------
Quote of the week
--------------------------------
"Noli turbare circulos meos!"
[Do not disturb my circles!]
Archimedes
mailto:archy@heaven.com
--------------------------------
The Site
--------------------------------
Again, because of recording commitments, I didn't manage to add to
AfraLisp, so I decided to include something in this Newsletter that I
would normally add to the site. A lot of people have sent queries
regarding batch processing. Here's a little application to get you
started :
;;;CODING STARTS HERE
;;;This application will Batch Bind All Xref's in a selection of drawings.
;;;
;;;
;;;Known Dependencies :
;;;DosLib must be available and within the AutoCAD Search Path.
;;;Doslib is available from Robert McNeel & Associates
;;;http://www.mcneel.com
;;;Single Drawing Interface must be ON. (setvar "SDI" 1)
;;;The current drawing loaded must be saved before running
BatchBind.
;;;---------------------------------------
;;;Written by Kenny Ramage
;;;March 2002
;;;afralisp@mweb.com.na
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (1 of 9) [23/03/2005 05:49:55 p.m.]
;;;http://www.afralisp.com
;;;---------------------------------------
(prompt "\nBatchBind Ver 1.1 - Written by Kenny Ramage -
AfraLisp@mweb.com")
(defun c:batchbind ( / CNTR DPATH DWGPATH FILE1 FLAG FLEN
FNAME
FNAME1 LEN1 MESSAGE NFILES NFILES1 SCRFILE
UFILES)
;;;Firstly we need to check if DOSLib is loaded.
(cond
((= (atoi (substr (getvar "acadver") 1 2)) 13)
(if (not (member "doslib13.arx" (arx)))
(arxload (findfile "doslib13.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 14)
(if (not (member "doslib14.arx" (arx)))
(arxload (findfile "doslib14.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 15)
(if (not (member "doslib2k.arx" (arx)))
(arxload (findfile "doslib2k.arx"))))
);cond
;;;This, first checks the version of AutoCAD in use.
;;;It then checks to see if that version of Doslib is loaded.
;;;If it is not, it searches the AutoCAD search path for the
;;;relevant version, and then loads it.
;;;Now, we need to retrieve the names of the files that we would
;;;like to bind all xrefs.
(setq dwgpath (getvar "dwgprefix"))
;get the path to the current directory
(setq ufiles (dos_getfilem "Select Drawings"
dwgpath "Drawing Files (*.DWG)|*.DWG"))
;display the file dialogue box
(if (not ufiles)
;if no files selected or Cancel
(exit)
;exit the application
);
;;;The first item in the list "ufiles" is the directory path
;;;The remaining items are the file names.
;;;First, let's retrieve the directory path.
(setq dpath (nth 0 ufiles))
;retrieve the directory path - the first item.
;;;Next, let's get the number of items in the list,
;;;and make sure that the user wants to continue.
(setq nfiles (length ufiles))
;get the length of the list
(setq nfiles1 (itoa (- nfiles 1)))
;count only the file names and convert to a string
(setq message (strcat "You have choosen " nfiles1 " files.
\nDo you want to continue?"))
;set up the message
(setq flag (dos_msgbox message "AfraLisp Batch Bind" 4 4))
;display the message box
(if (= flag 6)
;if Yes selected
(progn
;do the following
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (2 of 9) [23/03/2005 05:49:55 p.m.]
;;;We'll now open an external file to write our script to.
(setq scrfile (strcat dpath "batdir.scr"))
;add the path to the script file name
(setq file1 (open scrfile "w"))
;open the file to write
(setq cntr 1)
;set the counter
;;;We'll now start the loop, format the file names, and add
;;;the commands to the script file.
(repeat (- nfiles 1)
;start the loop
(setq fname (nth cntr ufiles))
;get the file name
(setq fname (strcat dpath fname))
;add the path to the file name.
;"fname" will be used to open each
;drawing.
;;;write the commands to the script file
;;;You can change this section to suit almost any type of batch script
file
;;;that your imagination can come up with.
(write-line (strcat "open " fname) file1)
;open the drawing
;write it to the script file
(write-line (strcat "filedia" " 0") file1)
;switch off dialogues
;write it to the script file
(write-line (strcat "xref " "b " "*") file1)
;bind all xrefs
;write it to the script file
(write-line (strcat "filedia" " 1") file1)
;switch on dialogues
;write it to the script file
(write-line "qsave" file1)
;save the drawing
;write it to the script file
(setq cntr (1+ cntr))
;increment the counter
);repeat
;;;now that we've finished writing the commands to the script
;;;file, we must remember to close it.
(close file1)
;close the script file
(command "script" scrfile)
;run the script file and sit back and have a beer.
);progn
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (3 of 9) [23/03/2005 05:49:55 p.m.]
-------------------------------
And here's something extra.
;CODING STARTS HERE
(prompt "\nType MIRR to Run.....")
(defun c:mirr ( / oldhigh oldmirr ss1 oldsnap)
(setq oldmirr (getvar "Mirrtext"))
(setq oldhigh (getvar "Highlight"))
(setq oldsnap (getvar "Osmode"))
(setvar "Mirrtext" 1)
(setvar "Highlight" 0)
(setvar "Osmode" 0)
(setq ss1 (ssget "X"))
(command "MIRROR" ss1 "" "0,0" "0,1" "y")
(command "ZOOM" "E")
(setvar "Mirrtext" oldmirr)
(setvar "Highlight" oldhigh)
(setvar "Osmode" oldsnap)
(alert "\nYou are now looking at your drawing,
\n From inside your monitor!!")
(princ)
)
(princ)
;CODING ENDS HERE
Try this on an existing drawing.
--------------------------------
The Questions
--------------------------------
Hi, first time writer to this news letter.
I'm so used to using a software on Acad R14 called SoftEngine, by
Vibrant Graphics. It has since gone out of business. The main feature
of it is the ease of zooming in and out of a drawing. (It also has an
enlargement window that works as a magnifying glass when the cursor
passes over a certain area.)
To zoom, just press shift, pick button @ the mouse (left pick) and drag
a window over the area, hit pick again and it'll zoom into that area.
Zoom previous is done by just pressing the shift key and hit right
mouse button (return). It is easy to use. I'm on 2002 now, have to do
without that zoom feature, I've tried make up short keys, and
programmable mouse, but still, the SoftEngine is the best. Does
anyone knows a similar program for Acad 2002?
Matthew
-------------------------
In Spain Release 14 of Autocad is still the standard, and most of us
who customize it employ only Autolisp. Some of the Bonus routines in
R14 are ARX files, which I learnt to use, but not to write, but now, with
Autocad 2002, I see almost exclusively VLX files, supposedly VBA
routines. Is that correct? What is the difference between ARX and VLX
files?
Rogelio Bravo
-------------------------
DVB files are applications developed using Visual Basic for
Applications.
ARX files are compiled C++ applications.
VLX files are compiled Visual Lisp or AutoLisp applications. They will
only run in AutoCAD R14 if you have the Visual Lisp Extensions
loaded.
-------------------------
Kenny,
Do you know of a batch purge program that will work with acadlt 2002?
Don Hoeger
-------------------------
The Answers
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (4 of 9) [23/03/2005 05:49:55 p.m.]
--------------------------
Hi Kenny,
You do an amazing job with your newsletter. It's first rate. Especially,
considering you don't have a Llama to help you. Just to prove that I'm
not completely ignorant about LISP (99% ignorant is Not complete) I
am including a little bit of code that turns snaps on and off. This only
works in R 2000 and later. I know that this can be done by saving the
current setting and restoring it but this bit has a twist. It works just like
clicking the OSNAP button in the status bar.
; Start Code
(defun SNAPTOGGLE (SNAPSTATE) ;Pass the snap state desired 1=On
0=Off
(setq snap (getvar "osmode"))
;(princ snap)
(if (= 1 SNAPSTATE) ;Turn it on
;(princ "Turn it on")
(if (> 16383 snap) ;button is pushed
() ;Leave it pushed else -
(setq snap (- snap 16384)) ;push button
)
;Turn it off
;(princ "Turn it off")
(if (> 16383 snap) ;button is pushed
(setq snap (+ snap 16384)) ;UNpush the button else -
() ;Leave it unpushed
)
)
(setvar "osmode" snap)
(princ)
)
(defun C:SnapOn ()
(SNAPTOGGLE 1)
)
(defun C:SnapOff ()
(SNAPTOGGLE 0)
)
; End Code
Mark
---------------
Are you looking for a Japanese Visual Lisp site?
http://www1.harenet.ne.jp/~hanafusa/visual/#for
--------------------------
And here's some Free Stuff :
http://www.turvill.com/t2/Free_Stuff/Index.htm
--------------------------
I have written a routine in VBA that will insert multiple xrefs or blocks
and allow you to select the
insertion point as well as select if an xref is an overlay or attached.
Robert Endres
Roberts coding is a wee bit big to post in this Newsletter,
but you can download the application from here :
http://www.afralisp.com/zip1/mi.zip ( 37Kb )
---------------------------
And, something from Russell Johnston
; EXTREME.lsp
; Finds the extreme upper right corner of a selection set of LINES only
; Written By : R. Johnston
; Date : Feb 18/02
;--------------------------------------------------------------------------
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (5 of 9) [23/03/2005 05:49:55 p.m.]
(prompt "\nType EXTR to run")
(print)
; Error Function
(defun *error* (msg)
(print msg)
(command ".undo" "back")
(setq *error* OLDERROR)
(setvar "cmdecho" OLDCMDECHO)
(setvar "cmddia" OLDCMDDIA)
(setvar "filedia" OLDFILEDIA)
)
; Start Main Function
(defun c:EXTR (/ N)
; Store original system variables
(setq OLDERROR *error*)
(setq OLDCMDECHO (getvar "cmdecho"))
(setq OLDCMDDIA (getvar "cmddia"))
(setq OLDFILEDIA (getvar "filedia"))
(setq OLDOSMODE (getvar "osmode"))
; Set system varibales to 0
(setvar "cmdecho" 1)
(setvar "cmddia" 0)
(setvar "filedia" 0)
(setvar "osmode" 0)
; Main Program
(command ".undo" "mark") ;set point to undo to if an error occurs
(setq SS (ssget))
(setq SSLENG (sslength SS))
(setq TEXT1 (strcat "Number of Entities = " (itoa SSLENG)))
(princ TEXT1)
(setq N 0)
(setq XVALUES (list 0))
(setq YVALUES (list 0))
(repeat SSLENG
(setq EN (ssname SS N))
(setq EL (entget EN))
(setq XPT1 (list (car (cdr (assoc 10 EL)))))
(setq XPT2 (list (car (cdr (assoc 11 EL)))))
(setq YPT1 (list (cadr (cdr (assoc 10 EL)))))
(setq YPT2 (list (cadr (cdr (assoc 11 EL)))))
(setq XVALUES (append XVALUES XPT1 XPT2))
(setq YVALUES (append YVALUES YPT1 YPT2))
(setq N (+ N 1))
);End of repeat bracket
(print XVALUES)
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (6 of 9) [23/03/2005 05:49:55 p.m.]
(print YVALUES)
; Find Maximum X value
(setq MAXXPT 0)
(setq N1 0)
(repeat (length XVALUES)
(if (> (nth N1 XVALUES) MAXXPT) (setq MAXXPT (nth N1 XVALUES)) ())
(setq N1 (+ N1 1))
);End of repeat bracket
(print MAXXPT)
; Find Maximum Y value
(setq MAXYPT 0)
(setq N2 0)
(repeat (length YVALUES)
(if (> (nth N2 YVALUES) MAXYPT) (setq MAXYPT (nth N2 YVALUES)) ())
(setq N2 (+ N2 1))
);End of repeat bracket
(print MAXYPT)
; Create Upper Right Point
(setq MAXPT (list MAXXPT MAXYPT))
(command ".circle" MAXPT "1")
; Set system variables back to original values
(setvar "cmdecho" OLDCMDECHO)
(setvar "cmddia" OLDCMDDIA)
(setvar "filedia" OLDFILEDIA)
(setvar "osmode" OLDOSMODE)
(princ)
)
; End Main Function
--------------------------
Do you know that you can attach volumes of data to almost any object
that is stored with the drawing. No it's not XDATA!
Let's attach some LDATA to the Modelspace Object.
Note that we are not attaching the data to a line or a circle, but to
Modelspace!!!!
In this example, we'll attached four integer, three real numbers, two
strings,
and (a partridge in a dotted pair tree).
(Coding very kindly donated by Peter Jamtgaard)
----------------------------
;CODING STARTS HERE
(defun C:VL-PUT-LDATA (/ ACADOBJ CDWGOBJ MSPCOBJ)
(setq ACADOBJ (vlax-get-acad-object)
CDWGOBJ (vlax-get-property acadobj "activedocument")
MSPCOBJ (vlax-get-property CDWGOBJ "modelspace")
)
(vlax-ldata-put MSPCOBJ "test"
'( 1 2 3 4 1.0 2.0 3.0 "TEST" "TEST1" (0 . "INSERT"))
)
(vlax-release-object ACADOBJ)
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (7 of 9) [23/03/2005 05:49:55 p.m.]
(vlax-release-object CDWGOBJ)
(vlax-release-object MSPCOBJ)
(prin1)
)
(defun C:VL-GET-LDATA (/ ACADOBJ CDWGOBJ MSPCOBJ)
(setq ACADOBJ (vlax-get-acad-object)
CDWGOBJ (vlax-get-property acadobj "activedocument")
MSPCOBJ (vlax-get-property CDWGOBJ "modelspace")
)
(print (vlax-ldata-get MSPCOBJ "test"))
(vlax-release-object ACADOBJ)
(vlax-release-object CDWGOBJ)
(vlax-release-object MSPCOBJ)
(prin1)
)
;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
I received this letter from a young lady earlier in the week :
Dear Kenny,
Last year I upgraded from Boyfriend 5.0 to Husband 1.0 and noticed a
slowdown in the performance of flower and jewelry applications that
had operated flawlessly under Boyfriend 5.0.
In addition, Husband 1.0 uninstalled many other valuable programs,
such as Romance 9.9, but installed undesirable programs such as NFL
5.0 and NBA 3.0. Conversation 8.0 no longer runs and Housecleaning
2.6 simply crashes the system. I've tried running Nagging 5.3 to fix the
problems, but to no avail.
What can I do?
Desperate
Dear Desperate,
First keep in mind, Boyfriend 5.0 is an entertainment package, while
Husband 1.0 is an operating system. Try to enter the command: C:/I
THOUGHT YOU LOVED ME and install Tears 6.2.
Husband 1.0 should then automatically run the applications: Guilty 3.0
and Flowers 7.0.
But remember overuse can cause Husband 1.0 to default to Grumpy
Silence 2.5, Happy Hour 7.0, or Beer 6.1. Beer 6.1 is a very bad program
that will create Snoring Loudly WAV files.
DO NOT install Mother-In-Law or reinstall another Boyfriend program.
These are not supported applications and will crash Husband 1.0.
In summary, Husband 1.0 is a great program, but it does have a limited
memory and cannot learn new applications quickly. You might
consider buying additional software to improve performance. I
personally recommend hot food 3.0 and Lingerie 6.9.
Good Luck,
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
The more you drink,
The better we sound.
http://www.BedrockBand.com
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (8 of 9) [23/03/2005 05:49:55 p.m.]
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-10
http://www.afralisp.com/newsletter/2002/2002-10.htm (9 of 9) [23/03/2005 05:49:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, March 15, 2002 21:22
--------------------------------------------------
AfraLisp Newsletter No 2002-11
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
<PHOTO OF INVISIBLE>
<MAN GOES HERE>
--------------------------------------------------
BedRock - The Band in the Sand
http://www.BedrockBand.com
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Did you notice that AfraLisp was off line last Saturday? I believe our
server experienced an e-mail attack!! I'm afraid to tell Frank, but I'll
whisper to you, that I think it could have been all my fan mail that
caused the e-mail overload. Shush. Don't say anything 'cos I might get
into trouble.
Anyway, I apologise for the problem and will keep fingers crossed that
it doesn't happen again.
There are some nasty people out there!!!
Oh, by the way. Randall Rath - http://www.vbdesign.net - has not been
well. On behalf of AfraLisp, I'd like to wish him all the best and hope he
has a speedy recovery.
--------------------------------
Quote of the week
--------------------------------
"You cannot make a centipede from gluing ants together".
--------------------------------
The Site
--------------------------------
Ha, ha. I've finally got around to doing some work!!!
This week I've posted three, yes three, new Tutorials, all in the Visual
Lisp section.
'Cos I've been getting so many queries regarding Layers, I've posted a
complete section regarding Visual Lisp and Layers :
http://www.afralisp.com/vl/layers.htm and I decided to have a closer
look at Visual Lisp and Profiles :
http://www.afralisp.com/vl/profiles.htm
As well as that, I've also had a look at Visual Lisp and Attributes :
http://www.afralisp.com/vl/attab-vl.htm
So pop along and have a wee read. There's also a couple of nice
routines that you should find interesting. For example :
Here's a little application that you may find interesting. It will check the
Login Name of the user and automatically load the relevant Profile for
that user.
Firstly you need to name your Profiles the same as your Login Name.
e.g. if your Login Name is NDBE51D1, your Profile must be named
NDBE51D1.ARG. Then you need to store all your user Profiles in the
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (1 of 7) [23/03/2005 05:49:56 p.m.]
same folder. (This example uses "c:/profiles/").
Irrespective of which user logs in, the specific Profile for that user will
be loaded if necessary, and made Active.
Not much in the way of error checking at the moment I'm afraid.....
;CODING STARTS HERE
(prompt "\nType LoginProfile to run......")
(vl-load-com)
(defun C:LoginProfile (/ profilename acadprofiles actprofile
thelist profilepath)
;retrieve the users login name
(setq profilename (strcase (getvar "LOGINNAME")))
;retrieve a reference to the Profiles
(setq acadprofiles (vla-get-profiles
(vla-get-preferences (vlax-get-Acad-Object))))
;retrieve the Active Profile
(setq actprofile (strcase (vla-get-ActiveProfile acadprofiles)))
;if they are not the same
(if (/= profilename actprofile)
;do the following
(progn
;get a list of the loaded profiles
(vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
;convert to a list
(setq thelist (vlax-safearray->list thelist))
;if the profile is not in the list
(if (not (member profilename thelist))
;do the following
(progn
;store the profile file
(setq profilepath
(strcat "c:/profiles/" profilename ".arg"))
;if the profile is found
(if (findfile profilepath)
;do the following
(progn
;load the profile
(setq NewProfile (vlax-invoke-method
acadprofiles 'ImportProfile
profilename profilepath :vlax-true))
;make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);progn
;profile file cannot be found - exit
(prompt (strcat "\nCannot find profile " profilepath))
);if
);progn
;it is loaded but make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);if
);progn
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (2 of 7) [23/03/2005 05:49:56 p.m.]
;We could reload the Profile if we wish.
;Just uncomment the next line.
;(vlax-invoke-method acadProfiles 'ResetProfile profilename)
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
--------------------------------
The Questions
--------------------------------
Back in R14 the attached error handler would bonk out and then spew
the code in the buffer to the command line so you could see where it
failed. I can't seem to get it to happen in 2000 or in 2000i. Do you know
if it is a variable setting?
(defun c:en ()
(if (= *error* nil)
(defun *error* (msg) (command)
(princ (strcat "\nbonk1: " msg)) (princ)
)
(setq *error* nil)
)
)
(c:en)
(c:en)
(princ)
To toggle it on/off just type "en" at the command prompt...
Bill Hashman
-------------------------
Prior to AutoCAD 2000, AutoLisp would dump a bug trace to the
command line when an error was encountered. While developers went
out of their way to suppress this behaviour in a released product, it
was a handy tool during the debugging cycle. To get the same
behaviour in AutoCAD 2000, replace the standard error handler with
this one :
;CODING STARTS HERE
(vl-load-com)
(defun errdump (s)
(vl-bt)
(princ)
)
;CODING ENDS HERE
---------------------------
Any ideas on how I could toggle the screen color in paperspace
(Acad2000) from white-black and black-white?
Kevin
-----------------------
This will get you started :
;CODING STARTS HERE
(vl-load-com)
(setq acaddisplay (vla-get-display (vla-get-preferences
(vlax-get-Acad-Object))))
(vla-put-GraphicsWinLayoutBackgrndColor acaddisplay 0)
;CODING ENDS HERE
This will change the Paper Space background color to black.
And, to change it back to white :
(vla-put-GraphicsWinLayoutBackgrndColor acaddisplay 16777215)
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (3 of 7) [23/03/2005 05:49:56 p.m.]
Check out the VBA Help on "GraphicsWinLayoutBackgrndColor".
For Model Space, check out "GraphicsWinModelBackgrndColor".
--------------------------
I downloaded you Attab VBA application and modified it for use with
my title block. My title block has 24 attributes, so I added the
appropriate number of lines to the "textbox" areas and got it to work.
However, in doing so I initially added 26 lines to see what would
happen and it errored out. I was thinking of trying to use this routine
instead of the ddatte routine (since Autodesk had to screw it up and
not allow customizing it). The problem is, I won't always know how
many attributes will be in a given block, and I wouldn't want to have to
create new code for every block where I do know how many attributes I
have. Is there a way to have it adjust itself according to how many
attributes there are? Also, is there a way for the label on the dialog box
to show the prompt for the attribute?
Thank you for your help!
Stacy DeGroot
--------------------------
If anybody knows the answer to this one, PLEASE let me know as
well!!!
--------------------------
Kenny
Thanks for your letter. Is there any way we can change the paper size
for plot to custom paper size through Auto/Visual lisp or VBA?
R.V Rajeev
--------------------------
R.V. - You don't mind if I call you RV do you?
I'll be looking at plotting in the next week or so.
Watch This Space........
--------------------------
Kenny,
Hi! What i need is a list of all xref in a drawing included in your date &
time stamp when inserted in a drawing it is automatically write all the
xref's that a drawing are using.
Thanks again for your time to my email.
earv
----------------------------
I can certainly provide you with a list of Xrefs in your drawing :
;CODING STARTS HERE
(defun c:getxref ()
(vl-load-com)
;retrieve a reference to the Active Document
(setq activedocument (vla-get-activedocument (vlax-get-Acad-Object)))
;retrieve a reference to the blocks
(setq theblocks (vla-get-blocks activedocument))
;create an empty list
(setq theList '())
;process each block
(vlax-for item theblocks
;check if it's an Xref
(setq yesxref (vlax-get-property item 'isXref))
;if it is
(if (= yesxref :vlax-true)
;do the following
(progn
;get the Xref name
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (4 of 7) [23/03/2005 05:49:56 p.m.]
(setq ablock (vlax-get-property item 'Name))
;store it in the list
(setq theList (append (list ablock) theList))
);progn
);if
);vlax-for
;print the list
(princ theList)
(princ)
);defun
(princ)
;CODING ENDS HERE
--------------------------
The Answers
--------------------------
Lst week we had a query regarding this :
"I'm so used to using a software on Acad R14 called SoftEngine, by
Vibrant Graphics. It has since gone out of business. The main feature
of it is the ease of zooming in and out of a drawing".
And, I received this in response :
Hi Kenny
You could create some simple little Lisp macro's to do the job. Place
the following in your Acad.lsp or Acaddoc.lsp file.
(defun c:za () (command "._ZOOM" "ALL"))
(defun c:ze () (command "._ZOOM" "EXTENTS"))
(defun c:zp () (command "._ZOOM" "PREVIOUS"))
(defun c:zw () (command "._ZOOM" "WINDOW"))
(defun c:z5 () (command "._ZOOM" "0.5x"))
(defun c:z9 () (command "._ZOOM" "0.95x"))
With 2002 (using a wheel mouse) and the system variable
MBUTTONPAN set to 1,
Zooming and Panning I personally think could not be much easier.
System variable ZOOMFACTOR controls Zoom incremental
increase/decrease for each turn of mouse-wheel.
Press & Hold Middle Button (works even if you don't have a wheel
mouse) - Real Time Panning
Hold Down Shift or Ctrl Key while rolling mouse-wheel - Real Time
Zooming, position of cross-hairs control the centre/focal point of the
Zoom In (Moving Wheel Forward) / Out (Moving Wheel Back).
Double Click Middle Button - Zoom Extents.
Also you have the DSVIEWER command to help your Zooming of Large
Scale Models. Or am I missing the point totally here....
Have a good one, Mike
-----------------------------------
Would you like a quick flash?
Save this as "Flash.lsp" and then load it into AutoCAD.
For good results you need to open a "busy" drawing.
Syntax : (flash "Layer Name")
Example : Type (flash "7") at the command line.
;CODING STARTS HERE
(defun flash (layname)
(cond ((setq lyr (tblobjname "LAYER" layname))
(setq lyr (entget lyr)
a (cdr (assoc 62 lyr))
b a
)
(while (/= (car (grread 2)) 2)
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (5 of 7) [23/03/2005 05:49:56 p.m.]
(entmod (subst (cons 62 (setq a (* -1 a))) (assoc 62 lyr) lyr))
)
(entmod (subst (cons 62 b) (assoc 62 lyr) lyr))
)
)
(princ)
)
;CODING ENDS HERE
Thanks and applause go to Stig Madsen.
---------------------------
The Back Stoep
---------------------------
Why the Railroad Gauge?
The US Standard Railroad Gauge (distance between the rails) is 4 feet,
8.5 inches. That's an exceedingly odd number. Why was that gauge
used? Because that's the way they built them in England, and the US
railroads were built by English expatriates.
Why did the English people build them like that? Because the first rail
lines were built by the same people who built the pre-railroad
tramways, and that's the gauge they used.
Why did they use that gauge, then? Because the people who built the
tramways used the same jigs and tools that they used for building
wagons, which used that wheel spacing.
Okay! Why did the wagons use that odd wheel spacing? Well, if they
tried to use any other spacing, the wagons would break on some of the
old, long distance roads, because that's the spacing of the old wheel
ruts.
So who built these old rutted roads? The first long distance roads in
Europe were built by Imperial Rome for the benefit of their legions. The
roads have been used ever since.
And the ruts? The initial ruts, which everyone else had to match for
fear of destroying their wagons, were first made by Roman war
chariots. Since the chariots were made for or by Imperial Rome, they
were all alike in the matter of wheel spacing.
Thus, we have the answer to the original questions. The United States
Standard Railroad Gauge of 4 feet, 8.5 inches derives from the original
specification for an Imperial Roman army war chariot. Specs and
bureaucracies live forever.
So, the next time you are handed a specification and wonder what
horse's ass came up with it, you may be exactly right. Because the
Imperial Roman chariots were made to be just wide enough to
accommodate the back-ends of two war horses.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
A Rock 'n Old Band.
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------

AfraLisp Newsletter No 2002-11


http://www.afralisp.com/newsletter/2002/2002-11.htm (6 of 7) [23/03/2005 05:49:56 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-11
http://www.afralisp.com/newsletter/2002/2002-11.htm (7 of 7) [23/03/2005 05:49:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, March 22, 2002 18:22
--------------------------------------------------
AfraLisp Newsletter No 2002-12
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
***Please delete this line as it is not required.***
--------------------------------------------------
Why not join a pleasant and civilised conversation pertaining to AutoLisp :
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
Look for the "Lost in Stupid Parenthetheeth " Board.
This forum is also great in regards to VBA.
--------------------------
The Front Stoep
--------------------------
Hi Everyone. Hope you're all fine and looking forward to a pleasant Easter
weekend. I just thought I'd give you a little bit of advance warning in that I'll be
going off on my holidays in just over a weeks time. This means that after next
weeks Newsletter, there will be no Newsletters for about 2 weeks.
More about that next week.
I'm not feeling all that great at the moment 'cos the bleedin Aussies have just
beaten us (South Africa) again at cricket. Ha, just wait, there are plenty of
matches left and revenge is sweet!!
(Australia - This is the land where men are men and the sheep are very
nervous!!!)
--------------------------------
Quote of the week
--------------------------------
Friends help you move.
Real friends help you move bodies.
--------------------------------
The Site
--------------------------------
I've had so many queries in regards to loading VBA files that I thought it was time
to have a close look at the subject. You can find what I've almost decided is
maybe, probably, could be the best way of achieving the aforemention task at :
http://www.afralisp.com/vl/vl-vba.htm
How does a Library of AutoLisp functions sound?
Not AutoLisp programs, functions/sub-routines.
You input and desirability in regards to this matter would be appreciated.
(In other words, let me know what you think).
--------------------------------
The Questions
--------------------------------
I apologize for insisting (I must be a bit slow, but VBA really overwhelm me), but
after years of loading, lisp routines in MNU files with the faithful
^C^C(if (not cl) (load "cl"));cl , ,
and using the same method, but with ARXLOAD, with ARX files, I am not yet sure
how to load DVB
files in MNU files (I owe to you to know that these files are VBA applications);
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (1 of 10) [23/03/2005 05:49:58 p.m.]
Must I use APPLOAD? Summing up: How to load example.dvb from a menu file?
Would (appload "example") do it?
Rogelio Bravo
-----------------------
Rogelio, the answer to your problem can be found in "The Site" section.
While we're on the subject, would you like to how to load and run a DVB
application from another DVB application? Here we go :
'CODING STARTS HERE
Sub Afra_LoadDVB()
Dim FileName As String
FileName = "d:\drawings\DVBFile.dvb"
LoadDVB FileName
RunMacro "DVBFile.dvb!Module1.Amacro"
UnloadDVB FileName
End Sub
'CODING ENDS HERE
-----------------------
Do you know how to load a routine and to automatically have it run when
Acad2000 starts (without any user input) ??
thanks,
Kevin
--------------------------
OK here's one method. Copy and paste this coding into Notepad and save it as
"Testing.lsp".
This will be our routine that we want to run.
;CODING STARTS HERE
(defun testing ()
(alert "Testing, Testing 123")
(princ)
)
(princ)
;CODING ENDS HERE
-----------------------------------
Now add the following to your Acad.lsp file or Acaddoc.lsp file :
;CODING STARTS HERE
(load "Testing" "\nTesting.Lsp not found.")
;-----------------------------------------------
(defun-q TESTINGSTARTUP ()
(testing)
);defun-q
(setq S::STARTUP (append S::STARTUP TESTINGSTARTUP))
;CODING ENDS HERE
--------------------------
The Answers
--------------------------
Kenny,
Your code for changing the screen colors works well, but it doesn't change the
crosshair colors. This results in crosshairs the same color as the background :-)
This is what I ended up with:
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (2 of 10) [23/03/2005 05:49:58 p.m.]
Thanks for the huge jump-start!!!
Mike Weaver
;CODING STARTS HERE
(vl-load-com)
;Toggle Paper Space
(defun c:pswhite()(screencolors nil 16777215 0)(princ))
(defun c:psblack()(screencolors nil 0 16777215)(princ))
(defun c:psgray()(screencolors nil 5592405 5592575)(princ))
;Toggle Model Space
(defun c:mswhite()(screencolors T 16777215 0))
(defun c:msblack()(screencolors T 0 16777215))
(defun c:msgray()(screencolors T 5592405 5592575))
;;; mspace nil - use paper space
;;; mspace T - use model space
(defun screencolors(mspace bkgrnd crshrs)
(setq acaddisplay (vla-get-display (vla-get-preferences (vlax-get-Acad-Object))))
(if (null mspace)
(progn
(vla-put-GraphicsWinLayoutBackgrndColor acaddisplay bkgrnd)
(vla-put-LayoutCrosshairColor acaddisplay crshrs)
);progn
(progn
(vla-put-GraphicsWinModelBackgrndColor acaddisplay bkgrnd)
(vla-put-ModelCrosshairColor acaddisplay crshrs)
);progn
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
---------------------------
Recently the guys here at work wanted me to write a routine that would toggle
the display to work in a WYSIWYG (What You See Is What You Get) mode. I did
do it with VBA because I didn't think there was a way to do it using Lisp. Am I
correct? Could Visual Lisp have done it?
Here is my VBA code:
'CODING STARTS HERE
Sub wysiwyg()
'Toggle Mspace Pspace
If Not (ThisDrawing.ActiveSpace = acPaperSpace) Then
ThisDrawing.ActiveSpace = acPaperSpace
ThisDrawing.SetVariable "dimscale", 1
ThisDrawing.SetVariable "ltscale", ThisDrawing.GetVariable("dimscale") * 0.5
End If
' Toggle Layout Crosshair Color
If Not (ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor =
vbBlack) Then
ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor = vbBlack
Else
ThisDrawing.Application.Preferences.Display.LayoutCrosshairColor = vbWhite
End If
' Toggle Layout Background Color
If Not
(ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor
= vbWhite) Then
ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor
= vbWhite
Else
ThisDrawing.Application.Preferences.Display.GraphicsWinLayoutBackgrndColor
= vbBlack
End If
' Toggle Show Plot Styles
If Not (ThisDrawing.ActiveLayout.ShowPlotStyles = True) Then
ThisDrawing.ActiveLayout.ShowPlotStyles = True
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (3 of 10) [23/03/2005 05:49:58 p.m.]
Else
ThisDrawing.ActiveLayout.ShowPlotStyles = False
End If
' Toggle Lweight Display
If ThisDrawing.GetVariable("LWDISPLAY") = "0" Then
ThisDrawing.SetVariable "lwdisplay", 1
Else
ThisDrawing.SetVariable "lwdisplay", 0
End If
'Lock viewports
Dim Ent As AcadEntity, pVP As AcadPViewport
For Each Ent In ThisDrawing.PaperSpace
Debug.Print Ent.ObjectName
If Ent.ObjectName = "AcDbViewport" Then
Set pVP = Ent
Debug.Print pVP.DisplayLocked
If Not pVP.DisplayLocked Then pVP.DisplayLocked = True
End If
Next Ent
' Regen The Drawing
ThisDrawing.Regen acAllViewports
End Sub
'CODING ENDS HERE
Thanks,
James
-----------------
Kenny
Further to earv's question last week about XREF stamping of drawings, I
offer the following code that I have been using.
This code has been cut down from a program I wrote in 1998 which stamped
the drawing with the user name, time and date, file name and AutoCAD
version.
Being a cut down program, the code is a bit clumsy and probably contains
elements that are not really required - But it works for me!
The program is manual in that you have to remember to type in 'stampx' to
stamp the drawing with all the XREFs. All you have to do next is point to
the top left hand corner of the drawing frame. (The program looks for the
end of the line.)
Users may like to customise the xloc and ftl to suit their own drawing
frame. Also the font iso3098b could be changed to the user preferred font.
Users should note the warning on the bottom of the program. Because the
drawing places text on the stamps layer, this layer is erased when the
program is run - Actually, only text with the style 'stamps' on the
'stamps' layer is erased, so the program is reasonably safe.
I am sure there are better ways of doing this (eg with attributes etc), but
I have been using this method for years with no problems.
BY THE WAY - I would be interested in knowing if there is a similar way of
stamping a drawing with IMAGE files attached to the drawing! I can't see
how to do it.
Regards
Craig Green
;CODEING START HERE
; stampx.lsp - Stamps drawing with xrefs list.
; C Green 10/12/2001
;
; LAYER USAGE:
; STAMPX Used for xref stamping of drawings
;
(defun c:stampx()
;
(command "zoom" "E")
(setq tl (osnap (getpoint "\nPoint to Top Left of drawing frame...")
"end"))
(setq ds (getreal "\nDrawing scale? <1>: "))
(if (= ds nil) (setq ds 1.0))
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (4 of 10) [23/03/2005 05:49:58 p.m.]
(setq txts (* 2.0 ds))
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
;
; Standard sheet default locations:
; Stamp locations
(setq xloc (list 25.2 574.49 0.0)) ; Xref list location
(setq ftl (list 24.5 579.0 0.0)) ; Top left of drawing frame
; Polar vectors for stamps
(setq xdist (distance ftl xloc))
(setq xang (angle ftl xloc))
;
(setq scmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq layer (getvar "clayer"))
(setq tstyle (getvar "textstyle"))
(setq tsize (getvar "textsize"))
(setq cecol (getvar "cecolor"))
(setq celt (getvar "celtype"))
(command "regenmode" "0")
(command "color" "7")
(setq prec (getvar "LUPREC"))
(setvar "LUPREC" 4)
(command "linetype" "set" "continuous" "")
(command "style" "stamps" "iso3098b" txts "1" "0" "n" "n" "n")
;
; Make the STAMPS layer and clear it
(command "LAYER" "MAKE" "STAMPS" "COLOR" "WHITE" "" "")
(setq r (getstring "Erase the stamp layer? <y>: "))
(setq r (strcase r))
(if (/= r "N")
(progn
(command "ERASE" (ssget "X" (list (cons 8 "STAMPS") (cons 0 "TEXT")
(cons 7 "STAMPS") )) "")
)
)
;
; Stamp the sheet with xrefs
;
(setq pt1 (polar tl xang (* xdist ds)))
(command "text" "style" "stamps" "j" "tl" pt1 "0" "%%uXREF LIST:")
(setq entl (tblnext "block" t))
(while (/= entl nil)
(setq xref (assoc 1 entl))
(if (/= xref nil)
(progn
(setq xref (cdr xref))
(command "text" "" xref)
)
)
(setq entl (tblnext "block"))
)
; Terminate the program
(command "zoom" "P")
(setvar "LUPREC" prec)
(if (= layer "STAMPS") (setq layer "0"))
(command "layer" "s" layer "")
(command "color" cecol)
(command "style" tstyle "iso3098b" tsize "1" "0" "n" "n" "n")
; RESET FONT & TWF etc?
(command "regenmode" "1")
(setvar "cmdecho" scmde)
(setvar "osmode" osm)
(prompt "\nW A R N I N G: Do not draw on the layer 'STAMPS'!")
(prin1)
)
;CODEING ENDS HERE
---------------------------
A reader wrote.
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (5 of 10) [23/03/2005 05:49:58 p.m.]
I downloaded you Attab VBA application and modified it for use with my title
block. My title block has 24 attributes, so I added the appropriate number of lines
to the "textbox" areas and got it to work. However, in doing so I initially added 26
lines to see what would happen and it errored out. I was
thinking of trying to use this routine instead of the ddatte routine (since Autodesk
had to screw it up and not allow customizing it). The problem is, I won't always
know how many attributes will be in a given block, and I wouldn't want to have to
create new code for every block where I do know how
many attributes I have. Is there a way to have it adjust itself according to how
many attributes there are? Also, is there a way for the label on the dialog box to
show the prompt for the attribute?
------------
And, Robert Endres wrote back :
The above is possible !
NOTE the following code CANNOT be written into the code of the form if the form
is the first thing loaded by issuing the command to run this routine.
It needs to be written into a "module" that is called before the form with your
attribute info is displayed.
In a MODULE that is loaded by the "start my command" button create a
GET_ATTRIBUTE_INFO routine to read through your blocks and extract the
attribute prompt and the attribute value and then set a variable equal to the
number of attributes on your FORM you need to create enough LABELS and
TEXT BOXES up to the maximum you might ever need. It may make sense to
number them by their index.....
LABEL1 >>>>>> TEXTBOX1
LABEL2 >>>>>> TEXTBOX2 etc.....
Then before issuing the MY_ATTRIBUTE_FORM.SHOW run the
GET_ATTRIBUTE_INFO routine and
set the PROPERTIES of the LABEL# and TEXTBOX# to visible up to the number
of ATTRIBUTES in the block.
example:
MY_TITLEBLOCK has 12 attributes
MY_ATTRIBUTE_FORM has 40 LABELS and TEXTBOXES numbered 1-40
in my MODULE code I enable LABELS and TEXTBOXES through 12
LABEL1.visible = TRUE up to LABEL12.visible = TRUE
TEXTBOX1.visible = TRUE up to TEXTBOX12.visible = TRUE
the text for the LABEL can be extracted from the GET_ATTRIBUTE_INFO routine
and
activated by LABEL#.TEXT = ATTRIBUTE_PROMPT
the text for the associated TEXTBOX can also be extracted from the
GET_ATTRIBUTE_INFO routine and activated by TEXTBOX #.TEXT =
ATTRIBUTE_DATA
if the user wants to he can resize the MY_ATTRIBUTE_FORM based upon the
number of ATTRIBUTES and how the layout of the form was created.
Robert Endres
---------------------------
And, to my shame, I contribute this :
From ACAD Newsletter Dated October 27th 1999. (http://www.vbdesign.net)
(And believe it or not, it was "me" that asked Randall the question!!!)
Q. How's about project that would display a set of AutoCad slides, similar to the
image dialogue that AutoCAD uses. The difference being, that the application
would allow the user to select a library directory (where the slides and blocks are
kept) and would create the image dialogue "on the fly". This way, the image
dialogue would not have to be hardcoded as it is in the AutoCAD menu. Thinking
about it, maybe we should use WMF files instead of slides
A. Of course we could use the slide ocx to display a complete library of slides,
but it is a shareware tool. So Kenny went with using Window Metafiles for the
images. The problem is, VBA does not allow for a dynamic array of controls (in
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (6 of 10) [23/03/2005 05:49:58 p.m.]
VB 5 and up this can be done), so we could create the image controls one at a
time (see my dynamic control code from this month), but this becomes very
complex if you have more than say, 10 images in a directory. You need to expand
the form to fit all of the images, or provide a button to switch to the next set of
images...too much trouble when we can just use StdPictures. What is an
stdPicture? A picture held in memory! We can even make these a dynamic array!
Well, that solves half of our problem, but how do we get enough image controls
onto the form to display all of the pictures in any given directory? the answer is,
we don't! Time to use a Tab Strip! This is the first part of this project, the second
half will depend on what Kenny (and the YOU) want to do with it, should we set it
so that the user can click an image and have the block inserted? Perhaps allow
multiple selections so that many blocks can be inserted as many times as
needed? INPUT please!!!
One last note, Take a look at what Ralph worked up prior to building the project!!
For the form:
1 tab strip named tabImages
9 image controls (all with default names) placed in the client area of the tab strip
1 command button (default name)
1 text box (default name)
'Begin code Block
Option Explicit
Option Base 1
Private stdImages() As StdPicture
Private colFiles As Collection
Private Sub CommandButton1_Click()
If TextBox1.Text > "" Then
If Dir(TextBox1.Text) > "" Then
tabImages.Enabled = True
LoadImages TextBox1.Text
CommandButton1.Enabled = False
Else
MsgBox "The path provided was not valid", vbOKCancel, "Llama Central"
End If
Else
MsgBox "You must provide a valid path", vbOKCancel, "Llama Central"
End If
End Sub
Private Sub tabImages_Change()
Dim ctlcontrol As Control
For Each ctlcontrol In UserForm1.Controls
If TypeOf ctlcontrol Is Image Then
ctlcontrol.Picture = Nothing
End If
Next
SetImages
End Sub
Private Sub TextBox1_Change()
CommandButton1.Enabled = True
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub LoadImages(strPath As String)
Dim strFile As String
Dim intCnt As Integer
Static intTab As Integer
Set colFiles = New Collection
If Right(strPath, 1) <> "\" Then strPath = strPath & "\"
strFile = Dir(strPath & "\*.wmf")
Do While strFile > ""
colFiles.Add strFile
strFile = Dir
Loop
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (7 of 10) [23/03/2005 05:49:58 p.m.]
intCnt = colFiles.Count
ReDim stdImages(intCnt)
For intCnt = LBound(stdImages) To UBound(stdImages)
Set stdImages(intCnt) = LoadPicture(strPath & colFiles(intCnt))
If intCnt > 8 Then
If intCnt Mod 9 = 1 Then
tabImages.Tabs.Add "Tab" & intTab, intCnt & " - " & intCnt + 9
intTab = intTab + 1
End If
End If
Next
SetImages
End Sub
Private Sub SetImages()
Dim intIcnt As Integer
Dim intTabNum As Integer
intTabNum = tabImages.SelectedItem.Index * 9
intIcnt = 1 + intTabNum
Image1.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image2.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image3.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image4.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image5.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image6.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image7.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image8.Picture = stdImages(intIcnt)
If intIcnt = UBound(stdImages) Then Exit Sub
intIcnt = intIcnt + 1
Image9.Picture = stdImages(intIcnt)
intIcnt = intIcnt + 1
End Sub
Private Sub UserForm_Initialize()
tabImages.Tabs.Item(0).Caption = "1 - 9"
tabImages.Tabs.Remove (1)
tabImages.Enabled = False
CommandButton1.Caption = "Load Images"
End Sub
'End Code Block
---------------------------
The Back Stoep
---------------------------
Well, that's about it until next week. Hey, if you've got something humourous that
you would like me to include on the "Back Stoep", please feel free to send it to
me. The more the merrier!!!
And I leave you with this............
After Quasimodo's death, the bishop of the cathedral of Notre Dame sent word
through the streets of Paris that a new bellringer was needed. The bishop
decided that he would conduct the interviews personally and went up into the
belfry to begin the screening process.
After observing several applicants demonstrate their skills, he decided to call it a
day when a lone armless man approached him and announced that he was there
to apply for the bellringer's job. The bishop was incredulous.
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (8 of 10) [23/03/2005 05:49:58 p.m.]
"You have no arms!"
"No matter," said the man, "observe!"
He then began striking the bells with his face, producing a beautiful melody on
the carillon. The bishop listened in astonishment, convinced that he had finally
found a suitable replacement for Quasimodo.
Suddenly, rushing forward to strike a bell, the armless man tripped, and plunged
headlong out of the belfry window to his death in the street below. The stunned
bishop rushed to his side. When he reached the street, a crowd had gathered
around the fallen figure, drawn by the beautiful music they had heard only
moments before.
As they silently parted to let the bishop through, one of them asked, "Bishop,
who was this man?"
"I don't know his name," the bishop sadly replied, "but his face rings a bell."
The following day, despite the sadness that weighed heavily on his heart due to
the unfortunate death of the armless campanologist, the bishop continued his
interviews for the bellringer of Notre Dame. The first man to approach him said,
"Your excellency, I am the brother of the poor armless wretch that fell to his
death from this very belfry yesterday. I pray that you honor his life by allowing
me to replace him in this duty."
The bishop agrees to give the man an audition, and as the armless man's brother
stoops to pick up a mallet to strike the first bell, he groans, clutches at his chest
and dies on the spot. Two monks, hearing the bishop's cries of grief at this
second tragedy, rush up the stairs to his side.
"What has happened?", the first breathlessly asks, "Who is this man?"
"I don't know his name," sighs the distraught bishop, "but he's a dead ringer for
his brother."
Tara the noo, (Scots for "Goodbye for Now")
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
(Some People Will Listen to Anything)
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to AfraLisp go to the main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (9 of 10) [23/03/2005 05:49:58 p.m.]
Search
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-12
http://www.afralisp.com/newsletter/2002/2002-12.htm (10 of 10) [23/03/2005 05:49:58 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Monday, April 01, 2002 8:40
--------------------------------------------------
AfraLisp Newsletter No 2002-13
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
---------------------------------------------------
"BedRock - The Band in the Sand"
(Although sometimes the Sand gets in the Band)
http://www.BedrockBand.com
--------------------------
The Front Stoep
--------------------------
I know what I forgot to mention to you last week. I've finally received
our 2002 Upgrades. I ordered them at the beginning of January but,
well this is Africa!!!
Looks good so far although there are one or two or twenty changes to
my existing coding that I need to make. But, all in all, not too much
work to be done. I'll be pointing out the new programming features in
future Newsletters and just hope that those of you on lower releases
(especially those of you on R14 and below) don't get too frustrated.
As I mentioned briefly last week, I will be on leave for the next two
weeks. So, unfortunately, there will be no Newsletter whilst I'm away
enjoying myself. Please feel free to send emails as my son and
daughter will be here, but don't expect any sort of reply for about 2
weeks.
Where am I going? From here (Oranjemund, Namibia), drive to Cape
Town, South Africa - couple of days there drinking beer - on to
Plettenberg Bay - visit my wife's Mum and sister and do some fishing
and drink some beer - back to Cape Town for another couple of days
and drink some more beer, and then return to Namibia. I'm looking
forward to it, I need a break from drinking.
Anyway, I should be back on-line around about the 12th of April.
--------------------------------
Quote of the week
--------------------------------
Puritanism :
The haunting fear that someone, somewhere may be happy.
Liberalism :
The haunting fear that someone, somewhere may be happy, and rich.
--------------------------------
The Site
--------------------------------
I decided, that before I disappear on holiday, I'd leave you something to
ponder upon.
I had a bit of a wee look at "Visual Lisp - Directories and Files". Quite a
few powerful commands Visual Lisp has! Pop along and have a look. I
might even show you how to design your own Files Dialog without
having to resort to DosLib or VBA.
http://www.afralisp.com/vl/vl-dir.htm
I also published a Tutorial on "Compiling AutoLisp Files". So, if you're
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (1 of 7) [23/03/2005 05:50:00 p.m.]
confused over the difference between LSP, FAS and VLX files, and you
don't want the coding that you sweated for hours over "borrowed", pop
along here :
http://www.afralisp.com/vl/vl-comp.htm
Remember last week I mentioned adding a Library of AutoLisp
Functions to AfraLisp?
Well, I've decided to go ahead with this. If you look on the site, you'll
see a new addition to the menu bar entitled "Thingies". It's a dead link
at the moment as I'm still busy putting the Library together. So, if
you've got any AutoLisp Functions (Thingies) that you would like to
see added to the Library, please feel free to send them in.
And, just to wet your appetite, here's a couple of example "Thingies" :
;CODING STARTS HERE
;Extract from User Get Functions with Default Prompt
;AfraLisp Thingie Library
;http://www.afralisp.com
;March 2002
;--------------------
;Description : Integer Input Function with prompt
;Syntax : (LISP_getint prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - Integer
;Returns : val - Integer or Default Value
;Example : (Lisp_getinteger "Please enter Integer" 7)
(defun LISP_getint (prmpt val / x)
(princ (strcat "\n" prmpt " <" (itoa val) ">: "))
(setq x (getint))
(if x
(setq val x)
)
val
)
;-------------
;Description : Real Number Input Function with prompt
;Syntax : (LISP_getreal prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - Real Number
;Returns : val - Real Number or Default Value
;Example : (Lisp_getreal "Please input Number" 8.5)
(defun LISP_getreal (prmpt val / x)
(princ (strcat "\n" prmpt " <" (rtos val 2 (getvar "LUPREC")) ">: "))
(setq x (getreal))
(if x
(setq val x)
)
val
)
;---------------
;Description : String Input Function with prompt
;Syntax : (LISP_getstring prompt default_value)
;Arguments : prompt - User defined prompt - String
; default_value - Default Value - String
;Returns : val - String or Default Value
;Example : (Lisp_getstring " Please Enter Your Name" "Kenny")
(defun LISP_getstring (prmpt val / tstr)
(princ (strcat "\n" prmpt " <" val ">: "))
(setq tstr (getstring T))
(if (/= tstr "") tstr val)
)
;CODING ENDS HERE
--------------------------------
The Questions
--------------------------------
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (2 of 7) [23/03/2005 05:50:00 p.m.]
Jambo Kenny!
Do you have any routines (LISP or VBA) that will purge ALL of the
unused STYLES (Wall, Door, Slab, etc...) from a drawing?
Architectural Desktop has Wall Styles, Slab Styles, Door Styles,
Window Styles, etc...for drawing it's true 3D entities.
Thanks!
Garry in Florida, USA
--------------------------
I can't help Garry 'cos I don't have ADT.
Anyone willing to help?
--------------------------
Kenny,
I've been reading the Dummy book and learning a whole lot. Thanks for
the advice. Here's something I have noticed. There are differences
between Visual Basic 6.0 and VBA for AutoCAD. For instance there is
no "Load" for a UserForm in VBA. In VBA it is "Activate". Also, for a
listbox there is no "Item_Check" in VBA. What do you do in instances
like that?
James
---------------------
James,
The differences between VB and VBA are a big problem for all of us.
Just the other day, a friend of mine sent me a VBA application written
in AutoCAD 2002 VBA. It would not run on R2000 because the "Round"
function does not exist in R2000 VBA (which by the way, is VB5).
Before using any VB function, you need to check if it is available in
AutoCAD VBA. (You can check for it under the Object Browser).
Randall Raath has a great website dedicated to AutoCAD and VBA. He
has a lot of "work arounds" to the sort of thing you mentioned.
http://www.vbdesign.net
He also has a great forum where you can ask all these sort of
questions, and I'll guarantee that you'll get a nice friendly response.
Hey, I even have a Lisp section on it.
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
Sign up, you'll get a lot of good info and it costs you nothing.
I'll see you there........
--------------------------
I am writing various lisp routines to assist me in drawing up erf
diagrams for a housing project. (They are small and numerous because
the project is a rush job and there are constant changes - the client
cannot make up his mind what he wants, and because of the rush the
coding is very untidy.) the two questions are this :
1. I want to in my lisp be prompted to draw a closed polyline which is
usually rectangular but sometimes irregular. I get the lisp to do so but
when I type "C" to close the polyline the lisp routine ends with an error.
2. In this very same project we are looking at having about 400 layout
tabs. To find a specific layout can be quite cumbersome. Is there no
way of going directly to the tab you want. Each layout tab has been
named the same as the drawing number ie "PE 123".
Cheers
Dave
-------------------------
The polyline query is really quite simple. Just stick it in a while loop.
;CODING STARTS HERE
(defun c:pclose ( / pt1 pt2)
(setq pt1 (getpoint "\nFirst point: "))
(setq pt2 (getpoint pt1 "\nSecond point: "))
(command "PLINE" pt1 pt2)
(while (setq pt2 (getpoint "\nTo point: " pt2))
(command pt2)
);end while
(command "c")
(princ)
)
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (3 of 7) [23/03/2005 05:50:00 p.m.]
(princ)
;CODING ENDS HERE
Note: You don't enter "C" to end the Pline, you just press "Enter"
-------------------------
Dear Kenny
Please I am with problems to change a text style using
vlax-get-property and vlax-put
EX:
To change the Font of " TXT " for " ARIALBD.TTF "
To change height of the source of 2.5 for 12.5
Do you can me to help?
Tanks
Sebastio Velasquez
--------------------------
The Answers
--------------------------
On the theme of blocks and attributes.......
Here is a handy dandy little VBA routine that allows the user to select
blocks with attributes. You can select 1 block at a time or multiples and
then modify the following properties :
move the text
rotate the text.
of 1 or all of the attributes within the blocks.
This puppy ROCKS !!
The user can type in the text rotation or select it in the drawing using
points
the move command is always done selecting 2 points.
Robert Endres
-----------
Thanks Bob,
You can download this handy application here :
http://www.afralisp.com/vba.htm
P.S. What do you call a man with no arms and no legs swimming in the
ocean?
You guessed - Bob!
--------------------------
Looking for AutoLisp files?
Then pay a visit to the "Autolisp Download Center".
http://www.cybernation.nl/michiel/
Still under construction, but looking good....
---------------------------
Would like to have your very own AutoLisp Editor that runs
independently from AutoCAD? Have a look at this :
LispLink 15.02 is now available and now provides a powerful listing of
your functions and variable lists.
LispLink is an advanced text editor designed to use with All AutoCAD
customisation files. LispLink was designed specifically for AutoCAD
Release 2000, 2000i, and 2002 user files, but will work with ALL
releases of AutoCAD.
If you're serious about programming, you need this in your toolbox. I
don't endorse many products but this one definitely gets the thumbs
up.
http://www.caelink.com
Tell them that I sent you 'cos they promised me a keg of beer per
download.
(I can but wish!!!)
---------------------------
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (4 of 7) [23/03/2005 05:50:00 p.m.]
The Back Stoep
---------------------------
We've all read, or not bothered to, those funny leaflets that are
included in the box with any type of electronic appliance that you
purchase.
If I had my way, this is how they would be worded :
******READ THIS FIRST*******
Congratulations! You have purchased an extremely fine device that
would give you thousands of years of trouble-free service, except that
you undoubtedly will destroy it via some typical bonehead consumer
maneuver. Which is why we ask you to PLEASE FOR GOD'S SAKE
READ THIS OWNER'S MANUAL CAREFULLY BEFORE YOU UNPACK
THE DEVICE. YOU ALREADY UNPACKED IT, DIDN'T YOU? YOU
UNPACKED IT AND PLUGGED IT IN AND TURNED IT ON AND FIDDLED
WITH THE KNOBS, AND NOW YOUR CHILD, THE SAME CHILD WHO
ONCE SHOVED A POLISH SAUSAGE INTO YOUR VIDEOCASSETTE
RECORDER AND SET IT ON "FAST FORWARD", THIS CHILD ALSO IS
FIDDLING WITH THE KNOBS, RIGHT? WE MIGHT AS WELL JUST
BREAK THESE DEVICES RIGHT AT THE FACTORY BEFORE WE SHIP
THEM OUT, YOU KNOW THAT?
We're sorry. We just get a little crazy sometimes because we're always
getting back "defective" merchandise where it turns out that the
consumer inadvertently bathed the device in acid for six days. So, in
writing these instructions, we naturally tend to assume that your skull
is filled with
dead insects, but we mean nothing by it. OK? Now let's talk about :
1. UNPACKING THE DEVICE. The device is encased in foam to protect
it from the Shipping People, who like nothing more than to jab spears
into outgoing boxes.
PLEASE INSPECT THE CONTENTS CAREFULLY FOR GASHES OR MS
BARKER'S ENGAGEMENT RING, WHICH SHE LOST LAST WEEK, AND
SHE THINKS MAYBE IT WAS WHILE SHE WAS PACKING DEVICES. Ms
Barker really wants that ring back, because it is her only proof of
engagement, and her fiancee, Bob, is now seriously considering
backing out on the whole thing inasmuch as he had consumed most of
a bottle of vodka in Quality Control when he decided to pop the
question.
WARNING: DO NOT EVER AS LONG AS YOU LIVE THROW AWAY THE
BOX OR ANY OF THE PIECES OF STYROFOAM, EVEN THE LITTLE
ONES SHAPED LIKE PEANUTS.
If you attempt to return the device to the store, and you are missing
one single peanut, the store personnel will laugh in the chilling manner
exhibited by Joseph Stalin just after he enslaved Eastern Europe.
Besides the device, the box should contain :
* Eight little rectangular snippets of paper that say "WARNING"
* A little plastic packet containing four 5/17 inch pilfer grommets and
two club-ended 6/93 inch boxcar prawns.
YOU WILL NEED TO SUPPLY: a matrix wrench and 60,000 feet of tram.
IF ANYTHING IS DAMAGED OR MISSING: You IMMEDIATELY should
turn to your spouse and say, "Margaret, you know why this country
can't make a without a major transmission overhaul? Because nobody
cares, that's why."
WARNING: This is assuming your spouse's name is Margaret.
2. PLUGGING IN THE DEVICE: The plug on this device represents the
latest thinking of the electrical industry's Plug Mutation Group, which,
in a continuing effort to prevent consumers from causing hazardous
electrical current to flow through their appliances, developed the
Three-Pronged Plug, then the Plug Where One Prong is Bigger Than
the Other.
Your device is equipped with the revolutionary new Plug Whose
Prongs Consist of Six Small Religious Figurines Made of Chocolate.
DO NOT TRY TO PLUG IT IN!
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (5 of 7) [23/03/2005 05:50:00 p.m.]
Lay it gently on the floor near an outlet, but out of direct sunlight, and
clean it weekly with a damp handkerchief.
WARNING: WHEN YOU ARE LAYING THE PLUG ON THE FLOOR, DO
NOT HOLD A SHARP OBJECT IN YOUR OTHER HAND AND TRIP OVER
THE CORD AND POKE YOUR EYE OUT, AS THIS COULD VOID THE
WARRANTY.
3. OPERATION OF THE DEVICE. WARNING : WE MANUFACTURE
ONLY THE ATTRACTIVE DESIGNER CASE. THE ACTUAL WORKING
CENTRAL PARTS OF THE DEVICE ARE MANUFACTURED IN JAPAN.
THE INSTRUCTIONS WERE TRANSLATED BY MRS. SHIRLEY
PELTWATER OF ACCOUNTS RECEIVABLE, WHO HAS NEVER
ACTUALLY BEEN TO JAPAN BUT DOES HAVE MOST OF "SHOGUN"
ON TAPE.
INSTRUCTIONS: For results that can be the finest, it is our advising
that :
NEVER to hold these buttons two times!! Except the battery. Next
taking the (something) earth section may cause a large occurrence!
However. If this is not a trouble, such rotation is a very maintainence
action, as a kindly (something) virepoint from Drawing B.
4. WARRANTY: Be it hereby known that this device, together with but
not excluding all those certain parts thereunto, shall be warrantied
against all defects, failures and malfunctions as shall occur between
now and Thursday afternoon shortly before 2, during which time the
Manufacturer will, at no charge to the Owner, send the device to our
Service People, who will emerge from their caves and engage in rituals
designed to cleanse it of evil spirits. This warranty does not cover the
attractive designer case.
WARNING: IT MAY BE A VIOLATION OF SOME LAW THAT MRS.
SHIRLEY PELTWATER HAS "SHOGUN" ON TAPE.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to this Newsletter,
go to the AfraLisp main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (6 of 7) [23/03/2005 05:50:00 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-13
http://www.afralisp.com/newsletter/2002/2002-13.htm (7 of 7) [23/03/2005 05:50:00 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Thursday, April 11, 2002 9:25
--------------------------------------------------
AfraLisp Newsletter No 2002-14
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Hey, I'm back earlier that I thought. I had a nice spot of leave and a good break. Drove
about 4500km, but that's to be expected in this part of the world.
Quite a few emails waiting for me when I got back. If you sent me anything and haven't yet
received a reply, please be patient, I will get back to you.
OK, enough drivel, let's get on with this weeks Newsletter........
--------------------------------
Quote of the week
--------------------------------
"If at first you don't succeed, call it version 1.0"
--------------------------------
The Site
--------------------------------
Have you ever wondered where the Visual Lisp Editor came from?
Would you like a copy of the original standalone Visual Lisp Editor?
Are you still using R14 (or even R12 of R13) and don't have the Visual Lisp Extensions?
Then pop along here :
http://www.afralisp.com/vl/vlisp.htm
Small in size (202KB), easy to use AND you don't have to have AutoCAD installed to use it.
It's nice to have even for nostalgias sake. (who's this nostalgia guy?)
--------------------------------
The Questions
--------------------------------
Hi Kenny,
I just started working with AutoCAD a few months ago and I'm really enjoying it. I've also
began studying Autolisp in order to make my work a bit easier. I have very limited
programming experience (I've done some decent scripts for the game
Counterstrike...that's about it)...but it's better than
nothing, I guess. I discovered your site about a week or so ago and I now visit it
daily...thanks for all of the tutorials and information!
From time to time I get confused about how to make certain ideas work...do you know of
any forums or chat rooms devoted to AutoLisp? Perhaps you may be able to help me (I
notice you answered questions in your newsletter).
Here goes:
Is there a way to change the values in a block's attribute without having to select an
attribute by location (by picking a point on the attribute)? In other words, can you call up
the block attributes by name and enter the values in by command line only? Here's the
situation: I make shop drawings
for precast underground structures (manholes, storm inlets, etc). Each job we do contains
many different structures, so we use one drawing for each individual job and place a
AfraLisp Newsletter No 2002-14
http://www.afralisp.com/newsletter/2002/2002-14.htm (1 of 5) [23/03/2005 05:50:01 p.m.]
different structure on each layer of that drawing. We have an attribute block in the upper
right-hand corner of each layer stating the Job Number and the Structure Number...the
block appears to be named "STRUCT_DESC". We use several different scales within a job,
so the location of this block can change from layer to layer...which is why I'd rather
access the block by name than by location. I'm attempting a lisp
which will copy the contents of one layer to a new layer...it will get the new Structure
Number from the user and name the new layer and edit the proper attribute if this is
possible.
Well, that about sums it up for now. Thanks for taking the time to read this and keep up
the good work with the site...it's the best I've found.
Thanks again,
Don Whitford
-------------------
Don,
A good AutoLisp chat room/forum? Pop along here :
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
Look for the "Lost in Stupid Parenthetheeth " Board.
Don't worry, it's all free.
Your second question regarding attributes. Have you had a look at these three sections on
AfraLisp :
http://www.afralisp.com/lisp/attab.htm
http://www.afralisp.com/vl/attab-vl.htm
http://www.afralisp.com/vba/attabvba-htm
You've got the choice between straight AutoLisp, Visual Lisp or VBA. All three do exactly
the same but using slightly different methods. The main point though, is that they all
retrieve the block containing attributes by name and then manipulate the attribute entities.
--------------------------
Hi Kenny,
A question subjected to Autolisp would like to ask you. If there are a list of number, how
to convert the information to a polygon via autolisp?
Example :
34,324 54,3242 234,234 534,45 234,234 ......
which is equivalent to :
x1,y1 x2,y2 x3,y3 x4,y4 ....xn,yn
where the x,y represent the vertex of polygon, and x1,y1 will connected to xn,yn
As well, do you know is there any autolisp program to convert Caltech Intermediate
Format (CIF) to AutoCAD (DWG / DXF ) format?
Regards
Victor Li
--------------------------
The Answers
--------------------------
Kenny,
Just been checking your web page out. I'd been looking for some hints and tips on VBA
and came across Afralisp. Nice site.
I'm the cad manager for a building services consultant in Sydney. We run a mixture of
Autocad 2000i and the 2000 LT version. I used to use a lot of lisp at the last company I
worked - they ran the full version on all cad terminals, so it gave me a lot of control.
However, having a mixture of the full and the LT at this place means that everything has to
be set up for the 'lowest common denominator'. That is, all my routines have to be
accessible to LT. I've had to spend a hell of a lot of time setting up menus using simple
macros with some diesel thrown in. Even had to buy a bar fridge so that I could work
uninterupted in my computer shack.
I would imagine that this problem is widespread, as the price difference between the 2
versions is significant and I cannot, in all honesty, justify any increase in productivity by
asking the management to spend a few thousand dollars per platform to upgrade to the
full version.
I still use a lot of lisp myself, but there are things that I want to do for all cad draughtsmen
that become impractical when not everyone has access to that particular routine. For
AfraLisp Newsletter No 2002-14
http://www.afralisp.com/newsletter/2002/2002-14.htm (2 of 5) [23/03/2005 05:50:01 p.m.]
example, setting up a system whereby a datestamp is automatically updated whenever
you save a drawing is worthless if even one cad terminal can't run it. If the date is only
90% trustworthy, then it becomes next to useless.
Enter the boys at drcauto: http://www.drcauto.com/
I've been speaking to them about a piece of software that they've been developing over
the last year or so. It seems that Autocad LT and the full version are identical - it's just that
our friends at Autodesk throw some switches within the code to disable Lisp (and some
aspects of 3D modelling). Drcauto has gone delving into the dark, musty corners of the
code and has brushed the cobwebs off these switches and turned them back on. They are
apparently allowed to do this as they class this action as a byproduct of the software that
they offer (which is some type of layer management system). Yeah, right...
They offer this package for circa $US400. You can get a trial demo as well (but the
bastards actually charge for it! However, they will knock the few bucks off the full version
if you decide to buy). I had the local Autodesk suppliers around for a demo of 2002 not so
long ago and the upgrade price (from 2000i) was something in excess of that. It went very
quiet around the table when I asked them what they thought was the better value. I'm
pushing our hierarchy to install this on all terminals over the next few months.
I thought you might like to know about these guys and maybe include the info on your
web page. I have to say that I have no connection with drcauto, other than the fact that
they're Aussies and their office is just down the road...
Guess I'll have to get into Visual Lisp after all.
Yours,
Ian Matthews
----------------------
Here is an example of setting layouts with a dialog box and
Active X.
Peter Jamtgaard
First the DCL Coding :
ddlayout : dialog {
label="**Layouts**";
:list_box { key = "layouts";
height = 30;
width = 25;
allow_accept = true;
}
ok_only;
}
Save this as "Set_Layout.dcl".
And now the AutoLisp coding :
;CODING STARTS HERE
; Set_layout will display a dialog box with all available layouts
; and allow the user to select the layout to switch to.
(defun C:SET_LAYOUT (/ CLOSE1 LAYOUTS FULL)
(vlax-for LOUTOBJ
(vla-get-layouts
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq LAYOUTS (cons (cons (vla-get-name LOUTOBJ) LOUTOBJ) LAYOUTS))
)
(setq LAYOUTS (reverse LAYOUTS))
(vla-put-activelayout CDWGOBJ (cdr (nth (ddset_layout LAYOUTS) LAYOUTS)))
)
(defun DDSET_LAYOUT (LISTIN )
(setq id (load_dialog "set_layout.dcl"))
(new_dialog "ddlayout" id)
AfraLisp Newsletter No 2002-14
http://www.afralisp.com/newsletter/2002/2002-14.htm (3 of 5) [23/03/2005 05:50:01 p.m.]
(start_list "layouts")
(mapcar 'add_list (mapcar 'car LISTIN))
(end_list)
(action_tile "layouts" "(progn (setq LAYN (atoi $value)) (princ LAYN))")
(setq start (start_dialog))
LAYN
)
;CODING ENDS HERE
Save this as "Set_Layout.lsp".
-------------------------
Kenny,
Working my way through a large pile of your newsletters...came across question re best
way to rotate crosshairs to certain angle. Kev Knowles sent a page or 2 of yummy looking
lisp which I'm sure does the trick.
Am I missing something, or would this mini macro be a bit simpler to use. We use it as a
button on our standard toolbar.
'SNAP R 0,0;PER;
Click the button, click the entity (polyline, xref, you name it) and voila. We've got another
button to snapang to zero when you're done. Works for me...
Thanks,
Ian M
---------------------------
Here is another version of pclose with the ability to enter "c" or "space"/"enter" for the
prompt. Also it cleans up the prompts on the command line.
Mike Melichar
;CODING STARTS HERE
;---------------------------------------------------------------------
; draw pline and close with c, enter or space
;---------------------------------------------------------------------
(defun c:pclose (/ pt1 pt2)
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq pt1 (getpoint "\nStart point: "))
(setq pt2 (getpoint pt1 "\nNext point: "))
(command "PLINE" pt1 pt2)
(while pt2
(initget "Close")
(setq pt2 (getpoint pt2 "\nNext point or [Close/Enter]: "))
(if (or (= pt2 "Close") (= pt2 nil))
(progn
(command "c")
(setq pt2 nil)
)
(command pt2)
)
)
(setvar "cmdecho" cmdecho)
(princ)
)
;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
There was this fella with a parrot. And this parrot swears like a sailor, I mean he's a pistol.
He can swear for five minutes straight without repeating himself. Trouble is, the guy who
owns him is a quiet, conservative type, and this bird's foul mouth is driving him crazy.
One day, it gets to be too much, so the guy grabs the bird by the throat, shakes him really
AfraLisp Newsletter No 2002-14
http://www.afralisp.com/newsletter/2002/2002-14.htm (4 of 5) [23/03/2005 05:50:01 p.m.]
hard, and yells, "QUIT IT!" But this just makes the bird mad and he swears more than ever.
Then the guy gets mad and says, "OK for you," and locks the bird in a kitchen cabinet.
This really aggravates the bird and he claws and scratches, and when the guy finally lets
him out, the bird cuts loose with a stream of vulgarities that would make a veteran sailor
blush.
At that point, the guy is so mad that he throws the bird into the freezer.
For the first few seconds there is a terrible din. The bird kicks and claws and thrashes.
Then it suddenly gets *VERY* quiet.
At first the guy just waits, but then he starts to think that the bird may be hurt. After a
couple of minutes of silence, he's so worried that he opens up the freezer door. The bird
calmly climbs onto the man's outstretched arm and says, "Awfully sorry about the trouble
I gave you. I'll do my best to
improve my vocabulary from now on."
The man is astounded. He can't understand the transformation that has come over the
parrot.
Then the parrot says, "By the way, what did the chicken do?"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to this Newsletter,
go to the AfraLisp main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+afralisp@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-14
http://www.afralisp.com/newsletter/2002/2002-14.htm (5 of 5) [23/03/2005 05:50:01 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, April 20, 2002 1:49
--------------------------------------------------
AfraLisp Newsletter No 2002-15
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Bit of a short Newsletter this week I'm afraid. (more questions than answers). I was out of
town for most of last week on a business trip so unfortunately, I couldn't get a lot of
AfraLisp work done.
Very interesting trip though, as I went to have a look at 3D draughting packages. Some
good stuff out there!
--------------------------------
Quote of the week
--------------------------------
Suicidal twin kills sister by mistake!
--------------------------------
The Site
--------------------------------
Watch This Space. I should have the "Thingies" section up and running by next week.
--------------------------------
The Questions
--------------------------------
Hello,
Thanks for your newsletter. I have a question to submit:
I have a Microsoft Access database in MA2001. I'm using Autocad 14. My database is
about 12 fields long. I have about 120 records in this database and would like to link this
database to drawings.
I work for an electrical contractor and the drawings are in paperspace with an mview
window. The Access table is a list of conduit runs, the fields describe the properties of
the run (size conduit, contents, source, destination, bla, bla, bla. There is also a ref #). If,
for example (5) conduits appear in a particular drawing, I'd like those (5) records to be
linked into the drawing, when I specify the appropriate ref # somewhere. The information
could be displayed on the paper space next to the mv window or in another mv window.
Can this be done? If so could we go a step further and say that some sort of intelligence
could be added to objects to make the proper records appear in each drawing
automatically?
Thank You,
Darryl
-------------------------------
Dear sir,
I am facing the following problem: I would like to move a block in Acad, thusfar no
problems, if I do this with the "move" command, then a ghost image appears after
selecting the `base point`, so that one can see where the object will be positioned after
clicking the target-point.
Now the following question: is this possible through VBA??? Moving objects and
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (1 of 7) [23/03/2005 05:50:03 p.m.]
selecting their target point is no problem, but i don`t find a solution to see the
ghost-image.
I think this problem can be solved by sending the normal command `move`, so by
sending from VBA a Autolisp command to Acad, but I don`t know what is the syntax to
send this command from VBA.
If you have any suggestion how to solve this problem, please let me know
kind regards,
Diederik Laroy
--------------------------
Hi Kenny,
I am coding a program in VB which creates DWF files once you select a directory where
you have your DWG files. This runs in a loop opening each DWG and generating DWF.
My problem is that when it opens the second DWG it pops up a dialog box which say's
"Save changes to C:\xxx.dwg" and gives you three options of "Yes/No/Cancel". Is there
any way we can supress this dialog box.
The steps my program will perform are:
(1) Open the DWG file
(2) Create a temp layer where I can put hatch pattern in the rooms (This involes query
from database. Each room has diff. pattern and attribute which comes from DB)
(3) Create the DWF file with the hatch patterns inculed and the attributes of the room
(4) I do not want to save the DWG file since we only require hatch pattern for DWF
(5) Open the next DWG file and do the same
If you can help me out I will appreciate it very much. I know you have worked lot on
VB/VBA/LISP
Hope to hear from you soon.
Thnx,
Anwarul M Sufi
-------------------------
Anwarul,
You can use the "SetDbMod" method of asdkunsupp2000.ARX
http://vbdesign.hypermart.net/cadpages/tbox.htm
(R14 users can get the same functionality using AcadUnsupp.ARX from the same page)
To force "DBMOD" to 0 prior to opening the next drawing. After you download the ARX,
follow the
instructions in the help file for registering it, then use code like this:
Public Sub SetDbMod()
Dim objSup As AsdkUNSUPP2000Lib.Application
Set objSup = _
Application.GetInterfaceObject("Asdkunsupp2000.Application.1")
objSup.SetDbMod 0
End Sub
-----------------------------
Hi Kenny hope you had a good holiday,
This is more of a general question than a LISPy one. Have you ever come across the .cit
image format used extensively in Microstation for background mapping. I need to use
backgrounds we got with some Microstation drawings to generate new maps in Acad
and I was wondering if you knew where I could
get a compatible (free) .dll for Acad or if you knew of another method of importing this
image format into Acad. Any ideas?
Regards
Liam
--------------------------------
hi Kenny,
I would like to know how to execute a wave file without having the dos screen or without
starting any wav player....is it possible??
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (2 of 7) [23/03/2005 05:50:03 p.m.]
only play a wav file when a button or option is selected.....
(i work with lisp...not VBA...)
thanks...
Andrea Andreetti
--------------------------
Andrea,
Have a look at "DosLib" by Robert Mcneel and Associates.
http://www.mcneel.com
You can play a "wav" file from AutoLisp using one of the functions.
-------------------------
G' day Kenny
Have been a fan and member for years and think it is still one of the best sources on the
net.
I do a bit of programming and have a question. I am doing a bunch of dialogues that
have image panels in them.
What is the best way to get the full image tile filled with the slide? I has been ages since I
did these slides but I seem to remember that it requires getting the dimx dimy values
from the image tile, then using that size as a view port size.
Is this right?? When you mslide, do you do this in PS or MS??
Know anyone with a creation tool for doing it this way? I have Slide factory which is
good but not suitable for this application.
regards
Mark Bowes
--------------------------
The Answers
--------------------------
Here's a lisp routine for exploding minserted blocks into single blocks and keeping the
minsert block pattern?
Heine Munch Nielsen
;CODING STARTS HERE
(defun C:MINX (/ ENT OBS BLK INS CS RS RWS CLS)
(if (setq ENT (entsel "\nSelect minsert: "))
(progn
(command ".undo" "begin")
(setq OBS (entget (car ENT))
BLK (cdr (assoc 2 OBS))
INS (cdr (assoc 10 OBS))
CS (cdr (assoc 44 OBS))
RS (cdr (assoc 45 OBS))
RWS (cdr (assoc 70 OBS))
CLS (cdr (assoc 71 OBS))
)
(command ".insert" ENT "non" INS "" "" "" ".array" "Last" "" "R" CLS RWS RS CS
".erase" ENT "")
(command ".undo" "end")
)
)
)
(princ)
;CODING ENDS HERE
--------------------------
Kenny,
I was able to resolve the issue of "painting the "z" from one object to another, so I'm
sharing it with you and the fans of Afra-Lisp.
This uses "nearest" for a snap, so be aware that wherever you select (especially on an
object with differing "z's") it will use that value. My small repayment for all of your help.
Tested on ADT3.
Thanks,
Garry
;CODING STARTS HERE
;created 04-09-02 by Garry Fisher
(defun c:paintz (/ a2 c2 newtdc oldtdc obj1 obj2)
(setvar "osmode" 512)
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (3 of 7) [23/03/2005 05:50:03 p.m.]
(SETQ moveme (GETPOINT "\nSelect the entity to be moved to the desired elevation"))
;(setq SS1(lastn 1))
(SETQ OLDTDC (GETPOINT "\nSelect an entity on the desired elevation"))
(terpri)
(SETQ obj1 (ENTLAST))
(setq a2 (caddr oldtdc))
(setq c2 (caddr newtdc))
(COMMAND "CHANGE" moveme "" "P" "E" a2 "" "")
)
;CODING ENDS HERE
--------------------------------------
Hi Kenny
Roaming around the net i found these undocumented filters for the ssget function:
:L Disallows selection of objects on locked layers (this was what I was looking - so cool!)
:P Disallows selection of Paper space viewports
:C Limits selection to objects in the current space
The last three flags are undocumented. Their use is permitted only in conjunction with
the default interactive object selection mode (where the balance of the mode argument is
an empty string). These three modes cannot be used with "X", or "P" or other modes that
prompt the user to interactively select objects. These three flags are particularly useful
for preventing the use of the "All" object selection keyword from selecting objects on
locked layers; objects not in the current space; or paper space viewports.
Maybe you knew them already but I thought it could be something for the newsletter.
Heres the link - there's some pretty dandy info on selection sets, in VBA though:
http://members.bellatlantic.net/~vze2vjds/acadx/classes/acadxapplication.htm
Med Venlig hilsen
Kind regards
Heine Munch Nielsen
---------------------------
You might like this routine for your thingies section, which enables a user to pick
multiple points with visual feed back and this is then passed back to the main routine.
Note the global variable...
PMV:EntlastFlag
The error routine will delete the entity if there is a crash.
Kind regards
Paul Matthews.
;;; CODING STARTS HERE.
;;; GEN:GETMPOINTS.lsp
;;; Written by Paul Matthews
;;; DESCRIPTION
;;; Sub routine that enables user to pick multiple points and returns
;;; list of points at conclusion to main routine. Function uses PLINE
;;; function to give user an indication of what is happening.
;;; MODE = nil for standard, 1 for 3D poly
;;; retain = keep created pline ( T ) or delete it ( nil ).
( defun GEN:GetMPoints ( MODE Retain / fp p1 p2 pntlst elst )
; This flag is called by error routine to check if pline requires deleting during crash
( setq PMV:EntlastFlag nil )
( defun GRdgp ( p )
( initget "Close Undo" )
( getpoint p "\nClose/Undo/<Endpoint of line>: " )
);def local function
( setvar "cmdecho" 0 ); turns off autocad prompts
( if
( setq fp ( getpoint "\nFrom point: " ))
( progn
( setq p1 fp pntlst ( list p1 )) ; start pntlist
( if ( = mode nil )
( progn ( setvar "PLINETYPE" 1 )( command "_.pline" p1 ))
( command "_.3dpoly" p1 )
)
( if ( null Retain )( setq PMV:EntlastFlag 1 ))
( setq p2 ( GRdgp p1 ) )
( while p2
( cond
;-------------------------------------------------
(( = p2 "Undo" ) ; remove last point from lst
( progn
( cond
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (4 of 7) [23/03/2005 05:50:03 p.m.]
(( > ( length pntlst ) 2 )
( progn
( setq pntlst ( reverse pntlst )
pntlst ( cdr pntlst )
p1 ( car pntlst )
pntlst ( reverse pntlst )
)
( command p2 )
)
)
(( = ( length pntlst ) 2 )
( progn
( setq p1 ( car pntlst ) pntlst ( list p1 ))
( command p2 )
)
)
(( = ( length pntlst ) 1 )
( progn
( setq PMV:EntlastFlag nil )
( princ "\nAll segments already undone." )
)
)
);cond
);progn
)
;-------------------------------------------------
(( = p2 "Close" )
( progn
( if ( > ( length pntlst ) 2 )
( progn
( command p2 )
( setq p2 0 )
( if ( null Retain )( setq PMV:EntlastFlag 1 ))
)
( progn
( princ "\nCannot close until two or more segments have been drawn")
)
);if
))
;-------------------------------------------------
(( /= p2 nil )
( progn ( command p2 )
( setq p1 p2 pntlst ( append pntlst ( list p2 )))
( if ( null Retain )( setq PMV:EntlastFlag 1 ))
))
);cond
( if ( /= p2 0 )( setq p2 ( GRdgp p1 )))
( if ( = p2 nil )( command "" ))
( if ( = p2 0 )( setq p2 nil ))
; ( princ pntlst)( princ " " );( princ p2 )( terpri )
);while
;(princ "flag1" )
;( princ PMV:EntlastFlag )
;( princ pntlst)
;;; function needs to discern if LWpline or HeavyPline and get
;;; resulting point list.
( setq elst ( entget ( entlast )))
;( princ "flag2" )
( if ( = ( dxf 0 elst ) "LWPOLYLINE")
( setq pntlst ( GEN:LwplinePntLst elst ))
( setq pntlst ( GEN:PlinePntLst elst ))
)
( if ( null Retain )( progn ( entdel ( entlast )) ( setq PMV:EntlastFlag nil )))
);progn
);if
pntlst
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (5 of 7) [23/03/2005 05:50:03 p.m.]
); defun
; returns pntlst of a 3dpline
( defun GEN:PlinePntLst ( elst / plst p )
( setq elst ( entnext ( dxf -1 elst ))
elst ( entget elst )
);setq
( while ( = ( dxf 0 elst ) "VERTEX")
( setq p ( dxf 10 elst )
elst ( entnext ( dxf -1 elst ))
elst ( entget elst )
);setq
( if ( null plst )
( setq plst ( list p ))
( setq plst ( append plst ( list p )))
)
);while
plst
)
; returns pntlst of a LightWeightPline
( defun GEN:LwplinePntLst ( elst / val pnt_lst )
( foreach val elst
( if ( = ( car val ) 10 )
( progn
( if ( = pnt_lst nil )
( setq val ( append ( cdr val ) '(0.0))
pnt_lst ( list val )
)
( setq val ( append ( cdr val ) '(0.0))
pnt_lst ( append pnt_lst ( list val ))
)
)
);progn
);if
);4
pnt_lst
);defun
;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
An man walks into a city bank and asks to see the loan officer. He says he is going on
holiday for two weeks
and needs to borrow $10,000. The bank officer says the bank will need some kind of
security for such a loan, so the man hands over the keys of his new BMW M3 parked on
the street in front of the bank.
Everything is checked out, and the bank agrees to accept the car as collateral for the
loan. An employee drives the BMW into the bank's underground garage and parks it
there.
Two weeks later, the man returns, repays the $10,000 and the interest, which comes to
$15.41.
The loan officer says, "We are very happy to have had your business, and this
transaction has worked out very nicely, but we are a little puzzled.
While you were away, we checked you out and found that you are a multimillionaire.
What puzzles us is why would you bother to borrow $10,000?"
The man replied, "Where else in the city can I park my car safely for two weeks for only
15 bucks?"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (6 of 7) [23/03/2005 05:50:03 p.m.]
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to this Newsletter,
go to the AfraLisp main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
----------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+kenny@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-15
http://www.afralisp.com/newsletter/2002/2002-15.htm (7 of 7) [23/03/2005 05:50:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, April 26, 2002 9:05
;READING STARTS HERE
--------------------------------------------------
AfraLisp Newsletter No 2002-16
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
Disturbing the peace since 1994
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------
The Front Stoep
--------------------------
Well another week has passed me by and I still haven't managed to add anything new to
AfraLisp. What will my mother say? Tut, tut, Kenny!!
We did though, manage to put the first African in space. (thanks to the Russians and lot's
of money). Not to be beaten, Namibia has plans to send the first manned mission to the
sun. "But they'll burn up", I can hear you say. Naaw, we're going to send them at night.
Anyway, to make up for my lack of contribution to AfraLisp, there's lot's of coding and
some nice goodies in this weeks Newsletter.
Oh, by the way, a big welcome to Terry Baker. Terry was the gentleman that first
introduced me to AutoCAD and AutoCAD customisation. (is that good or bad??) I'm
hoping to twist his arm and get him to contribute one or two articles to this Newsletter
(and hopefully AfraLisp), as he really knows his stuff.
--------------------------------
Quote of the week
--------------------------------
"I am amazed at radio DJ's today.
I am firmly convinced that AM stands for Absolute Moron.
I will not begin to tell you what FM stands for."
- Jasper Carrott
--------------------------------
The Site
--------------------------------
Have you upgraded to 2002?
Have you lost your "Express Tools?"
Would you like to have Express Tools installed in 2002?
You would? OK, now follow these simple steps :
Firstly, you will need to have your R2000 installation disk.
Got it? Great!
Create a sub-directory "Express" under the main AutoCAD 2002 directory.
Copy all the files in the AutoCAD 2000\Express directory to your new "Express"
sub-directory.
(Copy Autocad 2000\express\*.* to Autocad 2002/express)
Copy Autocad 2000\support\acettest.fas to Autocad 2002\support
Copy Autocad 2000\help\acetmain.hlp to Autocad 2002\help
Copy Autocad 2000\help\acetmain.cnt to Autocad 2002\help
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (1 of 9) [23/03/2005 05:50:05 p.m.]
Copy Autocad 2000\help\acetfaq.hlp to Autocad 2002\help
Fire up AutoCAD 2002 and select "Tools" "Load Application" from the pulldown
menus.
Now, from the "Startup Suite" select "Contents".
Add the file "acettest.fas" from your AutoCAD 2002 Support directory.
Exit the dialog.
Now, exit and then re-open AutoCAD.
Type "Expressmenu" at the command line.
Voila, your "Express" menu pulldown should now appear.
Please note that I haven't tested whether on not all the Express Tools work correctly in
AutoCAD 2002.
-------------------------------
Don't you like the "Double-Click" feature in 2002?
Would you like to switch it off?
You can disable the double click by typing "Dblclkedit" at the command line and selecting
"Off".
Just thought you might like to know!
-------------------------------
Would you like to use AutoCAD commands from Visual Basic or VBA?
Use the SendCommand method on the document object.
This example sends a command to the AutoCAD command line of a particular drawing for
evaluation. We will create a Circle in the active drawing and will zoom to display the entire
circle
'CODING STARTS HERE
Sub Example_SendCommand()
ThisDrawing.SendCommand "_Circle" & vbCr & "2,2,0" & vbCr & "4" & vbCr
ThisDrawing.SendCommand "_zoom" & vbCr & "a" & vbCr
ThisDrawing.Regen acAllViewports
MsgBox "A circle command has been sent to the command line of the current drawing."
End Sub
'CODING ENDS HERE
----------------------------------------
Do you know that you can automate the creation of DWF files using VBA?
The following code listing provides an example of how to create a DWF file using VBA :
'CODING STARTS HERE
Sub test()
Dim objDoc As AutoCAD.AcadDocument
Set objDoc = Documents.Open("C:\AutoCAD 2000\sample\colorwh.dwg")
Set objPlot = objDoc.Plot
Dim blnRet As Boolean
blnRet = objPlot.PlotToFile("c:\temp\temp.dwf",
"C:\AutoCAD 2000\plotters\DWF ePlot.pc3")
'Replace C:\AutoCAD 2000 with the location of acad.exe
'blnRet should be True if the plot is successful
objDoc.Close False
End Sub
'CODING ENDS HERE
--------------------------------------------
Script files do not execute properly when you use long file names or directory names in
the script. For example, if you included the path c:\myproject\floor plan.dwg in a script,
the Program would look for a file named floor and ignore the rest of the file name. Spaces
in file names are interpreted to be the end of the path.
To use long file names or directory names in a script file, you must enclose the entire path
in double quotes, as in the following example:
"c:\my project\floor plan.dwg"
The text inside the quotes is read as one object.
---------------------------------------------
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (2 of 9) [23/03/2005 05:50:05 p.m.]
Would you like to be able to access the Registry using Visual Lisp?
Try this :
;CODING STARTS HERE
(defun C:RegTest ( / AcadReg LMAcadReg Name1 Name2)
(vl-load-com)
(setq AcadReg (vlax-product-key)
LMAcadReg (strcat "HKEY_LOCAL_MACHINE\\" AcadReg)
Name1 (vl-registry-read LMAcadReg "FirstName")
Name2 (vl-registry-read LMAcadReg "LastName")
);setq
(alert (strcat "The name of this computer is " Name1 " " Name2))
(princ)
);defun
(princ)
;CODING ENDS HERE
Thanks to Bill Kramer for this little beauty.
------------------------------------------
Have you got an AutoLisp/Visual Lisp question that you would like an answer to?
Then make your way along to this forum :
http://www.vbdesign.net/~rrath/cgi/ikonboard301/ikonboard.cgi
Look for the "Lost in Stupid Parenthetheeth " Board.
This forum is also the best in regards to VB/VBA.
--------------------------------
The Questions
--------------------------------
Hi,
I would like to hatch multiple objects by picking a polyline or picking inside a space.
Is there a way this can be done with Lisp or vb so that the hatches remain individual for
editing rather than becoming one block. I use AutoCAD 2000
Any help greatly appreciated
Michael de Glanville
--------------------------
Michael,
When I first read your question, I immediately thought about using selection sets.
We would first create a selection set of all Objects or Points, loop through each one
hatching the object or area as we went along. Then I thought, don't be silly Kenny, why
don't we just use the "Bhatch" command and stick it in a "while" loop. Unfortunately, the
coding below will only allow you to select and Internal Point or an Object. (It's also a bit
"rough and ready").
Paste this into Notepad and save it as "MHatch.lsp".
;CODING STARTS HERE
(prompt "\nType MHATCH to run")
(defun c:mhatch ( / flag ans)
(setq flag (getstring "\nInternal Point or Object <I or O> : "))
(setq ans "y")
(if (or (= flag "I") (= flag "i"))
(progn
(while (or (= ans "y") (= ans "Y"))
(prompt "\nSpecify internal point : ")
(command "-bhatch" pause "")
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (3 of 9) [23/03/2005 05:50:05 p.m.]
(setq ans (getstring "\nContinue? <Y or N> : "))
);while
);progn
);if
(if (or (= flag "O") (= flag "o"))
(progn
(while (or (= ans "y") (= ans "Y"))
(prompt "\nSelect Object : ")
(command "-bhatch" "S" pause "" "")
(setq ans (getstring "\nContinue? <Y or N> : "))
);while
);progn
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
-----------------------------------
Good Morning Mr Ramage,
My name is Chris Griffiths, i spent a night searching the internet for an Autocad program
that would extract 'attext' data from clients drawing title blocks. Preferably a stand alone
program. I found 2, one costs too much for the single need I have, the other program is
'attext.exe' which is very simple but I believe, it needs the dwgs to be in release 12, so I
need to batch convert a few hundred dwgs.
Does your program do this, and how does it work? I tried to use your prog but did not
know where to run it from. Sorry I am a bit incompetent when it comes to technical things.
Chris Griffiths
-----------------------------
My problem is with the creation of the slides. I am having problems with the slides not
filling the image tile fully. They appear as fairly small images in the image tile. I would also
like to be creating them so they are fairly consistant in location.
What's happening...
The dialogue shows a duct piece, when various insulation radio buttons are selected, the
image tile changes to reflect the set insulation. The original slides I created are perfect but
I have created more with extra detail and these are all over the place - I just can't
remember the trick.
Mark
--------------------------------
Could you give me some feedback about the 3d packages you looked at? Im specifically
interested in applications for architects in conjunction with Autocad.
Regards Charles Howroyd
------------------------------------
Charles,
I looked at four main packages. Unfortunately, I was looking at them from the point of view
of Plant Layout and Structural/Mechanical design/detailing and not from an Architectural
point of view.
I had a look at Rhino, AutoCAD Inventor, Rebis and Pro-Engineer.
--------------------------------------
Kenny
Do you or any of your readers have a routine that will search a drawing for 2 identical
entities, be it blocks, lines text etc and delete all but one of those entities.
I have recieved a number of external drawings lately, that have 2 lots of blocks, 1 on top of
the other and am looking for a quick way of cleaning them up. Any help would be greatly
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (4 of 9) [23/03/2005 05:50:05 p.m.]
appreciated.
Thanks
Dennis.
---------------------------------------
Dennis,
Check out the AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001-05.htm
---------------------------------------
Mr. Kenny
I'm sorry ! No good of my English.
I have a question about Autocad command of "Offset"
Offset command to select one at a time of Autocad default value .
Now!!
I want to select one time several articles of "Offset" command. (maybe above 500 articles).
How to writing the lisp program??
Thanks for your help ...
Peter Chiu
---------------------------
Peter, try this :
;CODING STARTS HERE
;This application will perform an Offset on multiple entities.
;Kenny Ramage - April 2000
;afralisp@mweb.com.na
;http://www.afralisp.com
(prompt "\nType MULTOFF to run....")
(defun c:multoff ( / off sel1 side n lng)
(setq off (getdist "\nOffset Distance : ")
sel1 (ssget)
side (getpoint "\nSelect Side to Offset: ")
n 0
lng (sslength sel1))
(repeat lng
(setq ent (ssname sel1 n))
(command "OFFSET" off ent side "")
(setq n (1+ n))
);repeat
(princ)
);defun
(princ)
;CODING ENDS HERE
Save this as "Multoff.lsp".
----------------------------------
Hello,
I'm in need of shareware or software that will batch convert dwg's to pdf's Any help or
ideas?
Regards,
Rodger L. Ackinclose
------------------------
Strange, but I've just received this in my mailbox :
AcroPlot(tm) is the fast, easy, and inexpensive way to convert several AutoCAD drawings
into an Adobe Portable Document Format (*.pdf) file. AcroPlot even includes it's own PDF
Printer driver so there is no need to buy Adobe Acrobat. With AcroPlot(tm) you can easily
add bookmarks, a title page, and even create the email to send the .pdf file to your
customers or clients. Other features include advanced options such as template files, text
tags, and watermarks that allow you to quickly create the perfect PDF document for
anyone to view.
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (5 of 9) [23/03/2005 05:50:05 p.m.]
For further information, contact:
mailto:mail@cadopolis.com
www.cadopolis.com
Or :
mailto:sales@cadzation.com
www.cadzation.com
--------------------------
The Answers
--------------------------
Would you like to have a look at an "Artificially Intelligent Referencing Agent" that runs in
AutoCAD?
Then pop along to Aaron Strom's webpage :
http://geocities.com/watsonlisp/index.html
---------------------------
Re: AutoCAD Background color.
Here's a simple function that changes your bgcolor to any RGB values you like :
;CODING STARTS HERE
(defun bgcol (r g b / mycol)
(setq mycol (+ (* b 65536) (* g 256) r))
(command "VBASTMT"
(strcat "Thisdrawing.application.preferences.Display.GraphicsWinModelBackgrndColor =
"
(itoa mycol)
)
)
);defun
;CODING ENDS HERE
I might add that if the color "numbers" look kinda weird, it's because they are computed a
certain way. An OLE-color is a longint and is calculated this way :
Color = (blue * 65536) + (green * 256) + red
Call it from a loop with 3 changing integers and you'll have a psychedelic rush (or maybe
not).
Stig Madsen
---------------------------
I have encountered what may be a bug in AutoCAD 2000 regarding the Layout TABs. On
several occasions now, for seemingly no reason, the UCS on a Layout tab becomes
rotated 90 clockwise - but is still World UCS!! All the info inside the various viewports
appears to have disappeared. You can stand on your head and whistle Beethovens' 5th
through your feet but nothing will rectify the Layout. The solution, though, is very simple.
Use CTRL-C (copy clip) to copy everything on the offending Layout tab. Create a new
Layout and make it current, then CTRL-V (paste). All the info and UCS is back to normal.
You may find that on some occasions the viewports have been turned off, use MVIEW
command to turn them back on.
Hope this may be helpful to some.
Dave
---------------------------
Hey,
Would you like a different version?
Minserts to Inserts and visa versa.
Peter Jamtgaard
;CODING STARTS HERE
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (6 of 9) [23/03/2005 05:50:05 p.m.]
;Minsert to Insert
(defun C:MINTOIN (/ B CNT BELST BENAM ELST ENAM SSET)
(setq SSET (ssget (list (cons 0 "INSERT")))
CNT 0
)
(if SSET
(progn
(repeat (sslength SSET)
(setq ENAM (ssname SSET CNT)
ELST (entget ENAM)
)
(if (= (cdr (assoc 100 (reverse ELST))) "AcDbMInsertBlock")
(progn
(setq ELST (subst (cons 70 0)(assoc 70 ELST) ELST)
ELST (subst (cons 71 0)(assoc 71 ELST) ELST)
ELST (reverse (subst (cons 100 "AcDbBlockReference")(assoc 100 (reverse ELST))
(reverse ELST)))
BENAM ENAM
CNT (1+ CNT)
)
(entmake (cdr ELST))
(setq B 0)
(if (= (cdr (assoc 66 ELST)) 1)
(while B
(setq BENAM (entnext BENAM)
BELST (entget BENAM)
)
(entmake (cdr BELST))
(if (= (cdr (assoc 0 BELST)) "SEQEND")(setq B nil))
)
)
(entdel ENAM)
)
)
)
)
)
(prin1)
)
;CODING ENDS HERE
----------------------------------
;CODING STARTS HERE
;Insert to Minsert
(defun C:INTOMIN (/ B CNT BELST BENAM ELST ENAM SSET)
(setq SSET (ssget (list (cons 0 "INSERT")))
CNT 0
)
(if SSET
(progn
(repeat (sslength SSET)
(setq ENAM (ssname SSET CNT)
ELST (entget ENAM)
)
(if (= (cdr (assoc 100 (reverse ELST))) "AcDbBlockReference")
(progn
(setq ELST (subst (cons 70 2)(assoc 70 ELST) ELST)
ELST (subst (cons 71 2)(assoc 71 ELST) ELST)
ELST (reverse (subst (cons 100 "AcDbMInsertBlock")(assoc 100 (reverse ELST)) (reverse
ELST)))
BENAM ENAM
CNT (1+ CNT)
)
(entmake (cdr ELST))
(setq B 0)
(if (= (cdr (assoc 66 ELST)) 1)
(while B
(setq BENAM (entnext BENAM)
BELST (entget BENAM)
)
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (7 of 9) [23/03/2005 05:50:05 p.m.]
(entmake (cdr BELST))
(if (= (cdr (assoc 0 BELST)) "SEQEND")(setq B nil))
)
)
(entdel ENAM)
)
)
)
)
)
(prin1)
)
;CODING ENDS HERE
---------------------------
The Back Stoep
---------------------------
A few months ago, there was an opening with the CIA for an assassin. These highly
classified positions are hard to fill, and there's a lot of testing and background checks
involved before you can even be considered for the position. After sending some
applicants through the background checks, training and testing, they narrowed the
possible choices down to 2 men and a woman, but only one position was available.
The day came for the final test to see which person would get the extremely secretive job.
The CIA men administering the test took one of the men to a large metal door and handed
him a gun. "We must know that you will follow your instructions no matter what the
circumstances", they explained. "Inside this room, you will find your wife sitting in a chair.
Take this gun and kill her."
The man got a shocked look on his face and said "You can't be serious! I could never
shoot my own wife!" "Well", says the CIA man, "you're definitely not the right man for this
job then."
So they bring the second man to the same door and hand him a gun. "We must know that
you will follow instructions no matter what the circumstances ", they explained to the
second man. "Inside
you will find your wife sitting in a chair. Take this gun and kill her."
The second man looked a bit shocked, but nevertheless took the gun and went in the
room. All was quiet for about 5 minutes, then the door opened. The man came out of the
room with tears in his
eyes. "I tried to shoot her, I just couldn't pull the trigger and shoot my wife. I guess I'm not
the right man for the job." "No" the CIA man replied, "You don't have what it takes. Take
your wife and
go home."
Now they're down to the woman left to test. Again they lead her to the same door to the
same room and hand her the same gun. "We must be sure that you will follow instructions
no matter what the
circumstances, this is your final test. Inside you will find your husband sitting in a chair.
Take this gun and kill him." The woman took the gun and opened the door. Before the
door even closed all the way, the CIA heard the gun start firing. One shot after another for
13 shots. Then all hell broke loose in the room. They heard screaming, crashing, banging
on the walls. This went on for several minutes, then all went quiet. The door opened
slowly, and there stood the woman.
She wiped the sweat from her brow and said "You guys didn't tell me the gun was loaded
with blanks!
I had to beat the son of a bitch to death with the chair!"
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (8 of 9) [23/03/2005 05:50:05 p.m.]
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to this Newsletter,
go to the AfraLisp main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
;READING ENDS HERE
----------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+afralisp@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-16
http://www.afralisp.com/newsletter/2002/2002-16.htm (9 of 9) [23/03/2005 05:50:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Thursday, May 02, 2002 21:50
--------------------------------------------------
AfraLisp Newsletter No 2002-17
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
Are you looking for an Applications Developer?
Larry Hooven is your man.
mailto:dirty_howi@yahoo.com
Read on for more details.
--------------------------
The Front Stoep
--------------------------
"The Times they are-a-Changing"
Ladies and Gentlemen. I'm afraid I've got some good news and some bad news.
The bad news first.
Due to time constraints and work commitments on my side, I am not going to be able to
carry on with the AfraLisp Newsletter. In fact, this will be the final issue.
(Loud groans of dismay rise up from around the planet!!!!)
The good news is, Randall Raath (http://www.vbdesign.net) and myself, Kenny Ramage
(http://www.afralisp.com) have decided to put our heads together and publish a brand
new Newsletter. Within this new, improved, electronic correspondence, provisionally
entitled "Out of the Nutshell", we intend to provide coverage of all the AutoCAD
customisation languages.
(I look after AutoLisp and Visual Lisp, and Randall takes care of VC++ and the DWG
format via VB. We will both be sharing VBA).
The format of the letter will basically remain the same except that we will be covering a
lot more issues and looking at them in greater depth. Don't worry, we will still be catering
for all users, from beginners to experts. We also hope to have quite a few "guest" writers
to give you an even larger subject scope and the Question and Answer format will of
course, still apply - my mailbox is always open.
I hope you will all still continue to support Randall and myself in this new venture. There
will be no need to re-subscribe as your subscription to the AfraLisp Newsletter will
automatically be transferred. In the unlikely chance that you do not like the new
Newsletter, full unsubscribe information will be provided in the first issue and on the
AfraLisp and VB Design websites.
And, talking about the first issue, Wednesday the 15th of May is the planned roll out
date.
Your feedback and comments in regards to this first issue would be greatly appreciated.
I thank you for your support (and more than a few laughs), and hope that you find "Out
of the Nutshell" exciting, informative and that you hopefully learn a thing or two.
I Thank You.....
Kenny
-----------
(Kenny slumps over his keyboard. A tear trickles slowly down his cheek as he realises
that he has reached a crossroads, the end of an era, the beginning of a new
dawn........Sniff, sniff).
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (1 of 10) [23/03/2005 05:50:07 p.m.]
--------------------------------
Quote of the week
--------------------------------
"2 + 2 = 3 for extremely large values of 2."
--------------------------------
The Site
--------------------------------
As a bit of a "going away" present, I'd like to point you to this link :
http://www.afralisp.com/newsletter/code/code.htm
Here you will find a listing of ALL the coding that appeared in the AfraLisp Newsletters.
Go on, help yourself......
-----------------
Now for a bit of fun.
Copy this into Notepad and save it as "Flag.lsp".
Enjoy!!!
;CODING STARTS HERE
;Written by Watson Kilbourne
(prompt "\nType FLAG to run and stand to attention........")
(defun C:FLAG ( / SP HT XD XA EP YA D1 D2
D3 D4 RP RH XZ YZ P1 P2
P3 P4 P5 P6 P7 P8 P9 PX
PY PZ S1 S2 S3 S4 S5 S6
oldecho)
(setq oldecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(while (= SP nil)
(setq SP (getpoint "\nPick Lower Left Corner of Flag : "))
);while
(while (= HT nil)
(setq HT (getcorner SP "\nPick Upper Right Corner of Flag : "))
);while
(if (>= (angle SP HT) (/ pi 2))
(setq HT (polar SP (/ pi 4)
(distance SP HT)))
);if
(setq XD (distance SP HT)
XA (angle SP HT)
EP (polar SP (/ pi 2) (* XD (sin XA)))
YA (angle SP EP)
D1 (distance SP EP)
D2 (/ D1 13)
D3 (* D2 0.8)
D4 (* D2 1.4)
RP (polar SP 0.0 (* D1 1.5))
RH (polar EP 0.0 (* D1 1.5))
XZ (polar SP (* pi 1.25) D2)
YZ (polar RH (* pi 0.25) D2)
P1 (polar SP (/ pi 2) (* d2 6))
P2 (polar P1 0.0 (* D2 8.5))
P3 (polar EP 0.0 (* D2 8.5))
P4 (polar SP YA D2)
P5 (polar RP YA D2)
P6 (polar P4 YA D2)
P7 (polar P5 YA D2)
P8 (polar RP YA (* D2 6))
P9 (polar P2 YA D2)
PX (polar P8 YA D2)
PY (polar P9 YA D2)
PZ (polar PX YA D2)
S1 (polar P1 (* pi 0.25) D2)
S2 (polar S1 (* pi 0.3) (* D3 0.172))
S3 (polar S1 (* pi 0.7) (* D3 0.172))
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (2 of 10) [23/03/2005 05:50:07 p.m.]
S4 (polar S1 YA (* D3 0.43952))
S5 (polar S1 (* pi 0.25) D2)
S6 (polar P3 (* pi 1.25) D4)
);setq
(command "BLIPMODE" "OFF"
"FILL" "ON"
"ZOOM" "W" XZ YZ
"LAYER" "M" "BLUE" "C" "5" "" ""
"SOLID" P1 P2 EP P3 ""
"LAYER" "M" "RED" "C" "1" "" ""
"SOLID" SP P4 RP P5 ""
"ARRAY" "L" "" "R" "3" "1" (* D2 2)
"SOLID" P2 P9 P8 PX ""
"ARRAY" "L" "" "R" "4" "1" (* D2 2)
"LAYER" "M" "WHITE" "C" "7" "" ""
"SOLID" P4 P6 P5 P7 ""
"ARRAY" "L" "" "R" "3" "1" (* D2 2)
"SOLID" P9 PY PX PZ ""
"ARRAY" "L" "" "R" "3" "1" (* D2 2)
"SOLID" S1 S2 S3 S4 ""
"ARRAY" "L" "" "P" S1 "5" "360" "Y"
"ARRAY" "W" P1 S5 "" "R" "5" "6" D4 D4
"COPY" "W" P1 S6 "" S1 S5
"BLIPMODE" "ON"
);command
(setvar "CMDECHO" oldecho)
(princ)
);defun
(princ)
;CODING ENDS HERE
-------------
Just as a matter of interest, these were the Top Twenty search strings for AfraLisp
during the month of April: vba tutorials; visual lisp; autolisp; vba; powerpoint vba; edit
dll files; lisp editor; excel timesheet; autocad linetypes; visual basic autocad; vba
autocad; macro recorder; autocad visual basic; autolisp files; edit dll; hatch patterns;
resource hacker;
toolbar.dll; introduction to vba; vba primer.
--------------------------------
The Questions
--------------------------------
Does anyone or has anyone worked with this?? I have done a few things. I'm wondering
if there is a way that I can force the actually size of the link to show more of the object
that I have embedded or linked into my file. I seen a weB site that covered such a topic,
but I did not bookmark it for future reference. I also want to know why it is that when I
create a plt file of a drawing that the OLE info does not get wrote to the plt file. If there is
anyone that can help, please let me know.
Thanks
Brian S. Young
-------------------------------------
Dear Kenny,
Is possible to discover in AutoCAD R14 if source of a Style of I Test they have the
property Bold or Italic with VisualLISP or AutoLISP?
Thanks Sebastio.
---------------------------------------
Hi Kenny
I'm fine tuning some of my lisp routines to include an ABOUT or Help file. I would like to
be able to extract the path portion of a lisp routine that is loaded in the current drawing
using visual lisp. Is this possible?
Cheers
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (3 of 10) [23/03/2005 05:50:07 p.m.]
Dave
-----------------
Dave,
Here you go, this should help you out :
VL-FILENAME-DIRECTORY
Returns the directory path of a file, after stripping out the name and extension.
(vl-filename-directory filename)
Arguments : filename
A string containing a complete file name, including the path. The vl-filename-directory
function does not check to see if the specified file exists. Slashes (/) and backslashes (\)
are accepted as directory delimiters.
Return Values :
A string containing the directory portion of filename, in uppercase.
Example
_$ (vl-filename-directory "c:\\lisp\\lispfile.lsp")
"C:\\LISP"
And a couple more just for interest sake :
VL-FILENAME-BASE
Returns the name of a file, after stripping out the directory path and extension.
(vl-filename-base filename)
Arguments : filename
A string containing a file name. The vl-filename-base function does not check to see if
the file exists.
Return Values :
A string containing filename in uppercase, with any directory and extension stripped
from the name.
Examples
_$ (vl-filename-base "c:\\acadwin\\acad.exe")
"ACAD"
_$ (vl-filename-base "c:\\acadwin")
"ACADWIN"
VL-FILENAME-EXTENSION
Returns the extension from a file name, after stripping out the rest of the name.
(vl-filename-extension filename)
Arguments : filename
A string containing a file name, including the extension. The vl-filename-extension
function does not check to see if the specified file exists.
Return Values :
A string containing the extension of filename. The returned string starts with a period (.)
and is in uppercase. If filename does not contain an extension, vl-filename-extension
returns nil.
Examples
_$ (vl-filename-extension "c:\\acadwin\\acad.exe")
".EXE"
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (4 of 10) [23/03/2005 05:50:07 p.m.]
_$ (vl-filename-extension "c:\\acadwin\\acad")
nil
--------------------------------------
Howdy Kenny et all,
I dont know much about the 'Registry' and I noticed that you had a lisp in this weeks
newsletter regarding accessing it and etc. My question is simply: "What exactly is the
Registry and where do I find it?" Any info at all concerning this area would be
appreciated as I am not familiar with it in any way at all. I realise its probably more a
general computer question than an Autocad question but I'd really like to know anyway.
A lighter note :
What do you call a skeleton in the closet with blonde hair??
Last years Hide n' Seek winner. heh heh..!
Til next time its fare thee well from Oz.....
Pete
---------
Pete,
The registry is used by applications and Windows to store configuration data. It is a
replacement for the large numbers of .ini files that proliferate on Windows 3.x machines,
and is also used heavily by OLE.
Windows 3.1 used initialization (INI) files to store system-specific or application-specific
information on the state or configuration of the system. For example, the WIN.INI file
stored information about the appearance of the Windows environment, the SYSTEM.INI
file stored system-specific information on the hardware and device driver configuration
of the system, and various INI files (such as MSMAIL.INI and WINWORD6.INI) stored
application-specific information.
The Registry remedies this situation by providing a single location for a computer's
configuration information.
The registry is organized using a hierarchical series of keys and values resembling a
tree. Each key, beginning with one of the six predefined root keys, can have subkeys and
values associated with it.
You can access the Registry by choosing "Start" then "Run".
Enter "REGEDIT" into the "Open" text box and then select "OK".
Now open the "HKEY_CURRENT_USER" folder (root key).
Next open the "Software" folder (subkey).
You should find a folder entitled "Autodesk".
Keep on drilling down. You will find a treasure trove.
This will be one subject that I will be looking at in more detail in "Out of the Nutshell".
****WARNING***
Editing the Registry incorrectly can cause serious problems that may require you to
reinstall your operating system. BEFORE you attempt to edit the registry, make sure you
understand how to restore it if a problem occurs. You have been warned!!!!
--------------------------
Hello Kenny, long time no write. I have noticed that your newsletter is back and running
after along period of "no-letter". Oh well.
I have a question that will make you think a wee bit. You can call it a 3 beer question.
That is you can take up to 3 beers to find an answer. If by then you don't know the
answer, then you can have another 3.
Ok, here goes. I wrote a lisp that analyzes drawing files. You run the lisp and at the end it
tells you how many layers and names in a drawing. How many entities in each layer. How
many block names and instances of each.
In summary, it gives all relevant information of what is in the drawing.
Now what it is missing is SHAPES. And the question is: how do you query for shapes. Is
there a SHAPE table, like BLOCKS and LAYERS?
Thanks Kenny.
Ramn Castro
-------------------------
I have noticed that when you open a drawing that was saved in R14 that you get a
message stating that you are opening an early release saved drawing. you also get the
message when you do your work in LD3 and then save it to R14 format. I have found that
be typing in "EXPERT" at the command line you can this from happening. The only
problem is that when you exit out and then restart AutoCAD that it defaults back to "0".
Does any one know of a way to changes this so that the dialoge box come up?? Please
let me know. We have to
save it in R14, because we still have some Architects in my firm using R14, and they do
not want to change.
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (5 of 10) [23/03/2005 05:50:07 p.m.]
Thanks
Brian
--------------------------
The Answers
--------------------------
One of your readers asked about a attribute extract program
Here is one for you.
Have a great day
Peter Jamtgaard
----------------------------
;CODING STARTS HERE
(defun C:Get_Attributes (/ ATTLIST ELST ENT ETYP )
(setq ENT (car (entsel "\nSelect block: "))
ELST (entget ENT)
ETYP (cdr (assoc 0 ELST))
)
(if (= ETYP "INSERT")
(if (assoc 66 ELST)
(princ (setq ATTLIST (atts_to_list ENT)))
(princ "\nThat block doesn't have attributes: ")
)
(princ "\nThat is not a block! ")
)
(prin1)
)
(defun ATTS_TO_LIST (ENAM)
(setq X (vlax-ename->vla-object ENAM))
(if (= (cdr (assoc 66 (entget ENAM))) 1)
(progn
(mapcar '(lambda (X) (cons (vla-get-tagstring X)
(vla-get-textstring X)
)
)
(vlax-safearray->list
(variant-value
(vla-getattributes
(vlax-ename->vla-object ENAM)
)
)
)
)
)
)
)
;CODING ENDS HERE
-----------------------------------
Hi Kenny
Re: My problem is with the creation of the slides.
The following info on slide creation is from the AutoCAD 2002 Online Help File -
You can use any slide generated by AutoCAD as an image. However, the optimal use of
Image tile menus requires that you take care in preparing slides that will serve as
images.
Follow these guidelines :
Keep it simple. When an Image tile menu is displayed, the user must wait for all images
to be drawn before making a selection. If you are using the Image tile menu to show the
user numerous complex symbols, make the images simple versions of the symbols
rather than full renditions. An image should be as simple as possible and yet
immediately recognizable. Fill the box. Screen space is limited, and images appear in
small portions of the full screen. When making a slide for an image, be sure to fill the
screen with the image before entering the MSLIDE command. If the image is very wide
and short, or long and thin, the Image tile menu will look best if you center the image on
the screen with the PAN command before making the slide.
Images are displayed with an aspect ratio of 3:2 (3 units wide by 2 units high). If your
drawing area has a different aspect ratio, it can be difficult to produce image slides that
are centered in the Image tile menu. If you work within a floating viewport that has an
aspect ratio of 3:2, you can position the image and be assured that it will look the same
when it is displayed in the Image tile menu.
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (6 of 10) [23/03/2005 05:50:07 p.m.]
Solid-filled areas such as wide polylines, traces, and filled solids are visible in Image
tiles only if the slide was generated after issuing the -SHADE command. Otherwise, they
display as outlines. Do not overuse images as you encode abstract concepts into
symbols.
First Kenny in Space?
Mike
----------------------------
Some nice AutoLisp files :
http://autolisp.3utilities.com/
--------------------------
Kenny
Back in Newsletter 2001-13, you gave us the code to delete objects by double-clicking on
them. You mentioned that one could use this method to double-click on text to open the
text edit box - just what AutoCAD 2000 users want! I know nothing about reactors or vla
commands but (don't ask me how) I put the following code together and it seems to work
just fine! I load the code in the 'Startup Suite' and it works pretty much like double
clicking on text in 2000i. (I cant believe it!)
;CODING STARTS HERE
(vl-load-com)
;------------
(vlr-mouse-reactor "Edit text Object" '((:vlr-beginDoubleClick . DC-Edit)))
(defun DC-Edit (theReactor thePoint / app doc)
(setq app (vlax-get-acad-object)
doc (vla-get-activedocument app)
)
(vla-sendcommand doc "ddedit ")
(princ)
)
;CODING ENDS HERE
Any comments or suggested improvements?
Regards
Craig Green
------------------------
I think Craig deserves a big round of applause for this one.
Just one comment! Try double-clicking on a non-text object!!!!
---------------------------
I don't normally do this, but a friend of mine is out of work and this is the last issue.
So, over to you Larry :
Hello,
This morning while getting ready for the day, I realized the solution for problems some of
your readers are facing in their programming department.
They don't really want an Applications Programmer; They want an increase in sales,
reduction in implementation time as well as a reduction in customer complaints about
their product.
Now, I am not some "Developer Cowboy" with an itchy trigger finger. I have
"sleeves-rolled-up" programming skills that will help your readers in their pursuit to:
1. Increase their customer satisfaction.
2. Improve customer service relations.
3. Reduce implementation time and costs.
4. Reduce redundancies that lead to "spaghetti" code.
More importantly, I understand that they are in business to MAKE MONEY and I will help
them do that as well as help get more customers, sell them more and bring them back for
more.
I have worked with some very switched on operators and have copied and emulated
many of the ideas and strategies they use to run successful, service oriented, profit
driven software companies.
I realize that a good applications developer does more than write code to accomplish a
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (7 of 10) [23/03/2005 05:50:07 p.m.]
given task, they are the face of your customers business, and that is a very big
responsibility.
Honestly, do your readers want just another coder, or someone who has the people
skills as well as the logic skills born at the gate level to get the job done.
Would they rather have the next version of their product actually contain new features
rather than "bug fixes"?
If any of your readers are looking for a applications developer who is sales and service
focused and can write tight, error free, well tested code, I would love to hear from them.
If they can afford to pay me for doing all of the above, well then that would be nice too.
Yours Truly,
Larry Hooven.
EXPERIENCE
Design and Production
Designed, developed and programmed applications to generate bills of materials from
AutoCAD drawings automatically.
Wrote modular code and DLL's for functionality of client software product using Visual
Basic 6 and MSSQL.
Developed innovative solutions to nonstandard manufacturing problems using both
software and hardware.
Designed, wrote, and deployed project tracking software that reduced mis-shipped parts
by 70%
Created a successful product failure tracking system using Paradox database engine 5
and Delphi.
Researched and recommended changes in products based on customer feedback.
Designed and directed engineering and technical personnel in fabrication of testing and
test control apparatus and equipment.
Designed, constructed, programmed, tested and implemented automated equipment that
resulted in 300 percent increase in productivity on average.
Part of a development team responsible for writing codes for timing and scoring of CART
Indy cars.
SPECIAL SKILLS
Proficient in Visual basic, JavaScript Proficient in MS Access, pervasive.SQL, MSSQL
and Paradox databases.
I know my way around ADO.
Experienced in PASCAL, FORTRAN, DELPHI, R-Base, DBII, Basic, Dreamweaver4 and
FORTH.
Experienced in all phases of production, including design, customer service, product
testing and evaluation.
Excellent Database normalization skills.
Excellent ladder logic and PLC programming skills.
Contact Details :
Larry Hooven
P.O. BOX 94,
NORCO, CA 92860
PHONE 909-734-0609
mailto:dirty_howi@yahoo.com
---------------------------
The Back Stoep
---------------------------
For years, it has been believed that electric bulbs emit light, but recent investigation has
proven otherwise. Electric bulbs don't emit light; they suck dark. Thus, we call these
bulbs Dark Suckers.
Studying the Dark Sucker Theory and the characteristics of dark suckers has proven that
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (8 of 10) [23/03/2005 05:50:07 p.m.]
dark has significant mass and is heavier and faster than light.
First, the basis of the Dark Sucker Theory is that electric bulbs suck dark.
For example, consider the Dark Sucker in the room you are in. There is much less dark
near it than there is further away. Larger Dark Suckers are capable of sucking more dark
than smaller ones. Dark Suckers in the parking lot have a much greater capacity to suck
dark than the ones in this room.
As with all things, Dark Suckers don't last forever. Once they are full of dark, they can no
longer suck. This fact is clearly indicated by the dark spot that often appears on a full
Dark Sucker.
A candle is a primitive Dark Sucker. A new candle has a white wick. You can see that
after the first use, the wick turns black. This black is the residue of all the dark that has
been sucked into it. If you put a pencil next to the wick of an operating candle, it will turn
black. This is because the pencil got in the way of the dark flowing into the candle. One
of the disadvantages of these primitive Dark Suckers is their limited range.
There are also portable Dark Suckers. In these, the bulbs can't handle all the dark by
themselves and must be aided by a Dark Storage Unit. When the Dark Storage Unit is
full, it must be either emptied or replaced before the portable Dark Sucker can operate
again.
Dark has been shown to have mass. When dark goes into a Dark Sucker,
friction from the mass causes heat. Thus, touching an operating Dark Sucker is not
advised. Candles present a special problem, as the mass must travel into a solid wick
instead of through clear glass. This generates a greater amount of heat and therefore it's
more dangerous to touch an operating
candle. Also, dark is heavier than light. If you were to swim just below the surface of a
lake, you would see a great amount of light. If you were to slowly swim deeper and
deeper, you would notice it getting darker and darker. When you get to some great
depth, you would be in total darkness. This is because the heavier dark sinks to the
bottom of the lake and the lighter light floats at the top. This is why it is called light.
Finally, we can prove that dark travels faster than light. If you were to stand in a lit room
in front of a closed, dark closet, and slowly opened the door, you would see the light
slowly enter the closet. But since dark is so fast, you would not be able to see it escape.
Cosmologists now believe that most of the mass in the universe is Dark Matter.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
If you enjoy superb music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
To subscribe to this Newsletter,
go to the AfraLisp main page :
http://www.afralisp.com
enter your e-mail address and press the button.
----------------------------------------------------------
----------------------
To unsubscribe from the AfraLisp Newsletter, clink on this link :
http://www.yourmailinglistprovider.com/unsubscribe.php?afralisp+kenny@mweb.com.na
We will then hunt you down and make you change your mind.
-----------------------
This newsletter is hosted by :
http://www.yourmailinglistprovider.com
-----------------------
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (9 of 10) [23/03/2005 05:50:07 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2002-17
http://www.afralisp.com/newsletter/2002/2002-17.htm (10 of 10) [23/03/2005 05:50:07 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, September 16, 2001 14:58
AfraLisp Newsletter No 2001-01
AfraLisp : http://afralisp.hypermart.net
=====================================
Hello and Welcome.....
Short and sweet, eh?
No, I'm not lazy, (not very) but how else do you start off a
newsletter that you haven't produced for over a year?
I suppose I should begin by explaining what I've been doing for the
last 12 months!!
Easy.......I was practicing to become a "Rock Star." (Don't believe
me? Check out this site : http://kramage.tripod.com)
O.K. I promise, no more plugs for my new CD "Recovery"
available at :
http://kramage.tripod.com
and currently at No 14 on the South African Charts.
Enough Kenny!!!
Sorry......
Right, we've got that over with so now onto something completely
indifferent.
THE FORMAT OF THIS LETTER!!!!
Here is where I need your help.
I would like/hope/wish this letter to be an open forum where "us"
people who are interested in AutoCAD/AutoLisp/Visual
Lisp/VBA/VB, etc, can write in with problems, solutions,
annoyances, gimmicks, etc, etc, and hopefully, receive some
constructive feedback.
I will try to help the best I can, but I really need "YOU", "YES
YOU", (don't look away,) to share with all the other readers of this
letter the pearls and fruits of your vast wisdom and experience.
This letter will concentrate more on AutoLisp and Visual Lisp
rather that VBA. The one reason being, is that I know what I'm
doing with AutoLisp (I think) and the second being that Randall
Raath is too bloody good at VBA/VB. (I had to say that as he'd
threatened to de-tune my guitar at my next gig if I said something
within the negative. He also now owes me 2 beers for being nice to
him.)
That aside, I do take great pleasure in proving to Randall that an
ancient and arcane language such as AutoLisp can still do lot's of
things that VBA/VB cannot do!!!! And, I don't need a VB interface
to programme, just Notepad or even DOS Edit. Hey Randall, some
AfraLisp Newsletter No 2001-01
http://www.afralisp.com/newsletter/2001/2001-01.htm (1 of 3) [23/03/2005 05:50:08 p.m.]
of my stuff will even work on R10. (How's that for fighting talk?)
Anyway, down to business. (as the actress said to the Bishop.)
The letter will be split into certain distinct sections, most of which
will require contributions from yourself and every other reader to
make them work :
The Front Stoep.
This is the front veranda (stoep is the African word for veranda,)
where I sprout off about anything that catches my fancy, normally
whilst indulging in a nice cold beer.
The Site.
http://afralisp.hypermart.net
This is where I let you know what has been added or changed on
AfraLisp.
At the moment, I'm busy with a major upgrade and plan to make it
a much more interactive site.
Don't worry, the tutorials will not only stay, but lot's more will be
added within the near future.
(If I've got to learn Visual Lisp, you might as well learn with me.)
The Questions.
This bit you fill in. Send your questions to me at
mailto:kenny@mweb.com.na and if I can't answer, I'm sure some
kind reader will help you out. (I even put questions in here.)
The Answers.
I fill in what I can, the rest you do. Send answers to
mailto:kenny@mweb.com.na
The Back Stoep.
Here, I do anything that catches my fancy that I forgot to mention
earlier whilst indulging in my 3rd beer.
The Credits.
The bit at the bottom that nobody ever reads unless they want to
un-subscribe.
Right. You've got the idea!!!! So, what are you waiting for?
Send in the e-mails and I look forward to speaking to you all next
week............
Cheers,
Kenny Ramage Q.B.E.
=====================================
AfraLisp : http://afralisp.hypermart.net
=====================================
To unsubscribe send e-mail to
mailto:kenny@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
=====================================
To subscribe to AfraLisp send e-mail to
AfraLisp Newsletter No 2001-01
http://www.afralisp.com/newsletter/2001/2001-01.htm (2 of 3) [23/03/2005 05:50:08 p.m.]
mailto:kenny@mweb.com.na
with "Subscribe" in the Subject Line.
=====================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
=====================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C. (or even your life for that matter.)
==========================================
Bye.
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-01
http://www.afralisp.com/newsletter/2001/2001-01.htm (3 of 3) [23/03/2005 05:50:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, September 22, 2001 12:32
AfraLisp Newsletter No 2001-02
AfraLisp : http://afralisp.hypermart.net
=====================================
The Front Stoep
Instead of working, I'm sitting here contemplating my belly button whilst drinking beer. Why,
you might ask? Simple. I'm surrounded by a vast mountain of pamphlets, photo copies and
technical manuals ranging from VB6 to Visual Lisp to "How to record a set of drums so that
the punters think it's Bon Jovi and not some little garage band." You see, I'm trying to catch
up with all of the developments that have gone on in the AutoCAD programming world over
the past year.
But, don't worry, I'm getting there. I'm slowly plodding my way along and really quite
enjoying myself. A lot of the hard work in sussing out how these languages can co-exist with
AutoCAD has already been done by people like Randall Raath, Frank Zanders and others. All
I have to do now is to work out how to present it in such a way that they don't realise where I
stole it from. (hee, hee.)
Please note, that if you are receiving these letters twice, please let me know as I'm trying to
update my old mailing list with new subscriptions coming in all the time. In other words, I get
a bit confused!!! (and that is not difficult for me.)
The Site
AfraLisp is still under major re-construction but new sections should be
posted within the next week or two. (time, time, time.....) To keep you happy
here's a couple of handy tricks.......
Have you had a good look at the Express Tools yet? Under the Text sub-menu there
is a little gem of a routine called "Rtext." Using this application you can
insert Diesel expressions anywhere in your drawing. This is great for Plot
Stamps and much easier to setup and maintain than other Plot Stamp
applications. Just insert it into your template drawings and away you go.
Here's the one that I use :
Date Plotted : $(edtime, 0, Mon DD"," YYYY - H:MMam/pm)
Plotted By : $(upper, $(getvar, "loginname"))
This "stamps" the Plotted Date and Time as well as the users Login name.
Check out the "Rtext" help for more details and more uses.
==================================================================
Can anybody remember the Acad.lsp file? Now that there are MNL files and Acaddoc.Lsp,
Acad.Lsp would seem to be redundant. Well not really. The Acad.Lsp file is great for ensuring
that partial menu's are loaded.
So, want to ensure your custom menu/menu's, including pulldowns, are loaded
everytime AutoCAD is opened? Copy and paste this into your Acad.Lsp file
substituting your menu name where applicable :
;;;Start Coding Here
(defun MYSTARTUP ( );;;replace this line with the following if you are using R2000
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (1 of 9) [23/03/2005 05:50:09 p.m.]
;;;(defun-q MYSTARTUP ( )
;first set the flag
(setq flag1 T)
;check for the existence of the menu
(setq loaded (menugroup "MYMENU"))
;if it's not loaded
(if (= loaded nil)
;do the following
(progn
;find the menu
(setq temp (findfile "MYMENU.MNU"))
;if you find it
(if temp
;do the following
(progn
;suppress dialogues
(setvar "FILEDIA" 0)
;load the menu
(command "menuload" "MYMENU")
;un-suppress dialogues
(setvar "FILEDIA" 1)
;load the first pulldown
(menucmd "P11=+MYMENU.POP1")
;load the second
(menucmd "P12=+MYMENU.POP2")
;tell them what you are doing
(prompt "\nLoading MyMenu Custom Utilities....\n")
);progn
;if you cannot find the menu, do this
(progn
;tell the it's missing
(alert "Cannot Locate MyMenu Menu. \n
Blame Randall Raath.")
;clear the flag
(setq flag1 nil)
);progn
);if
);progn
);if
;if the flag is set
(if flag1
;inform the user
(prompt "\nMyMenu Custom Utilities Loaded....\n")
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (2 of 9) [23/03/2005 05:50:09 p.m.]
);if
;finish clean
(princ)
);defun
;append your startup function to any other startup function
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
;;;End Coding Here
Please ensure that all "MYMENU" menu files are in your AutoCAD search path.
=======================================================================
The following will give you a list of all entries in a symbol table. This is
great for creating a list to populate a list box in DCL.
;;;Start Coding Here
(defun tablelist (s / d r)
(while
(setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
);while
);defun
;;;End Coding Here
For example, if you would like a list of all layers in a specific drawing,
use this :
(setq all_layers (tablelist "LAYER"))
AutoLisp should return something like this :
("7" "6" "5" "4" "3" "2" "0")
To populate a list box with the key of "selections," use this :
(start_list "selections")
(mapcar 'add_list all_layers)
====================================================================
The Questions
And the first question in this newsletter is from Antonio Pellegrino :
I read your report "Application data" of Afralisp.com.
I download the routines c:test8 and register that work very fine to control
the number of runs of an application by 'setcfg' and 'getcfg' that write and
read the file acad.cfg.
This approach is not very safe if I want distribute my demo-application for
valuation to potential users because the file acad.cfg is a ASCII file that
can be read and write by users in a very easy way.
I thinked to Autolisp files but also them are ASCII files. There's a way to
write informations in place very hard to read and write by users?
Thank you for the answer.
By Antonio Pellegrino.
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (3 of 9) [23/03/2005 05:50:09 p.m.]
mailto:st150847@tiscalinet.it
This was always a problem with earlier releases of AutoCAD. There was, and still probably
are, a couple of applications floating around that "protected" your source coding.
Unfortunately, these applications were cracked days before they were ever released. With the
release of Visual Lisp though, and the ability to compile your applications, things have
changed. Visual Lisp also gives you access to the Windows registry. This may not be a
foolproof way of storing this type of demo data, but most amateurs think twice before messing
with the registry. VBA , of course is also another solution. You didn't mention what release of
AutoCAD you are working with, but my advice would be to upgrade if you are using one of the
earlier releases and are serious about protecting your work.
============================================================
I got a question...
How do you set dwgprops using lisp???
Thanx
Dan
mailto:landrum@miller-engineering.com
I don't know but would love to!! Can anybody out there help?
=============================================================
Is there a batch converter for converting old AutoCad drawings to AutoCad
2000? If so where can I find it.
Thanks
Darrell Trent
Peabody Energy
St. Louis, Mo
314-342-7636
mailto:dttrent@peabodyenergy.com
Darrell,check out http://afralisp.hypermart.net/lisp59.htm
This is a tutorial on creating batch slides but you should be able to modify the coding to do
want you want. (Hint: Just open the drawing in 2000 then save it.) If you get stuck give me a
yell and I'll send you the coding.
================================================================
Anybody know the latest method of loading and unloading a VBA application using AutoLisp?
Kenny
mailto:kenny@mweb.com.na
================================================================
The next contribution is stolen from Frank Zander with his blessing.
Contract CADD Group
http://www.contractcaddgroup.com
This application is the perfect example of how something so simple can be so powerful.
My immediate reaction on reading this article and then running the coding was, "Why didn't I
think of that?"
I implemented it into my office so quickly you wouldn't believe it.
Using VBA in AutoCAD R14 / 2000 to Control Layer Standards.- Frank Zanders
Introduction
Have you ever wondered why drawings can contain many layers, but objects such as "text",
"dimensions" and "hatch" do not always end up on the correct layers? This article addresses
a potential solution to that problem. First, I talk briefly about layer standards and show you
how to create a small VBA project for AutoCAD r14.01 or 2000 to control layers.
Layer Standards
Several times in the past, I have been asked by new users, "Why doesn't AutoCAD put text
objects on the text layer and hatch objects on a hatch layer, etc?" The answer is that Autodesk
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (4 of 9) [23/03/2005 05:50:09 p.m.]
has designed AutoCAD to give users unrestricted flexibility with layer names and to allow
companies to create or adopt any layer standard. Unfortunately, this flexibility of
open-architecture layer names within AutoCAD has allowed many an AutoCAD user to
recklessly create layer names. Sometimes, it seems, layer names are chosen according to what
pops into the user's head while staring at the AutoCAD layer dialogue box! And after several
other users in the same company use these layer names, the results are then called the
"company layer standards".
There are many recognized layer standards in existence, such as AIA, Master Format, British
BSD, etc. that companies can adopt, but it seems to be more trendy for companies to make up
their own layer names and standards on the fly. The rationale seems to be "Those other
existing layer standards could not possibly accommodate the type of work that our company
does. " How many times have you come across a drawing (done by someone else, of course)
containing layers called dim, dimension, and dimensions? The purpose of this small VBA
project is to create a mini layer-manager that enforces layers for "text", "hatch" and
"dimension" objects as they are created in a drawing. Text goes on to a layer called "text",
hatch patterns are placed on a layer called "hatch", and dimensions are placed on a layer
called "dim". Seems almost too obvious! Sure, this is a rather simplistic way of managing
layers for objects, but it works! For those interested in modifying the code to fit your own
company layer standard or for working with multiple disciplines, take a look at the section
called "Extending the Code" later in the article.
I was recently exposed to the "AcadDocument_BeginCommand" sub-program when I began a
technical review for WROX press of a book called AutoCAD - VBA Programmers Reference
(currently being written by Joe Sutphin). Joe's example code made me think, "Wow! I could
apply his technique to do some layer management of my own!" In the program outlined in this
article, I access this sub-program to check on the command being accessed by AutoCAD. Once
the command being used is checked, it creates the appropriate layer settings before AutoCAD
starts the command. Therefore, when a user enters the text command, my VBA program
sets-up and/or creates the text layer, transparently in the background, before the text
command starts. The sub-program "AcadDocument_BeginCommand" picks up on AutoCAD
commands used in LISP programs and any alias (defined in the ACAD.pgp) that references an
AutoCAD command. For example, if a user types "BH" (standard short cut alias for the
"bhatch" command), the sub-program "AcadDocument_BeginCommand" still traps the
"bhatch" command.
The compliment to the "AcadDocument_BeginCommand" sub-program is the sub-program
"AcadDocument_EndCommand". I use the latter sub-program to check for the name of the
command that has just been completed. If the command name matches my criteria (using the
"select case" method), the layer is set back to the original layer in use before the command was
started. Look at the following commented code to see if you can follow what is happening
inside the VBA program. Start with the "AcadDocument_BeginCommand" sub-program and
finish with the "AcadDocument_EndCommand" sub-program.
A Look at the Code
'<---Coding Starts Here
' Using Option Explicit -- you must explicitly declare all variables using the
' Dim, Private, Public, ReDim, or Static statements.
' If you attempt to use an undeclared variable name,
' an error occurs at compile time.
' Option Explicit is a great way to make sure you do not have wonkie typo mistakes
' in your code.
Option Explicit
' set the public object current Layer to be an AutoCAD Layer
Public objCurrentLayer As AcadLayer
' set the public object Previous Layer to be an AutoCAD Layer
Public objPreviousLayer As AcadLayer
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
' Save the current / active AutoCAD layer
Set objPreviousLayer = ThisDrawing.ActiveLayer
' Check for the folowing cases of the AutoCAD command.
Select Case CommandName
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (5 of 9) [23/03/2005 05:50:09 p.m.]
' Check the AutoCAD command,
' is there a match for TEXT, MTEXT, or DTEXT
Case "TEXT", "MTEXT", "DTEXT" ' then do the following..
' check for to see if the current layer is Text
' if the current layer is not TEXT then set up the TEXT
' layer for use.
If Not ThisDrawing.ActiveLayer.Name = "TEXT" Then
' set up the TEXT layer
' this layer will be created if it does not exist
Set objCurrentLayer = ThisDrawing.Layers.Add("TEXT")
' make the TEXT layer blue
objCurrentLayer.Color = acBlue
' turn the TEXT layer ON
objCurrentLayer.LayerOn = True
' Thaw the TEXT layer
objCurrentLayer.Freeze = False
' Unlock the TEXT layer
objCurrentLayer.Lock = False
' Make the TEXT layer the current
' active layer in this drawing.
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for TEXT being the current layer.
End If
' Check the AutoCAD command,
' is there a match for HATCH, or the BHATCH command.
Case "HATCH", "BHATCH"
' check for to see if the current layer is HATCH
' if the current layer is not HATCH then set up the HATCH
' layer for use.
If Not ThisDrawing.ActiveLayer.Name = "HATCH" Then
' set up the HATCH layer
Set objCurrentLayer = ThisDrawing.Layers.Add("HATCH")
' make the HATCH layer red
objCurrentLayer.Color = acRed
' turn the HATCH layer ON
objCurrentLayer.LayerOn = True
' Thaw the HATCH layer
objCurrentLayer.Freeze = False
' Unlock the HATCH layer
objCurrentLayer.Lock = False
' Make the HATCH layer the current
' active layer in this drawing.
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for HATCH being the current layer.
End If
' check for AutoCAD dimension commands..
Case "DIMALIGNED", "DIMANGULAR", "DIMCENTER", _
"DIMCONTINUE", "DIMDIAMETER", "DIMLINEAR", "LEADER", _
"DIMORDINATE", "DIMRADIUS", "DIM", "DIM1"
If Not ThisDrawing.ActiveLayer.Name = "DIM" Then
Set objCurrentLayer = ThisDrawing.Layers.Add("DIM")
objCurrentLayer.Color = 140
objCurrentLayer.LayerOn = True
objCurrentLayer.Freeze = False
objCurrentLayer.Lock = False
ThisDrawing.ActiveLayer = objCurrentLayer
' end of if checking for DIM being the current layer.
End If
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (6 of 9) [23/03/2005 05:50:09 p.m.]
' end of the Select
End Select
' end of Private Sub AcadDocument_BeginCommand
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
' Check for the folowing cases of the AutoCAD command that has just ended.
Select Case CommandName
' check for a match on the following AutoCAD commands
Case "HATCH", "BHATCH", "MTEXT", "TEXT", "DTEXT", _
"DIMALIGNED", "DIMANGULAR", "DIMCENTER", _
"DIMCONTINUE", "DIMDIAMETER", "DIMLINEAR", "LEADER", _
"DIMORDINATE", "DIMRADIUS", "DIM", "DIM1"
' make the current active AutoCAD layer the previously saved layer.
ThisDrawing.ActiveLayer = objPreviousLayer
' clear the objCurrentLayer
Set objPreviousLayer = Nothing
End Select
' clear the objCurrentLayer
Set objCurrentLayer = Nothing
' end Private Sub AcadDocument_EndCommand
End Sub
'Coding Ends Here-->
=======================================================
Change the layer names to suit your own then place the coding into a module in "This
Drawing." Then add it to your Startup Suite. I tell you, brilliant. Thanks again Frank.
=======================================================
The Back Stoep
A number of people have asked why I do this? Here's one reason :
Dear Mr. Ramage,
We are two boys on a technical orientated school in the South-Western part of
Germany.
For our graduation next summer we have to do a "special" work.
Our teacher told us that there is no user's manual in German for this programme
like you have put on in English on the website
http://afralisp.hypermart.net/tutor.htm.
Because of the fact that we both have Advanced Course English he asked us to
translate your manual into German and put it on a website.
We would appreciate it, if you could give us the permission to translate your
manual from English into German.
Please answer as soon as you can; if it is possible until Thursday, because we
have a meeting on Friday with our teacher and he wants to give us further
instructions.
If we do not get your permission - we do not hope so - he will give us another -
maybe bad - work.
We would be very proud to translate the your manual into German, so please let
us know what is going on.
Sincerely
Markus & Lars
Would you give them permission?
========================================================
A couple of great informative and helpful AutoLisp/VBA sites :
VB Design
http://www.vbdesign.net/
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (7 of 9) [23/03/2005 05:50:09 p.m.]
Contract CADD Group
http://www.contractcaddgroup.com
AcadX.Com
http://www.acadx.com
Reini Urban
http://xarch.tu-graz.at/autocad
======================================================
Did you hear of the Irish town of Ballybutton?
It's a Naval Base.............
And I'd like to leave on this note :
C#
(That's "C sharp" for the musically illiterate amongst you.)
Cheers,
Kenny Ramage Q.B.E.
=====================================
AfraLisp : http://afralisp.hypermart.net
=====================================
To unsubscribe send e-mail to
mailto:kenny@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
=====================================
To subscribe to AfraLisp send e-mail to
mailto:kenny@mweb.com.na
with "Subscribe" in the Subject Line.
=====================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
=====================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
==========================================
Bye.
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (8 of 9) [23/03/2005 05:50:09 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-02
http://www.afralisp.com/newsletter/2001/2001-02.htm (9 of 9) [23/03/2005 05:50:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, September 30, 2001 6:36
AfraLisp Newsletter No 2001-03
AfraLisp
URL : http://www.afralisp.com
E-mail : mailto:afralisp@mweb.com.na
=====================================
The Front Stoep
So, have you been to AfraLisp's new home yet? Nice hey! Just wait, I've got lot's of new content in
the pipeline and lot's of space to do it with. Again, a big thank you to Frank Zander (Contract
CADD Group - http://www.contractcaddgroup.com) for his generous help in making this possible.
I mentioned last week that if you were receiving multiple copies of this newsletter then you must
please let me know. Well conversely, if you are not receiving the newsletter, you must also let me
know!!!
But, I digress. Have we got some goodies for you this week?
Curious? then read on.......
The Site
I've posted a couple of new items on AfraLisp. One is a tutorial on "Automating Menu Loading."
You can find this at http://www.afralisp.com/menuload.htm
The second one I'm not going to say anything about at the moment. You'll find out all about it
later on in the letter.
As the pickings on the website are a bit slender this week because AfraLisp is still under
reconstruction, (or should it be "destruction?" as Randall Raath would say) a couple of more code
snippets for you to play with :
Want to repeat a command indefinitely using AutoLisp?
Try this :
;;;<--Coding starts here
(defun c:test ()
(prompt "\nSpecify first point: ")
(command "_LINE")
(while
(= 1 (logand (getvar "CMDACTIVE") 1))
(command PAUSE)
(prompt "\nSpecify next point: ")
);while
;;;Now you can carry on with rest of your programme
(alert "\nLine command is complete.")
(princ)
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (1 of 7) [23/03/2005 05:50:11 p.m.]
);defun
;;;Coding ends here-->
And here's another bit of coding that draws a never ending leader line :
;;;<--Coding starts here
(defun c:test1 ( / pt1 pt2 pt3)
(setq pt1 (getpoint "\nSpecify first point: "))
(setq pt2 (getpoint "\nSpecify next point: "))
(setq pt3 (polar pt1 (angle pt1 pt2) 3.5))
(command "_PLINE" pt1 "W" "0" 5.0 pt3 "W" "0" "0" pt2)
(while
(setq pt2 (getpoint "\nTo point: " pt2))
(command pt2)
);while
(command "")
;;;Now you can carry on with rest of your programme
(alert "\nLeader Line command is complete.")
(princ)
);defun
;;;Coding ends here-->
====================================================================
The Questions
Hello Kenny,
Just having another look over your site today after you sent out the new
newsletter, and was having a look at the section "Creating a Toolbar DLL."
http://afralisp.com/vba15.htm
I came across a great web site a while ago which offers a Resource compiler
which I use to create toolbar dll's and its FREE. I thought this might be
useful to people who don't have VB6. The link is below.
http://rpi.net.au/~ajohnson/resourcehacker/
BTW, I have no affiliation with the site, I'm just trying to contribute
something to the CAD community.
Regards,
Chad.
mailto:plogic@ozlinx.com.au
Thanks Chad, you're a star....
I downloaded this application, it's called "Resource Hacker," and believe me it really works. It's
quite small (533Kb zipped) and reasonably easy to use. The only problem comes when you want to
create a new DLL file. As the author was not kind enough to provide an empty one for us to use, I
just took an existing one, deleted the bitmaps I didn't require and added the ones I did. I am trying
to contact the author to ask him for permission to include this on AfraLisp. If he grants my wish,
I'll post an empty DLL for you to use.
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (2 of 7) [23/03/2005 05:50:11 p.m.]
Breaking News.
You can find a tutorial explaining everything you need to know about this application in regards to
creating Toolbar DLL's, and links to the download sites at : http://www.afralisp.com/vbadll.htm
See, I have been busy!!!
=========================================================================
Afternoon
I have a question for you. I am using ACAD2000i.
How can I determine if lines are duplicate or fragmented lines contained
in that line (lines that are over lines) so they can removed from the
drawing?
I just need a code fragment or where to start from or look for. The code
fragment could be in lisp or vba.
Thank for any help
Tom
mailto:turtlepets@aol.com
=============================================================
Re: Using VBA in AutoCAD R14 / 2000 to Control Layer Standards.
Frank Zanders
I have a question on this VBA tool from Frank.
He traps certain AutoCAD commands and sets certain layers current.
My question is, Is there a way to trap a lisp command and have it
change layers the same way. Reason is because some lisp routines
I have are encoded so I can't edit the routine to change layers so I'm
trying to find another way of doing it, and this would be great.
Thank you
Darek D. Watson
mailto:darekw@zfa.com
Darek, one possible solution.
Create a new lisp file that changes to the desired layer first, calls the
encoded lisp routine as a sub-routine, and then changes the layer back.
=================================================================
Answers
And the question in question was :
"How do you set dwgprops using AutoLisp?"
And the beginning of the answer is :
"You want to modify the Revision Number field on the Statistic tab of the
Drawing Properties dialog box do you?
This field is used by revision control or other drawing management software.
There is no simple method for editing this field. However, you can use the
following AutoLISP function to update this field.
Note: You must save the drawing prior to updating its revision number with
the following sample routine."
;;;;
;;;;Beginning of the AutoLISP routine
;;;
(defun add-record (/ Xrec Xname)
(setq Xrec '((0 . "XRECORD")
(100 . "AcDbXrecord")
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (3 of 7) [23/03/2005 05:50:11 p.m.]
(1 . "DWGPROPS COOKIE")
(9 . "")
)
)
(setq Xname (entmakex Xrec))
(dictadd (namedobjdict) "DWGPROPS" Xname)
)
(prompt "\nType in UPDREV to start this routine")
(defun c:updRev (/ xlist rev)
(setq Rev (getstring "\nEnter drawing Revision Number: "))
(setq xlist (dictsearch (namedobjdict) "DWGPROPS"))
(if Xlist
(progn
(dictremove (namedobjdict) "DWGPROPS")
(dictadd (namedobjdict) "DWGPROPS" (entmakex (subst (cons 9 Rev)
(assoc 9 xlist) xlist)))
)
(progn
(add-record)
(setq xlist (dictsearch (namedobjdict) "DWGPROPS"))
(dictremove (namedobjdict) "DWGPROPS")
(dictadd (namedobjdict) "DWGPROPS" (entmakex (subst (cons 9 Rev)(assoc
9 xlist) xlist)))
;(entmod (subst (cons 9 Rev) (assoc 9 xlist) xlist))
)
)
(princ)
)
;;;;
;;;;End of the AutoLISP routine
;;;
And it came from :
Victor Delgado
mailto:VDelgado@alhansen.com
O.K. who's brave enough to expand on this?
Remember, you're only allowed to use AutoLisp.
==============================================
And, believe it or not, hot of the press.......
"I created a routine in 2002 for setting DwgProps...
Thanks to Victor Delgado for pointing out info on AutoDesks webpage.
Here is what I came up with..."
<--- Start Of Lisp --->
;----------------------------------
; 2 Title
; 3 Subject
; 4 Author
; 6 Comments
; 7 Keywords
; 1 Hyperlink
; 8 Last saved by
; 9 Revision
; 40 Editing time
; 41 Creation time
; 42 Last modified time
; 90 Number of custom properties
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (4 of 7) [23/03/2005 05:50:11 p.m.]
; 300-309 Custom properties
;----------------------------------
(defun add-record (NUMBER / Xrec Xname)
(setq Xrec '((0 . "XRECORD")
(100 . "AcDbXrecord")
(1 . "DWGPROPS COOKIE")
(NUMBER . "")
))
(setq Xname (entmakex Xrec))
(dictadd (namedobjdict) "DWGPROPS" Xname)
)
(defun upddwgp (NUMBER STRING)
;(defun upddwgp (NUMBER / xlist STRING)
(setq xlist (dictsearch (namedobjdict) "DWGPROPS"))
(if Xlist
(progn
(dictremove (namedobjdict) "DWGPROPS")
(dictadd (namedobjdict) "DWGPROPS" (entmakex (subst (cons NUMBER STRING)
(assoc NUMBER xlist) xlist)))
)
(progn
(add-record NUMBER)
(setq xlist (dictsearch (namedobjdict) "DWGPROPS"))
(dictremove (namedobjdict) "DWGPROPS")
(dictadd (namedobjdict) "DWGPROPS" (entmakex (subst (cons NUMBER STRING)(assoc
NUMBER xlist) xlist)))
;(entmod (subst (cons NUMBER STRING) (assoc NUMBER xlist) xlist))
)
)
(princ)
)
<--- End Of Lisp --->
<--- Start Example Function Call --->
(setq MYSTRING "This is my string")
(upddwgp 6 MYSTRING)
<--- End Example Function Call --->
If you see fit, then add to your newsletter and/or website...
Or if you know a better way of doing things I would really like to see them...
Thanx
Dan Landrum
mailto:landrum@miller-engineering.com
THANK YOU, Victor and Dan.
This is what this Newsletter is all about.
Maybe we should call it the "Open AutoLisp Alliance?"
or OAA or "?" (think about the last one.)
==========================================================================
The question :
"Anybody know the latest method of loading and
unloading a VBA application using AutoLisp?"
The answer :
"This is how I've been doing it. Don't know if it's the right way or not
but it works."
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (5 of 7) [23/03/2005 05:50:11 p.m.]
(command "undefine" ".qsave")
(defun c:qsave ()
(command "vbaload" "n:\\autocad\\common\\pltstmp.dvb")
(command "vbarun" "pltstmp.thisdrawing.pltstmp")
(command "vbaunload" "pltstmp")
(command ".qsave")
(princ)
)
Darek Watson
mailto:darekw@zfa.com
Thank's Darek, let's see if we get anymore answers to this vexing issue.
==========================================================
I would like to extract extended entity data and property data
from child elements of inserted blocks. I have tried various things, but I
can only access the data properties of the parent block entity. What method
should I use?
Eric Tompos
mailto:etompos@ntainc.com
==========================================================
The Back Stoep
Well, that's about it for this week. My daughter is home from boarding school so I'm getting nasty
female type looks every time I sit down at the computer. Crikey I hate shopping, especially when
I'm only the unpaid taxi driver. Naaaw, I don't really mind. We don't see much of Kyla with her
being away at school in Cape Town and she is studying so hard for her finals.
So, I bid you farewell until next week and leave you with this :
There was a man who sent ten different puns to his work mates,
in the hope that at least one of the puns would make them laugh.
Unfortunately, no pun in ten did.
Cheers,
Kenny Ramage Q.B.E.
======================================================
Sites worth a wee look at :
VB Design
http://www.vbdesign.net/
Contract CADD Group
http://www.contractcaddgroup.com
AcadX.Com
http://www.acadx.com
Reini Urban
http://xarch.tu-graz.at/autocad
=====================================
AfraLisp : http://www.afralisp.com
=====================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
=====================================
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (6 of 7) [23/03/2005 05:50:11 p.m.]
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na
with "Subscribe" in the Subject Line.
=====================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
=====================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
==========================================
Bye.
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-03
http://www.afralisp.com/newsletter/2001/2001-03.htm (7 of 7) [23/03/2005 05:50:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, October 06, 2001 7:31
AfraLisp Newsletter No 2001-04
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
=====================================
AfraLisp is supported by :
Contract CADD Group
http://www.contractcaddgroup.com
=====================================
The Front Stoep
Ladies and Gentlemen and Randall. I welcome you once again to my humble abode and hope that
you are feeling well within yourself. Moi? I feel great. Tired yet happy, busy as a little bee,
haphazardly flitting from programme to programme overcoming new challenges, discovering
otherwise unknown planets, conquering the entire civilised world.........
To cut a long story short, I'm fine thanks.
I'm still busy, slowly but surely, with the updating of AfraLisp. Oh yeah, before I forget, please
remember that AfraLisp will also post your AutoLisp or VB/VBA application. Just send it to me,
(the coding please, not the application,) I place it on AfraLisp, and suddenly, you're rich and
famous. Sounds good doesn't it, and it doesn't cost you a penny. Ask Randall, he must be a
millionnaire by now with all the stuff I've nicked from him and posted on AfraLisp :-)))
Right, enough waffle. Shut the doors, draw the curtains, switch the lights off, (the lights, not your
monitor!!) and on with the show........
============================================================
The Site
Creating Icon menu's in AutoCAD can be quite tedious. First you need to create slides of all your
drawings that you want to include in your menu. (http://www.afralisp.com/lisp59a.htm) Secondly,
you need to create a text file with the names of all the slides. Thirdly you need to run "Slidelib.exe"
to create your slide menu. And last but not least, you need to add all the menu items and macros to
your menu. (http://www.afralisp.com/menu3.htm)
A lot of work hey! Then, 2 months later you want to add something to the menu and you have to go
through the whole process again.
This is where the "AfraLisp Slide Manager" comes in. This application will allow you to create
Slide Libraries without the overhead of having to create icon menu's or modify your menu files. Pop
along, download the AutoLisp application and play around with it. Your comments would be
appreciated.
You can find "AfraLisp Slidemanager" at : http://www.afralisp.com/slideman.htm
Wach this space 'cos I'm busy attempting to produce a similar application using VBA.
(Randall, stop laughing......Jessica, please throw him a fish or something.)
By the way, for those of you who don't know Randall, he's a 42.4 year old Llama.
You can find him at http://www.vbdesign.net
Don't tell him I sent you!!!
===========================================================================
The Autosave feature in AutoCAD does not save the drawing you are working on, but saves a copy
of your drawing to a directory stored in the Savefilepath system variable. This drawing does not
have the same name as your drawing file and can be overwritten with subsequent Autosaves. Here's
a little VBA application which I wrote that will save your drawings at a user determined interval.
(or very close.) It basically takes the time from the system clock and stores it in one of the User
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (1 of 6) [23/03/2005 05:50:12 p.m.]
system variables. Every time you select "Line," "Pline," or "Zoom," the application checks to see if
15 minutes has passed. If it hasn't, it does nothing. If it has, it saves the drawing and then resets the
stored time to the system time. (Phew!)
Stick this coding in a module, save it as "SaveTime.dvb," and add it to your startup suitcase.
'<--Start Coding Here
Option Explicit
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim OldTime
Dim NewTime
'trigger when user selects
Case "LINE", "PLINE", "ZOOM"
'get the time now
NewTime = (Hour(Time) * 60) + Minute(Time)
'get the time stored in USERI2
OldTime = ThisDrawing.GetVariable("Useri2")
'If the time has not been set
If OldTime = 0 Then
'set the time
ThisDrawing.SetVariable ("Useri2"), NewTime
'then end
End
End If
'if the difference is greater that 15 minutes
If (NewTime - OldTime) > 15 Then
'save the drawing
ThisDrawing.Save
'and then reset Useri2
ThisDrawing.SetVariable ("Useri2"), NewTime
End If
' end of the Select
End Select
End
End Sub
'End Coding Here-->
You can find "SaveManager" at : http://www.afralisp.com/saveman.htm
====================================================================
And, just to prove to you all that I do, and can read, here's a little something that appeared in the
Llama's A.C.A.D. dated October 1999!!!!!
Did you know that you can run VBA statements from the command line?
Try this :
From AutoCAD's Command line
1. VBASTMT <enter>
2. ThisDrawing.PurgeAll <enter>
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (2 of 6) [23/03/2005 05:50:12 p.m.]
=============================================================
The Questions
Why don't you include some IntelliCAD stuff on your site - It may not match AutoCAD but it is hot
on the heels because it walks like a duck, it quacks like a duck, fill the rest yourself.............
Like your sense of humour..... or lack of it........all depends on your time and space......keep up the
good work and don't slack off with the VBA code because lisp is in slow decline (death comes to us
all) Ralph The Wonder Llama can see the future.........we need death and rebirth to progress!
Kind Regards
From Australia
John Finlay
mailto:john@acecad.com.au
I replied to Bruce with this :
"Glad you enjoy the letter Bruce. II intend to add a lot more VB/VBA stuff in the near future. A lot
of users though are still using AutoLisp and I get a stack of correspondence on that subject. Believe
it or not, a lot of people are still on R12/R13. (especially in this part of the world.) IntelliCAD! I
haven't looked at. Have you got a free copy for me?"
Kenny
And, of course, Bruce replied back to me :
Kenny,
For a free copy of IntelliCAD 2001 just go over to the CMS web site at http://intellicadms.com
and select Download. The Lisp and DCL are very similar and would only require slight
modification of your ACAD routines to enable them to work. See the help files in ICAD for
differences. ICAD has a command interface just like ACAD only menu customisation is easier in
ICAD - you will see what I mean by selecting Tools>Customise from the pull down menu.
Now you can tell all your readers where to obtain free copies. Even some may like to use ICAD to
read or convert ACAD2000 drawings back to R12 -> R2.5
Regards
John Finlay
===================================================================
Hi Ken
Have started being a regular visitor to your excellent website.
I have a problem you may be able to help with, I recently downloaded a copy of a program called
"AWELD". It really is a good program for inserting weld symbols comprising a lisp routine and a
slide library which does not need slides?
There is also a DCL file which seems to have the tile drawing routines written in it, my problem is
that the tiles display perfectly in R12 & 2000 but not in R14, although selection does function OK,
any ideas?
Regards
cyril horsey
mailto:cyril_h@smartchat.net.au
South Australia
Cyril,
I had a similar problem with R14. I ended up having to remake all my slide files and slide libraries.
Why? I haven't a clue! What goes on behind the screen and inside my "box" is a mystery to me.
Hopefully some hardware guru can help us both out.
Kenny
=================================================================
Kenny,
Thankyou for listing the earliy version of Watson.
Attached is the current version Watson2.
I was hoping you might list this one if you dare.
The site has also been updated for version2 at
http://www.geocities.com/watsonlisp/
Aaron J. Strom
mailto:aaronic_abacus@hotmail.com
Aaron, It will be posted on AfraLisp sometime this week.
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (3 of 6) [23/03/2005 05:50:12 p.m.]
===================================================
Answers
The question was:
"Anybody know the latest method of loading and
unloading a VBA application using AutoLisp?"
What about :
(command "vbarun" "TestFile.dvb!TestModule.TestMacro")
if testfile,dvb is found in support file search path.
or
(defun c:qsave ()
(command "vbarun" "n:\\autocad\\common\\pltstmp.dvb!pltstmp.thisdrawing.pltstmp")
(command ".qsave")
(princ)
)
?
Why do you need to unload?
Ragnar Thor Mikkelsen
mailto:Ragnar.Mikkelsen@nestor.no
===============================================================
If you are using AutoCAD 2002 there are new lisp functions for handling VBA...
Instead of using "vbaload use this: "vl-vbaload"
Instead of using "vbarun" use this: "vl-vbarun"
The two new functions include better error handling... For example if you
use "vbaload" on a project that is already loaded but you did not know,
well, then you get an error. But if you use "vl-vbaload" for the same
example, well, you do not get the already loaded error...
I do not know for sure which version of AutoCAD these new functions came
into play but I do know for sure that they are in version 2002...
Dan
mailto:landrum@miller-engineering.com
==========================================================
This is interesting to see how others perform this task. The way I have
come up with to load & unload is :-
;; Load BayCreate Program
(defun c:Lmdt41 ()
(setq p1 "d:/program files/premier/vb/baycreate.dvb")
(command "-vbaload" p1 "-vbarun" "choice")
)
;; Unload BayCreate Program
(defun c:Umdt41 ()
(setq p1 "d:/program files/premier/vb/baycreate.dvb")
(command "vbaunload" p1)
)
Looking back im not sure why I did the load and unloading coding in this
way, just seemed the way to do it at the time. Also, why I chose to use /
in the directory structure and also the - symbol in the -vbaload and
-vbarun commands is also something I cannot remember now . hehe
Peter. K. Foster Jnr
mailto:peter_foster@aaf.co.uk
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (4 of 6) [23/03/2005 05:50:12 p.m.]
==========================================================
The Back Stoep
I mentioned my daughter Kyla finishing her preliminary exams last week. Well, she brought home
one of her exam papers. I knew things had changed since I was at school, but this was what was
written at the top of the exam paper :
Note :
Please read all instructions carefully.
If the words are too long, ask the examiner to read them for you.
Write all answers between the lines.
No part of the answer book is to be rolled and smoked.
No children of students are allowed to participate.
Leave firearms in the possession of the parole officer.
Bribes may be accepted for amounts exceeding $500.
If this exam paper does not match the one purchased last night
please notify the examiner.
Cheers,
Kenny Ramage Q.B.E.
======================================================
AfraLisp : http://www.afralisp.com
=====================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
=====================================
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na
with "Subscribe" in the Subject Line.
=====================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
=====================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
==========================================
Bye.
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (5 of 6) [23/03/2005 05:50:12 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-04
http://www.afralisp.com/newsletter/2001/2001-04.htm (6 of 6) [23/03/2005 05:50:12 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, October 13, 2001 5:00
AfraLisp Newsletter No 2001-04
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
=====================================
AfraLisp is supported by :
Contract CADD Group
http://www.contractcaddgroup.com
=====================================
The Front Stoep
Jeepers, what a week. Sunday fixed all the bugs (I hope) in "AfraBack" (see The Site) that
Randall so kindly picked up for me. Monday work. Tuesday, drove to Cape Town, South
Africa for my daughters valedictory. (850km.) Wednesday attended aforementioned
ceremony wearing suit. (Ughh...) Thursday, drove home. (another 850km.) Friday, back to
graft. Phew, time for a nice long beer. In fact, talking about beer, I recently went on the
drinking mans diet. You don't eat anything, you just drink beer. I lost 3 days!
AfraLisp is coming on well, I'm happy with the look of the site and delighted with
AfraLisp's new service provider. (Way to go Frank.) Please let me know if there is
anything in particular you would like to see added to the site and I'll do my best to oblige.
I've had a lot of queries in regards to my band "BedRock" and our CD "Recovery."
Check out the "Back Stoep" for more news.
============================================================
The Site
Do you need to transfer drawing files from one directory or drive to another?
Do you work on your local drives then transfer them to a network drive at the end of the
day?
Or do you not trust your I.T. department and prefer to make your own backups of critical
files? (that's me.)
Then "AfraLisp Drawing Backup" is for you.
Pop along, have wee look, and then help yourself.
http://www.afralisp.com/afraback.htm
Feedback on this application would be much appreciated.
=============================================================
VBA Tips has been updated, (http://www.afralisp.com/vbtips.htm) and I intend
updating all the R14 VBA applications and tutorials for R2000 functionality.
Watch this space.
=============================================================
Would you like to create a hyperlink to your favourite website on a form using VBA?
Thought so!
Open a new project in VBA and insert a new Userform.
Add a label to the form and change the caption to the URL of your website.
e.g. http://www.afralisp.com
Change the colour of the label to Blue - Underlined.
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (1 of 9) [23/03/2005 05:50:14 p.m.]
Now add the following coding to the click event of the label :
'<- Coding Starts Here
Private Sub Label1_Click()
Dim nFile As Integer
'Write a temp file URL
nFile = FreeFile
Open "TEMP.URL" For Output As #nFile
Print #nFile, "[InternetShortcut]"
Print #nFile, "URL=http://www.afralisp.com"
Close #nFile
'Launch the browser
Shell "rundll32.exe shdocvw.dll,OpenURL " & "\temp.url", vbNormalFocus
'Delete the temp file
Kill "TEMP.URL"
End Sub
' Coding Ends Here
Voila, you have a hyperlink on your form.
===============================================================
The Questions
Hi Ken,
Do you ever come across DXF files produced by Caddie? I have a few newly
generated ones here that have an error in the hatch objects. AutoCAD will
not import them because the dxf structure of the hatch objects are wrong. I
fixed it once before but I cannot remember how I did it - hence this
desperate SOS.
Thanks,
Kevin Barnett
mailto:kevin.barnett@bigenafrica.com
===============================================================
Hi Kenny,
Firstly, thanks for the newsletter No 2001-04, I especially enjoyed the
Back Stoep. So true these days.
I downloaded your Ddsteel routine many moons ago and have been using it with
great success ever since. (It is version 2.0 of 1998). I have one
suggestion/request (because I don't have time/am too lazy). What about
adding in the train rails and heavy crane rails. It is such a schlepp to
draw them out each time I need them. (I know I should save them as std
drawings and just insert them as needed - but as I said I am too lazy,
besides I cannot remember which jobs I have used them previously to go and
drag them out and save them as standards)
I wanted to email a fish for Randall but I was afraid it might stink up my
hard drive, thanks again for the great humour in the newsletter keep up the
good work.
Cheers
Dave Corrall
mailto:dacorrall@hotmail.com
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (2 of 9) [23/03/2005 05:50:14 p.m.]
Dave,
I'll try and find some time and add the crane sections to Ddsteel.
In fact it's due for a spring clean and polish.
=========================================================================
Hello there Kenny,
I am simple AutoLisper per say and have a major hang up at the moment.
I have a list [ex. (1.0 5.0 6.0 8.0 2.0) ] and need them in a new list, in proper order [ex. (1.0
2.0 3.0 4.0 ect....)]. Can you possibly help here?
Thanks,
Eric
mailto:emortensen_mic@hotmail.com
Eric,
Try this :
;create a list
Command: (setq a '(1.5 5.7 9.3 2.4 1.1))
Returns: (1.5 5.7 9.3 2.4 1.1)
;convert to strings
Command: (setq a (mapcar 'rtos a))
Returns: ("1.5" "5.7" "9.3" "2.4" "1.1")
;sort the list
Command: (setq a (acad_strlsort a))
Returns: ("1.1" "1.5" "2.4" "5.7" "9.3")
;convert back to real numbers
Command: (setq a (mapcar 'atof a))
Returns: (1.1 1.5 2.4 5.7 9.3)
If you are using Visual Lisp it's worth looking at the
vl-sort functions.
For more complex sorts, check out Tony Tanzillo's sort page at :
http://ourworld.compuserve.com/homepages/tonyt/sortsort.htm
or Reini Urban at :
http://xarch.tu-graz.ac.at/autocad/lisp/#sort
===============================================================
Ken,
I'm looking for a way to add a support path to autocad using autolisp. Can you please
help?
Dave
mailto:dgerret@ppella.net
Dave,
Try this out :
;<-Coding Starts Here
(defun addSP (dir pos / tmp c lst)
(setq tmp ""
c -1
)
(if
(not
(member (strcase dir)
(setq lst (mapcar 'strcase (parse (getenv "ACAD") ";")))
)
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (3 of 9) [23/03/2005 05:50:14 p.m.]
)
(progn
(if (not pos)
(setq tmp (strcat (getenv "ACAD") ";" dir))
(mapcar '(lambda (x)
(setq tmp (if (= (setq c (1+ c)) pos)
(strcat tmp ";" dir ";" x)
(strcat tmp ";" x)
)
)
)
lst
)
)
(setenv "ACAD" tmp)
)
)
(princ)
)
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
(while pos
(setq lst (cons (substr str 1 pos) lst)
str (substr str (+ pos 2))
pos (vl-string-search delim str)
)
)
(if (> (strlen str) 0)
(setq lst (cons str lst))
)
(reverse lst)
)
;Coding Ends Here ->
Arguments : A folder path and the position at which to insert it. (0 based.)
Example : (addSP "c:\\afralisp" 3)
Funnily enough, I was looking for something like this myself just the other day.
Anyway, I "borrowed" this from http://www.acadx.com
Please don't tell on me!!!
========================================================================
Answers
The question was :
"How can I determine if lines are duplicate or fragmented lines contained
in that line (lines that are over lines) so they can removed from the
drawing?"
And the answer :
Hello ,
Here is the code to find and delete overlapped (not overlapping) lines.
It highlights lines that are fully overlapped (embedded) by other lines, and asks the user
whether he wants to delete it.
The user has two choices:
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (4 of 9) [23/03/2005 05:50:14 p.m.]
1) Select all lines in the drawing (default option).
2) Select lines by window.
I have tried it successfully on a small drawing.
There is still scope for
a) Error handling
b) Code optimization and
c) User interface.
But important thing is, it works. (AutoCAD 2000 compatible.)
You are all welcome to abuse test it and suggest errors, improvements or new features,
or simply send your comments.
mailto:sanganaksakha@freelance-worker.com
;;; ======================
(defun c:Overlap ()
(setq oOSMODE (getvar "OSMODE"))
(Setvar "OSMODE" 0)
(setq oCMDECHO (getvar "CMDECHO"))
(Setvar "CMDECHO" 0)
(setq vZERO 8.8817843e-16)
(Setq ss1 (ssadd))
(Setq ss2 (ssadd))
(initget "All Window ")
(setq selOption
(getkword
"Select Objects; [window] or All : "
)
)
(If (= selOption "Window")
(progn
(setq
s1 (getcorner
(setq f1
(getpoint
"Specify first corner: "
)
)
"Specify opposite corner: "
)
)
(While (= (sslength ss1) 0)
(Command "_Zoom" "_W" f1 s1)
(Setq ss1 (ssget "_w" f1 s1))
)
)
(progn
(Command "_zoom" "_e")
(setq SS1 (ssget "_x" '((0 . "LINE"))))
)
)
(setq
TotLines (sslength ss1)
) (if (< TotLines 2)
(progn
(Alert
"No overlapping lines found in the selection!\n\n
The program ends!!"
)
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (5 of 9) [23/03/2005 05:50:14 p.m.]
(setvar "CMDECHO" oCMDECHO)
(setvar "OSMODE" oOSMODE)
(princ)
(exit)
)
)
(setq lDone 0)
(While (< lDone TotLines)
(setq bLine (ssname ss1 lDone))
(setq lDone (1+ lDone))
(setq pt (cdr (assoc 10 (entget bLine))))
(setq ss2 (ssget "_c" pt pt '((0 . "LINE"))))
(if (/= ss2 nil)
(processSS1)
)
)
(setvar "CMDECHO" oCMDECHO)
(setvar "OSMODE" oOSMODE)
(princ)
)
(defun ProcessSS1 ()
(if (> (sslength ss2) 1)
(progn
(setq ss2 (ssdel bLine ss2))
(while (> (sslength ss2) 1)
(ssdel (ssname ss2 (- (sslength ss2) 1)) ss2)
)
(setq pt1
(cdr
(assoc 10
(entget bLine)
)
)
)
(Setq pt2
(cdr
(assoc 11
(entget bLine)
)
)
)
(setq sLine (ssname ss2 0))
(setq sLinEdata (entget sLine))
(setq pt3 (cdr (assoc 10 sLinEdata))
pt4 (cdr (assoc 11 sLinEdata))
)
(processSS2)
)
)
)
(defun ProcessSS2 ()
(if (= (inters Pt1 Pt2 pt3 Pt4)
nil
)
(progn
(if
(or
(And
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (6 of 9) [23/03/2005 05:50:14 p.m.]
(< (abs (- (angle Pt3 Pt1)
(angle Pt3 Pt2)
)
)
vZERO
)
(< (abs (- (angle Pt4 Pt1)
(angle Pt4 Pt2)
)
)
vZERO
)
(and
(/= (distance Pt1 Pt3) 0)
(/= (distance Pt2 Pt4) 0)
)
(and
(/= (distance Pt1 Pt4) 0)
(/= (distance Pt2 Pt3) 0)
)
)
(or
(and
(= (distance Pt1 Pt3) 0)
(= (distance Pt2 Pt4) 0)
)
(and
(= (distance Pt1 Pt4) 0)
(= (distance Pt2 Pt3) 0)
)
)
(and (or (= (distance Pt1 Pt3) 0)
(= (distance Pt1 Pt4) 0)
(= (distance Pt2 Pt3) 0)
(= (distance Pt2 Pt4) 0)
)
(or (> (abs
(- (angle Pt3 Pt1)
(angle Pt3 Pt2)
)
) vZero
)
(> (abs
(- (angle Pt4 Pt1)
(angle Pt4 Pt2)
)
) vZero
)
) ;_ end of or
)
)
(progn
(vl-load-com)
(setq obj1
(vlax-ename->vla-object bLine)
)
(vla-highlight obj1 "True")
(initget "Yes No")
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (7 of 9) [23/03/2005 05:50:14 p.m.]
(setq delLin
(getkword
"This line is being 'embedded' by another line.\n\n
You can confirm by zooming transparently.
\n\nDo you want to delete it? [No] or Yes: "
)
)
(if (= delLin "Yes")
(progn
(entdel bLine)
(ssdel bLine ss2)
)
)
(command "_regen")
)
)
)
)
)
(alert
"Type 'Overlap' at the command
prompt to run this program"
)
;;; ================
===============================================================
The Back Stoep
As most of you probably know, I'm lead guitarist/vocalist for "BedRock - The Band in the
Sand." If you would like to listen to a couple of sample Mp3's from our new CD
"Recovery," or would like to purchase a copy on-line, then pop along to
http://www.oneworld.co.za/ Enter "BedRock" into the search text box in the upper right
hand corner to access BedRock's download page.
And I leave you with this :
A man takes his Rottweiler to the vet.
"My dog's cross-eyed, is there anything you can do for him?"
"Well," says the vet, "let's have a look at him"
So he picks the dog up and examines his eyes, then checks his teeth.
Finally, he says "I'm sorry but I'm going to have to put him down."
"What? Because he's cross-eyed?"
"No, because he's really heavy"
Tara the noo,
Kenny Ramage Q.B.E.
======================================================
AfraLisp : http://www.afralisp.com
======================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter.htm
======================================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
======================================================
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (8 of 9) [23/03/2005 05:50:14 p.m.]
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na
with "Subscribe" in the Subject Line.
======================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
======================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
======================================================
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-05
http://www.afralisp.com/newsletter/2001/2001-05.htm (9 of 9) [23/03/2005 05:50:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, October 21, 2001 6:08
AfraLisp Newsletter No 2001-06
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
Contract CADD Group
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
"But I don't want to go among mad people," Alice remarked.
"Oh, you can't help that, we're all mad here." said the Cat: "I'm mad. You're mad!"
"How do you know I'm mad?" said Alice.
"You must be," said the Cat, "or you wouldn't have come here."
Makes you think doesn't it?
===============================================================
The Site
Would you like to be able to write the perfect code whether it be in AutoLisp, VBA or C+?
Then do yourself a favour and read this article : "How to write Unmaintainable Code," written by
Roedy Green. You can find it at : http://www.afralisp.com/unmain.htm
This is not to be missed..........
===============================================================
Is your ambition in life to be able to place shadows on your controls?
Do you dream of giving your forms a 3D appearance?
Then check out http://www.afralisp.com/vba/shadow.htm
===============================================================
Have you every tried to calculate the area of two intersecting entities, especially if one,
or both, include curves? Difficult hey!
Draw a couple of intersecting entities (like two circles,) and run this little routine :
;coding starts here
(defun c:barea ( / a b opp tekst)
(setq a (getpoint "\nSelect Internal Point: "))
(command "-Boundary" a "")
(setq b (entlast))
(redraw b 3)
(command "area" "O" "L")
(setq opp (rtos (getvar "area") 2 3))
(setq tekst (strcat "\nArea = " opp))
(alert tekst)
(redraw b 4)
(command "Erase" b "")
(princ)
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (1 of 8) [23/03/2005 05:50:15 p.m.]
);defun
(princ)
;coding ends here
If you would like to know more about calculating and formatting areas, pop along here
and have a wee look :
http://www.afralisp.com/lisp/area.htm
=======================================================================
Something a bit different especially if you need screen shots for web pages or manuals.
You are all probably going to laugh at me for not knowing this, but anyway, here goes :
To perform a screen capture of an AutoCAD dialog box:
1. Display the dialog box as desired.
2. Simultaneously press ALT+Print Screen buttons.
3. Start the destination application.
4. Select Edit > Paste from the destination applications pull down menu.
The AutoCAD dialog box should now be pasted into the application.
See, you're never too old to learn.
===============================================================
The Questions
Dear Kenny,
I have any questions about your written application with visual basic, AcadExport.Exe I have
download this application from your website and I had export any drawings from AutoCAD
Release 14 to dwf format. But I will export a selected directory of drawings to dwf format for
Autocad release 2000. How can I export dwg format to dwf with autocad 2000 or 2002.
Greatings,
R. Ayaz
Amsterdam
mailto:R.Ayaz@chello.nl
I've had a lot of queries in regards to creating DWF files using a batch process application.
Well, if you use AutoCAD 2000, you don't need one. In A2K, you can use the Batch Plot utility to
automate the creation of DWF files.
1. Start the Batch Plot utility.
The Batch Plot utility starts a new A2K session.
2. In the AutoCAD Batch Plot Utility window, choose the Add Drawing button to select drawing
files for the batch plot list.
3. In the Add Drawing File dialog box, select some drawing files and choose Open.
4. In the AutoCAD Batch Plot Utility window, select the drawings you want to batch plot.
5. Choose the Plot Devices button to list the current plot devices for A2K.
6. In the Plot Devices dialog box, select DWF ePlot.pc3 from the Plot devices list, and
then choose OK. The Plot Device column in the AutoCAD Batch Plot Utility window displays
DWF ePlot.pc3 for each of the files you selected in step 4.
7. In the AutoCAD Batch Plot Utility window, choose the Plot button to batch plot the selected
drawings and create the DWF files.
===============================================================
Dear Kenny Ramage,
You run an awesome site and I, along with many other people, keep coming
back to it for reference and new ideas. It's great to see that you got a
domain instead of a subdomain.
I have, finally, set up a site of my own. The idea is to pass on
information gathered through 10 years trying to deal with AutoLISP, and by
that maybe help others or maybe even get some started.
I'd appreciate and be honoured if you would be kind enough to maybe have a
look at the site or at least include a reference to it on your links page.
It is rather sketchy at the moment, but I decided that it contains enough
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (2 of 8) [23/03/2005 05:50:15 p.m.]
information by now to go online with it.
http://intervision.hjem.wanadoo.dk/
Regards,
Stig Madsen
Danish National Museum,
Copenhagen, Denmark
mailto:stig.madsen@natmus.dk
Nice site with lot's of potential.
Welcome to the family Stig....
===============================================================
Where does the *32.bmp file come from?
In the menus I have, the first call for a bitmap is the bitmap name and then
the second call is to a "icon_16_blank" or something like that?
How do you make a *32.bmp from one of my custom autocad bmp's?
Darek Watson
mailto:darekw@zfa.com
Darek, let's have a look at a typical toolbar menu item :
ID_3 [_Button ("Draw a Line", "Cline16.bmp", "Cline24.bmp")]^C^C^P_Line;
The first item "Button" defines a button on the toolbar.
The second item "Draw a Line" is the tooltip.
The third item "Cline16.bmp" calls the bitmap used.
The fourth item "Cline24.bmp" calls the bitmap file to use if large buttons are selected.
(Right click on any toolbar, select "Large Buttons" and see what happens.)
When you create your bitmaps for the toolbar, you are suppose to create a set that are
16 x 15 in size, and a set that are 24 x 22 in size.
BUT, if the 24 x 22 bitmaps are not available, AutoCAD will just scale up the 16 x 15
bitmaps and use them. So, it would be perfectly exceptable for your toolbar menu item
to look like this :
ID_3 [_Button ("Draw a Line", "Cline16.bmp", "Cline16.bmp")]^C^C^P_Line;
Have a look at the AutoCAD menu. That's how they do it.
================================================================
Hey Kenny,
Love the site!
I am trying to automate some of my lisp files here in the office. I would like to be able to use a
dialog box to choose which LISP file to run. How do I make a call to run another lisp file from a
radio button? Do I make the call to the lisp In the "action_tile"? ex: (action_tile "rb1" "(setq door
\"single\")")
where "single" is the name of the lisp file I want to execute.
I'm new to dialog boxes, so I would really appreciate your help.
Thanks,
David W Fitzgerald
mailto:davidf@hcyu.com
David,
Copy this coding into Notepad and save it as Startlisp.dcl :
//dcl coding starts here
startlisp : dialog {
label = "StartLisp" ;
: radio_button {
key = "rb1" ;
label = "Lisp Routine No &1" ;
value = "1" ;
}
: radio_button {
key = "rb2" ;
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (3 of 8) [23/03/2005 05:50:15 p.m.]
label = "Lisp Routine No &2" ;
}
ok_cancel ;
}
//dcl coding ends here
Now copy this coding into Notepad and save it as Startlisp.lsp :
;autolisp coding starts here
(defun C:startlisp ()
;define function
(setq choice "No1")
;store default choice
(setq dcl_id (load_dialog "startlisp.dcl"))
;load dialog
(if (not (new_dialog "startlisp" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile "rb1" "(setq choice \"No1\")")
;*store choice
(action_tile "rb2" "(setq choice \"No2\")")
;*store choice
(action_tile
"accept"
;if O.K. pressed
"(done_dialog) (setq userclick T)"
;close dialog
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog
(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(progn
;do the following
(if (= choice "No1")
(progn
(cond
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (4 of 8) [23/03/2005 05:50:15 p.m.]
((null C:Lisp1) (prompt "Please Wait...")
;if not loaded
(load "Lisp1")))
;load it
(C:Lisp1)
;then run it
);progn
);if
(if (= choice "No2")
(progn
(cond
((null C:Lisp2) (prompt "Please Wait...")
;if not loaded
(load "Lisp2")))
;load it
(C:Lisp2)
;then run it
);progn
);if
);progn
);if userclick
(princ)
);defun
(princ)
;autolisp coding ends here
There is another way of triggering an AutoLisp expression from within a dialog box.
Check out http://www.afralisp.com/lisp49f.htm
For a complete explanation of DCL Tile Attributes go to :
http://www.afralisp.com/lisp49m.htm
And for a listing of all available DCL Tiles, pop along to :
http://www.afralisp.com/lisp48m.htm
All of the above include downloadable working examples.
Now, am I not nice?
================================================================
Do you know of a way to tab through several viewports in Model Space
(Acad200) ?
Right now I'm using -VIEW R (view name), etc, etc
Quite cumbersome when dealing with many views to find a detail....
thanks,
Kevin
mailto:KRicketts@nlh.nf.ca
One technique used for fast viewing of drawings is to divide the drawing into regions. You can
then quickly zoom into those regions. "PanZoom" uses an AutoLisp routine and a toolbar to
automate the viewing of your drawing in four regions. You can find "PanZoom" at :
http://www.afralisp.com/mylisp.htm
===============================================================================
Kenny,
Have you ever written any routines that will find duplicate entities and
delete them? I have several hundred duplicate text entities (they somehow
were copied on top of each other) and I need to get rid of them. Any ideas?
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (5 of 8) [23/03/2005 05:50:15 p.m.]
Thanks
Rod
mailto:gis@beld.com
===============================================================================
Hi,
My name is Andrea and your website is a big reference for me.
I would like to know how to extract an attribute in a variable:
example: (setq att1 ( get the attribute whos the tag is "x"))
I don't know how. Could you help me with this ?
thank you
mailto:aandreetti@siteplus.org
Hi
My Name Is Jeff.
I realy appreciate the web site, it is very helpful.
I was wandering if you could shed some light on a
problem I'm having?
I can not figure out how to get text entered in an
edit box to run in a lisp routine.
I wrote a simple lisp routine to change the text in
a block attribute.
Kind of like changing xx to JBP in the title block
where it says drawn by.
I can not get it to work with a dialog box.
Your help would be greatly appricaited.
Jeff Pickett
mailto:jeffbpickett@hotmail.com
Andrea/Jeff,
You'll find the answer to this one at :
http://www.afralisp/lisp/attab.htm
It's a wee bit large to include in this forum.
==========================================================
Answers
The question was:
"Anybody know the latest method of loading and
unloading a VBA application using AutoLisp?"
Here's another method:
(vl-vbarun "MyFile.dvb!MyMacro")
I think this is the easiest method, and I still don't understand why you need to unload :-)
For Nestor AS
Ragnar Thor Mikkelsen
mailto:Ragnar.Mikkelsen@nestor.no
The front runner to this discussion (I was going to say argument but people might get upset,)
is without doubt "VL-VBALOAD."
Why????
If you use the command "VBALOAD" and the VBA application is already loaded, you get
an error message. "VL-VBALOAD" does not cause an error and just does nothing if the
application
is already loaded. (or maybe it loads it again and makes it run twice as fast???)
Why would you want to unload?
In the "olden" days, system resources were valuable and if you were not using an application,
you would unload it to conserve memory.
Just habit I guess. Jeepers, you youngsters are spoilt!!!
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (6 of 8) [23/03/2005 05:50:15 p.m.]
===============================================================
The Back Stoep
I was thinking about what I mentioned just now about preserving system resources. I started
using AutoCAD with Release 1.7. It came on ONE 320kB floppy disk. (I've still got it.) We had no
hardrives. First we loaded DOS (remember that dark place,) with one disk, then we loaded
AutoCAD, and then we stuck another disk in to save our drawings. One day, my boss arrived in
the office with a "borrowed" PC that had a 10 meg hardrive installed. "There is no way on earth
that we could possibly fill this." I confidently remarked. We used to store all the drawings in one
big directory. No clue that such a thing as sub-directories existed. No mouse, no digitizer, just
the pen and, wait for it, a black and white monitor. (10") No pull down menu's, no toolbars, no
icon menu's, just the screen menu. I felt like a king on the cutting edge of technology. We used
to customise the AutoCAD menu using "Word Star." You needed a degree in computer science
just to understand the keystroke combinations on that word processor!!!
O.K. I'm showing my age. Hey, this was only 18-19 years ago.
Must go, it's time for my tablets and my daily walk around the garden with the nurse.
Talk again soon...........
"Apparently, 1 in 5 people in the world are Chinese.
And there are 5 people in my family, so it must be one of them.
It's either my mum or my dad, or my older brother Colin.
Or my younger brother Ho-Cha-Chu.
But I think it's Colin."
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na
with "Unsubscribe" in the Subject Line.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na
with "Subscribe" in the Subject Line.
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://kramage.tripod.com
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
Bye........
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (7 of 8) [23/03/2005 05:50:15 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-06
http://www.afralisp.com/newsletter/2001/2001-06.htm (8 of 8) [23/03/2005 05:50:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, October 26, 2001 21:44
AfraLisp Newsletter No 2001-07
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
Competition time. (FX : drum roll that gradually get's louder.) I'm looking for a nice simple logo for
AfraLisp. You know, one of those small, eye catching goodies, about the size of a postage stamp, that
immediately catches your attention. The prize? A copy of my band BedRock's
(http://www.bedrockband.com) new CD "Recovery", fully autographed by the band and delivered to
your doorstep anywhere in the world. Full credit will be given to the designer of the winning logo and
your name will appear on the site. Judging will be done by my wife Heather, Randall Rath and myself.
Hope you don't mind Randall? (I haven't asked him yet!!!) Results will appear in Newsletter No 2001-09.
(that's 2 weeks time folks.)
===============================================================
The Site
AfraLisp now has a discussion forum where you can post AutoLisp/VB/VBA questions and answers.
If you would like to participate in some serious intellectual debate, or simply swop insults, then pop along
to :
http://afralisp.community.everyone.net
===============================================================================
Last week I posted a new tutorial on AfraLisp entitled "Attributes and Dialogue Boxes."
http://www.afralisp.com/lisp/attab.htm
Well this week I've published one that does exactly the same, but this time using VBA.
You can find this tutorial entitled "Attributes and VBA" at :
http://www.afralisp.com/vba/attab.vba.htm
==========================================================================
Want to add menu items to your right-click shortcut menu? Try this :
'CODING STARTS HERE
Sub VbaMenu()
Dim currMenuGroup As AcadMenuGroup
Dim openMacro As String
Dim newScmenu As AcadPopupMenu
Dim scMenu As AcadPopupMenu
Dim entry As AcadPopupMenu
On Error GoTo Err_Control
' Use MenuGroups property to obtain reference to main ACAD menu
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD")
'===================================================================
'find the shortcut menu
For Each entry In currMenuGroup.Menus
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (1 of 7) [23/03/2005 05:50:17 p.m.]
If entry.ShortcutMenu = True Then
Set scMenu = entry
End If
Next entry
'create a shortcut menu item
Set newScmenu = scMenu.AddSubMenu(0, "&VBA Menu")
'create the vbaload macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaload" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Load", openMacro
'create the vbaide macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaide" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Editor", openMacro
'create the vbarun macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbarun" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "VBA &Macro", openMacro
'create the vbaman macro
openMacro = Chr(3) & Chr(3) & Chr(95) & "vbaman" & Chr(32)
'display the shortcut sub-menu item
newScmenu.AddMenuItem "", "&VBA Manager", openMacro
'add a separator line
scMenu.AddSeparator 1
're-compile the AutoCAD menu
currMenuGroup.Save acMenuFileCompiled
'==========================================================
Over_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case -2147024809
Err.Clear
Resume Over_Here
Case Else
MsgBox Err.Number & " - " & Err.Description
Exit Sub
End Select
End Sub
'CODING ENDS HERE
For a complete tutorial on creating menu's using VBA, look out for :
http://www.afralisp.com/vba/vbamenu.htm
I should have it posted sometime next week.
=================================================================
Using AutoLisp you can only explode one entity at a time using the command function.
This is untrue and this is why :
;<--Coding starts here
(defun c:multiex ( / sel i n_ent )
(setq sel (ssget))
(setq i 0)
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (2 of 7) [23/03/2005 05:50:17 p.m.]
(setq n_ent(sslength sel))
(repeat n_ent
(command "_explode" (ssname sel i))
(setq i (+ 1 i))
);repeat
(princ)
);defun
(princ)
;Coding ends here==>
==================================================
Or would you like an even quicker way? Try this :
;<--coding starts here
(defun c:ex ()
(setvar "QAFLAGS" 1)
(command "explode" "all" "")
(setvar "QAFLAGS" 0)
(princ)
)
(princ)
;coding ends here -->
I can just hear everybody! "What's this "QAFLAGS?"
Don't ask me, I just use it.......
=============================================================================
Place this into your Startup Suitcase, double click on any object
in your drawing and see what happens :
'CODING STARTS HERE
Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)
ThisDrawing.SendCommand ("_properties") & vbCr
End Sub
'CODING ENDS HERE
=============================================================
Does this happen on your system?
You close a drawing that you did not modify while it was open; however, the following prompt displays:
Save changes to <filename>?
Some applications run automatically when you open a drawing, such as an AutoLISP routine stored in
acad.lsp or acaddoc.lsp. These routines can result in modifications of system variables that apply to a
drawing. For this reason, you are prompted to save changes to a drawing that you did not modify.
You can modify such an AutoLISP routine to prevent this by using the new functions, acad-push-dbmod
and acad-pop-dbmod.
The following excerpt is from the AutoCAD 2000 Readme file:
New Functions Provided to Prevent a Document From Being Marked "Updated"
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (3 of 7) [23/03/2005 05:50:17 p.m.]
Two new functions, acad-push-dbmod and acad-pop-dbmod, can be used to suspend and resume the
$DBMOD recording mechanism that AutoCAD uses to track changes to a drawing. These functions allow
applications to make changes to a document as part of their initialization process without setting flags in
$DBMOD and triggering unwanted save drawing queries.
(acad-push-dbmod) pushes the current value of the $DBMOD system variable for the document onto an
internal stack. The function always returns T. (acad-pop-dbmod) restores the value of $DBMOD to the
most recently pushed value on the document's internal stack. The function returns T for a successful
stack pop and nil if the stack is empty.
The acad-push-dbmod and acad-pop-dbmod functions are implemented in acadapp.arx, which is loaded
by default on AutoCAD startup, but can be disabled, if desired.
To use the new functions, precede program actions that should not affect the value of "$DBMOD" with
calls to push the $DBMOD value, then pop the value after performing the action. Here is a simple LISP
example:
(acad-push-dbmod)
(setq new_line '((0 . "LINE") (100 . "AcDbEntity") (8 . "0")
(100 . "AcDbLine") (10 1.0 2.0 0.0) (11 2.0 1.0 0.0)
(210 0.0 0.0 1.0)))
(entmake new_line) ; Sets $DBMOD 1 flag
(command "_color" "2") ; Sets $DBMOD 4 flag
(command "_-vports" "_SI") ; Sets $DBMOD 8 flag
(command "_vpoint" "0,0,1") ; Sets $DBMMOD 16 flag
(acad-pop-dbmod) ; $DBMOD will again have the same value it had before
==================================================================
The Questions
Thanks for the help on my little dcl/lisp program!! It work fine.
I have been cruising thru your sit and reading all of your tutorials on lisp and VBA and I find them very
useful. My next step is to upgrade our panel schedule program to allow more functionality. We are
currently creating all of our schedules (HVAC, Electrical, Plumbing etc.) in excel and exporting to
AutoCAD using the Spanner program. It is an easy way to get your schedules into AutoCAD, but that is
about it.
I would like to be able to access these items from within Cad or from excel to do editing. I thought of
using OLE objects, but then I run into problems with them not wanting to print out right. I guess my
question to you would be, Do you have any information on using VBA with excel to import excel files into
AutoCAD, and be able to edit from either direction? Also how about converting an excel spreadsheet to a
VBA application? I made a small excel spreadsheet to do motor load calculations and I would like to try
and convert this to VBA. Can you direct me to more info on this subject?
Thanks for your knowledge!
David W Fitzgerald
mailto:davidf@hcyu.com
===============================================================
Hi Kenny
I downloaded the vbasteel program together with all that I could find on vba programming and got stuck
into it, I was very impressed with the website as a whole.
Anyway I have filled the vbasteel program with all the BHP Australia sections including welded and pile
sections, if you think it will be any use on the website I will upload it to you,
it has ended up at 885 Mb so it's fairly hefty.
Regards
Cyril Horsey
South Australia
mailto:cyril_h@smartchat.net.au
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (4 of 7) [23/03/2005 05:50:17 p.m.]
I'll have this handy application posted next week.
===============================================================
Kenny,
I have used many of your utilities and lisp programs that you have written over the years, but I have
found that I am terrible at programming. My eyes cross, my brain freezes and I forget my name for
starters. So I wanted to ask you a question. I have some things I want to "do" in AutoCAD that if I had a
clue I know I could write code to do it. I know what I want to do but how to do it is a mystery for me.
How do other people get code to do what they want? What do you think? Should I just give up and find
someone to write code for me? Do you do that?
Obviously Im fishing for information.
Any help would be great.
Thank You.
Chris Allen
mailto:callen@theexpogroup.com
"Someone to write code for me!!" Yes, Randall Rath.
Seriously Chris, read, try out, read, try out again, read, try out, steal from Randall, read, try out, ask
Randall for help, read, try out, give up, have beer, try out yet again, sleep on it, dream about it, wake up,
try out, read, talk to walls, ask dog for advice, have beer, try out...................................Hey, it works, BIG
smile. Have 12 beers. Start next program. Infinite loop.
=============================================================================
A question for you or the Wonder Llama. How do you make a routine that
"paints" the z value from one object or block to another?
Thanks,
Garry Fisher
mailto:gfisher@royaleresorts.cc
=============================================================================
Dearest Kenny,
I have been reading your newsletter for a short time. I am beginning to look
forward to seeing it in my mailbox. I hope you can help me and maybe post
the answer in your Q & A section of your newsletter. I have been trying
(with little success) to make an automated bill of material lisp.
What I envision is a simple leader that after given the pick points, asks
for a quantity, piece mark and description. The pertinent info would appear
on the leader as well as in a database, that would generate a bill of
material when the drawing is finished, by a "generate bill of material"
command.
I have been experimenting with it for about 2 months now and the voices in
my head are getting louder with every failed attempt. I just wish they would
get my right when they scream at me :)
ttyl,
Shane (not Joe) MacIntyre
mailto:enco@encoeng.com
==============================================================
Is it possible to make a patch purge program that also can
delete all frozen layers on a drawing ?
Terje Gunnarsen
mailto:terjegun@online.no
=============================================================
Can you start external applications from within Autocad 2002.
Specifically I would like to have a button on a toolbar to start some
frequently used applications.
Thanks,
Russ Johnston
mailto:rjohnston@handling.com
Russ,
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (5 of 7) [23/03/2005 05:50:17 p.m.]
Just place this small AutoLisp routine within the macro section
of the toolbar button :
^C^C^C(startapp "Theapplication.exe")
eg. To start Notepad, add this :
^C^C^C(startapp "Notepad.exe")
=============================================================
I would like to know how to get a combo box to display a list of variables that I can use to open a folder
on my hard drive, or on the network. What I am trying to do is set up a vba application to allow the user
to select from a list of (types of drawings) which will correspond to a folder on the hard drive. Then in a
text box I want to show the contents of that folder that have the (.dwg) extension. Next when the user
highlights one of those drawings in the list box I would like to show a preview of that drawing. Then be
able to hit the "OK" button to insert that drawing into the current drawing that the user has opened.
It doesn't sound like much, but how? Please help me!
David W Fitzgerald
mailto:davidf@hcyu.com
==========================================================
The Answers
About screen shots:
If you use ALT+PrtSc and then Paste directly into Word, you will soon have a doc at several Mbytes.
Maybe Word 2000 is asmarter than older version?
Here is one suggestion to minimze the doc-size:
1) Use 256 colors in Windows or "thousands of colors" instead og "millions". (Right click your desktop
and select "Propeties")
2) Paste the screenshot into MsPain (or simmilar).
3) Copy from MsPaint and use "Paste Special" in Word, selecting "Picture" or "Image" (not sure
because I have Norwegian Office, the point is to create a Word picture object, not a bitmap).
Ragnar Thor Mikkelsen
mailto:Ragnar.Mikkelsen@nestor.no
====================================================================
The Back Stoep
Well, I finally seem to have got the Newsletter distribution list sorted out. There should be no more
double e-mails and hopefully things will run smoothly from now on. (famous last words Kenny!) Any
problems, please drop me a line.
If you don't know already, "BedRock - The Band in the Sand" has a new home. Check us out at :
http://www.BedRockBand.com
Pop along and sign our guestbook. We'd love to hear from you.
Some Alternative Meanings
Coffee (n), a person who is coughed upon.
Flabbergasted (adj), appalled over how much weight you have gained.
Abdicate (n), to give up all hope of ever having a flat stomach.
Pokeman (n), a Jamaican proctologist.
Esplanade (v), to attempt an explanation while drunk.
Willy-nilly adj), impotent.
Negligent (adj), answering the door in your nightie.
Lymph (v), to walk with a lisp.
Gargoyle (n), an olive flavoured mouthwash.
Flatulence (n), the emergency vehicle that picks you up after you've been run
over by a steamroller.
Balderdash (n), a rapidly receding hairline.
Testicle (n), a humorous exam question.
Oyster (n), a person who sprinkles his conversation with Yiddish expressions.
Circumvent (v), the opening in the front of underpants.
Tara the noo,
Kenny Ramage Q.B.E.
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (6 of 7) [23/03/2005 05:50:17 p.m.]
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:majordomo@www.afralisp.com
with "unsubscribe afralisp-newsletter" in the BODY.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:majordomo@www.afralisp.com
with "subscribe afralisp-newsletter" in the BODY.
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-07
http://www.afralisp.com/newsletter/2001/2001-07.htm (7 of 7) [23/03/2005 05:50:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Saturday, November 03, 2001 7:38
AfraLisp Newsletter No 2001-08
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
I apologise profusely for the double Newsletter last week. I must have hiccupped and pressed the
"send" button twice, or maybe I was seeing double when I wrote it and produced two without
realising. Who knows? Who cares? You're lucky I'm not a twin! Now if I'd sent 42 copies we
would all have the secret of the universe wihin our grasp and nobody would complain.
(Voice Over : "Kenny, a simple 'sorry' will suffice.")
Yes, well, no, fine.
The site is building up nicely, (I hope you've noticed.) I'm posted quite a few new tutorials and I
am looking for ideas for more. Any suggestions? I'm also going to start a new section where I'll
be posting other peoples VBA/VB coding/applications. So, if you've got any super-duper
earthshaking coding that you'd like to share with the big wide world, just send it in.
By the way, I've only received two entries for the AfraLisp Logo. (although the two I've received
are very nice.)
Come on all you budding graphic designers, time is running out.......
===============================================================
The Site
I've completed the tutorial on VBA and Menu's. You can find it at :
http://www.afralisp.com/vba/vbamenu.htm
And Cyril Horsey's VBASteel can be downloaded from :
http://www.afralisp.com/vba.htm
You can also find a new tutorial entitled "VBA and Sequential Text Files."
(sounds complicate doesn't it? - don't worry, it can't be if I understand it.)
There's a letter further on which will give you my motive for writing this.
Oh, by the way, you can find the tutorial at : http://www.afralisp.com/vba/extext.htm
===============================================================
Would you like to change certain aspects of your AutoCAD display?
Check this out :
'CODING STARTS HERE
Sub Setup_Display()
Dim ACADPref As AcadPreferencesDisplay
'error handler
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (1 of 8) [23/03/2005 05:50:18 p.m.]
On Error GoTo Err_Control
'get a reference to the AutoCAD display
Set ACADPref = ThisDrawing.Application.Preferences.Display
'set the cursor size
ACADPref.CursorSize = 5
'switch on the scrollbars
ACADPref.DisplayScrollBars = True
'release display object
Set ACADPref = Nothing
Exit Sub
Err_Control:
MsgBox Err.Number & " - " & Err.Description
Err.Clear
Exit Sub
End Sub
'CODING ENDS HERE
=========================================================================
I stole this from the AutoCAD help 'cos I thought it was maybe worth looking into :
If you want to use a VBA macro to launch an AutoCAD interactive (built-in)
dialog box, AutoCAD does not open this dialog box until the VBA macro has
completed. (AutoCAD queues any AutoLISP commands that are executed using the
ThisDrawing.SendCommand method until the VBA macro finishes.)
The result of this is that you cannot run code or make changes or verify
preferences.
If you split the macro into two or more parts, and then use this queuing to
your advantage, you can force the macro to resume -- actually, the second
macro takes control when the dialog box is closed.
Here is a sample of a macro that calls a second 'part' after a dialog box is
closed:
'CODING STARTS HERE
Sub Test()
MsgBox "Please setup the layout the way you would like", vbOkOnly, "User Prompt"
' This command queues the launch of the 'Layout Wizard' dialog
ThisDrawing.SendCommand ("(command ""_layoutwizard"")" & vbCr)
' This command queues the second part of the macro
ThisDrawing.SendCommand ("(command ""_-vbarun"" ""Test_Part_2"")" & vbCr)
End Sub
Sub Test_Part_2()
MsgBox "Part 2"
End Sub
'CODING ENDS HERE
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (2 of 8) [23/03/2005 05:50:18 p.m.]
==================================================================
The Questions
Hey Kenny,
You fixed the double email - I now get three - nice one Kenny!
John Finlay
Go on John, rub it in!!!
Hey, that means you owe me for an extra one.
===============================================================
Kenny,
Thank you for the newsletter with the edit menu facility... very
interesting... I looking forward to trying this out.
However I have a problem with some basic trigonometry, and maybe I'm looking
at this too hard.
How does one work out the angle of a triangle knowing the lengths of it's
sides?
Take for instance a 3,4,5 triangle... I assume one uses the formula - sine
angle = ( / opposite hypotenuse )
using autolisp...
( setq opposite ( log 3 ) hypotenuse ( log 5 ))
; using log otherwise Autolisp returns 0 as a result
( setq result ( / ( exp opposite )( exp hypotenuse )))
this returns a value of 0.6
How does one then change this value into the angle, Autolisp doesn't appear
to have a reverse sine function?.
The resulting angle should be 36.8699deg or 0.643501 radians.
Kind regards
Paul Matthews
Paul, I'm sure that arc sine is just the inverse of sin.
eg. 1/sin or "one divided by the sine of the number, or the sign of the number
to the power of minus one. Must think about this one. I'll ask the kid's, they've
just finished maths at school. I'll get back to you...
==================================================================
Hi Kenny,
I would like to know where I can download the autolisp source code for 3D cube.
Regards
Victor
===============================================================
Hi Kenny,
I was just wondering if it is possible to add the file name, date and time
of a plot automatically to the bottum of a plot.
Regards,
Barend.
I've had a lot of queries regarding this subject so everybody please excuse
me for repeating something from one of the earlier newsletters :
Have you had a good look at the Express Tools yet? Under the Text sub-menu there
is a little gem of a routine called "Rtext." Using this application you can
insert Diesel expressions anywhere in your drawing. This is great for Plot
Stamps and much easier to setup and maintain than other Plot Stamp
applications. Just insert it into your template drawings and away you go.
Here's the one that I use :
Date Plotted : $(edtime, 0, Mon DD"," YYYY - H:MMam/pm)
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (3 of 8) [23/03/2005 05:50:18 p.m.]
Plotted By : $(upper, $(getvar, "loginname"))
This "stamps" the Plotted Date and Time as well as the users Login name.
Check out the "Rtext" help for more details and more uses.
===============================================================
Hello Kenny,
I have a problem.
I made an excel file and put my information in it (blocknames, distances,
enz. ), then I call it from VBA and use it in AutoCAD, but also a
possibility I heard is, to get the information out of an .txt file instead
of an .xls file, this would save a little time so the routine is quicker.
Do you know have to call a .txt-file in VBA?
I hope you can help me.
Regards Ren
Rene,
The following example will read from an external text file and populate a list box :
'CODING STARTS HERE
Sub FillListBox()
Dim sTemp As String
lstLayer.Clear
Open "C:\DATA\LAYERS.TXT" For Input As #1
While Not EOF(1)
Line Input #1, sTemp
lstLayer.AddItem sTemp
Wend
Close #1
End Sub
'CODING ENDS HERE
Rene, came back to me with this :
Kenny,
Thank you I will try it.
I got another answer to from someone else, would you tell me what your
opinion is about his answer?
**The time you might save on loading the text file will be lost in
**formatting the text in the text file. Stick with your Excel!!! Your
**wasting time trying to pull formatted text out of a text file.
Thank you and goodbye my friend.
So I replied back with this :
Rene,
Your friend is quite right in what he says except for one or two "minor" points :
a) Saving Time? How much time are you going to lose? Milliseconds!!! A good text parsing
routine will extract the information you need before the user has time to blink. I have text files
with up to 2000 plus entries and speed is not an issue.
b) More importantly, any user must have Excel installed on his PC before you can extract
information from it. Every computer can read an ASCII text file. On top of that, when you start
using VBA and talking to Excel, different versions of Excel have different object models which
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (4 of 8) [23/03/2005 05:50:18 p.m.]
creates further complications. With text files, no such issue.
I'm not saying Text files are better to use than Excel, or vice a versa, only you can decide that,
but looking at general overheads and maintenance, text files in my opinion can be a quick and
easy way of exporting/importing information. As a matter of interest, you can not only read from
a text file sequencially using VBA, you can also create a random access file or, even go so far as to
create an INI file. All of these files are ASCII text files. (hey, this is a very good subject for a
tutorial.)
To put it in a nutshell, using Excel or any other application such as Access or Lotus makes you
reliant on that application for your program to work. Using a text file keeps your program
independent.
On the other hand, if you intend to export information, run calculations or create reports and
then import the results into AutoCAD, Excel or a similar application is the route to take.
For further info check out http://www.afralisp.com/vba/extext.htm
================================================================
Hello,
I found your address at the afralisp.com homepage.
I'm looking for a solution to get EXCEL 97 datas drawn by AUTCAD 14
automatically.
For example a simple rectangle.
Could you please forward some hints or examples or contact me via E-Mail?
I can also sent my sheets and the corresponding drawing later.
Thanks in advance,
Ralf
OK Ralf, the pressure is getting to much. I'll have a look at AutoCAD and
Excel in the near future. Watch this space. " "
=================================================================
Hello Kenny,
I am trying to insert a title block into a new drawing and I do not know how to write a VB code to
accomplish this task. Title block's name is "a-shop.dwg", and has several attributes.
Could you please help me?
Thanks, Eugene.
Yep, Watch the site next week.
=================================================================
The Answers
Following on from the AfraLisp newsletter...
I obtained this from CadDesk magazine..
But this routine utilises a global variable that contains the file name that
you want to open. It may be of interest to you...
^C^C^P(setq pmv:tmp (findfile "ACAD.PGP"))(startapp "C:/windows/notepad.exe"
pmv:tmp)(princ)
Also I have inserted the following that enables Autocad to open up other
drawings. R2000 is a little different to R14. Again it might interest
you....
;;;----------------CODING STARTS HERE---------------------------
;;; ( GEN:OpenDwgFile filename bit )
;;; Function discerns which Acad version and applies appropriate command.
;;; Bit controls as follows
;;; 0 = Open file if Acad2000 or separate session if Acad14
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (5 of 8) [23/03/2005 05:50:18 p.m.]
;;; 1 = Open file - Don't save current drawing
;;; 2 = Open file - Save current drawing.
( defun GEN:OpenDwgFile ( filenm bit / cmd f )
;;; local functions
( defun OpenDwgFileR15 ( f / cmd )
; string together the cmd expression and send to VBASTMT e.g.
; ( command "vbastmt" "AcadApplication.Documents.Open
\"x:/ADG/templates/ControlledSurveys.dwt\"")
( setq cmd ( strcat "AcadApplication.Documents.Open \"" f "\"" ))
( command "vbastmt" cmd )
) ; local defun
( defun OpenDwgFileR14 ( f bit / cmd )
( command "pan" "0.0,1.0,0.0" "0.0,0.0,0.0" ) ; force prompt
( if ( = bit 1 )
( command "_.open" "n" f ) ; save changes
( command "_.open" "y" f ) ; don't save changes
)
) ; local defun
( defun OpenDwgFile>0 ( f )
( alert "When using this file either SAVEAS and edit file \n OR
\nCUT and PASTE but don't overwrite original." )
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn
( setvar "SDI" 0 ) ; turn on multiple document interface
( OpenDwgFileR15 f ) ; if R2000 open dwg otherwise start separate
session of Acad.
); progn
( startapp "acad.exe" f)
)
); local defun
( defun OpenDwgFile>1 ( filenm / f ) ; don't save changes
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn ( OpenDwgFileR15 filenm ));progn
( OpenDwgFileR14 filenm 0 )
)
); local defun
( defun OpenDwgFile>2 ( filenm / f ) ;save changes
(if ( wcmatch ( getvar "ACADVER" ) "15*" )
( progn ( OpenDwgFileR15 filenm ));progn
( OpenDwgFileR14 filenm 1 )
)
); local defun
; main function
( if ( setq f ( findfile filenm )) ; locate file
( progn
( cond
(( = bit 0 )( OpenDwgFile>0 f )); access another drawing
(( = bit 1 )( OpenDwgFile>1 f )); don't save changes
(( = bit 2 )( OpenDwgFile>2 f )); save changes
);cond
);progn
( alert ( strcat "AutoCad cannot find " filenm ))
)
) ; defun
;;;----------------CODING ENDS HERE---------------------------
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (6 of 8) [23/03/2005 05:50:18 p.m.]
Kind regards
Paul Matthews.
===============================================================
The Back Stoep
Well, another week has gone by (plus one more crate of beer,) and I'm just gearing myself up for
the "silly" season with the band. (Check out our Diary page at
http://www.bedrockband.com/diary.htm) From the look of things, we're pretty well booked up
right until Xmas and New Year so I suppose I'd better start taking care of my liver. Or do you
think I should I put it under an intensive training schedule to let it get used to the competitive
drinking that I'm sure I'll indulge in? A serious word of warning to you all. Pleeeeease be careful
on the roads. There's a lot of nutters out there. And don't drink and drive. You might spill some.
Until the next time....
Yesterday, I was getting into my car, and this chap says to me
"Can you give me a lift?"
I said "Sure, you look great, the world's your oyster, go for it.'
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:majordomo@www.afralisp.com
with "unsubscribe afralisp-newsletter" in the BODY.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:majordomo@www.afralisp.com
with "subscribe afralisp-newsletter" in the BODY.
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
Bye........
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (7 of 8) [23/03/2005 05:50:18 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-08
http://www.afralisp.com/newsletter/2001/2001-08.htm (8 of 8) [23/03/2005 05:50:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Sunday, November 11, 2001 20:33
AfraLisp Newsletter No 2001-09
http://www.afralisp.com
mailto:afralisp@afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
I've had a few entries for the AfraLisp Logo competition and decided that I'm
going to let you, the reader, decide which one you think is the best. So if you
would like to have a hand in designing the AfraLisp home page, just pop along to
http://www.afralisp.com/logo/logo.htm and have your say. Each of the Logo's are
numbered and all you have to do is send an e-mail to :
mailto:afralisp@afralisp.com with "Logo" in the Subject line and the Logo number
of your choice in the Body.
===============================================================
The Site
Jings, I've been lazy this week. Only one new tutorial. What will my Mum say?
Naw, just a bit busy with work and the band. I have posted a simple but effective
tutorial that has a closer look at "Layers and Linetypes ByLayer." 'cos I'm busy
trying to fill in all the little gaps in my AutoLisp Tutorials that I've been meaning to
cover for ages. This is one of them. You can find it at :
http://www.afralisp.com/lisp/clay.htm
Quite handy if you like to play around with Colours and Linetypes.
Don't forget the AfraLisp Discussion Form is up and running at :
http://afralisp.community.everyone.net
Although, in a way, I much prefer posting your Questions and Answers via this
Newsletter.
(Mum : "So why do you have a Discussion Forum if you don't want one. I've told
you before Kenny, your eyes are bigger than your belly. Now look at that nice
young lad Randall. I bet he doesn't, blah, blah, blah, blah, blah ...............")
See Randall, the trouble you get me into.........
==================================================================
The Questions
I had two similar questions this week, both of them concerning DCL and AutoCAD
freezing.
I'm only going to show you the line that was the cause of the error.
Have a look at the first one :
(action_tile "cancel" "(done_dialog) (setq bryt 1) (exit)")
I was told that everytime the user clicked the "Cancel" button, AutoCAD would
freeze.
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (1 of 9) [23/03/2005 05:50:21 p.m.]
Any idea why?
The second example has a similar error :
(action_tile
"accept"
"(progn
(setq rimel (get_tile \"ebrim\"))
(setq maxel (get_tile \"ebmax\"))
(done_dialog) (setq flag T) (cutt))"
)
They were both trying to call a function (exit) and (cutt) from within a dialog.
In other words, the dialog was still open when they called the function.
An easy error to make and one to look out for.
Please everybody, be careful out there!
=================================================================
Kenny - I just had a look at your site and was quite impressed.
Thanks for having a link to my cad nauseam site on your site.
However, the cad nauseam site has now moved to :
http://www.users.bigpond.com/stevejohnson.
I bet there are quite a few links broken on my site, too. :)
Steve Johnson
Yes, I know Mum, the Links page also need updating.
See Steve, you've also dropped me in it with my Mum.
============================================================
I found your website via cadence newsletter. Interesting site.
You, being an autolisp jock, I suspect have other tricks up your sleeve.
I've got a border sheet that I've added some new rtext features to in an
effort to "automate" some of the grunt work - like dates, paths, filenames
etc.
When people use a file naming convention incorporating the sheet number as
the first two characters, such as: 01GenNotes.dwg, or, 33BunchaDetails.dwg
... the rtext extracts the number of the drawing and places it in a part of
the block requiring that. So the user has "drawing 1 of ...". The trick
I'm looking for is extracting the largest sheet number of the set of
drawings. It can be done in Lisp, but I'm not sure the other blokes in here
would bother with running a routine. The best way, in my opinion, would be
to do it with an rtext statement. At this point I'm stumped. I haven't any
idea whether this is even doable in rtext. Any ideas?
Thanks ahead of time.
Tom Edwards.
==================================================================
Sometime ago I set something with Acad2000 that allowed me to resize the
Open or New Drawing Box by grabbing the bottom right side corner. Great for
previewing existing drawings.
A co-worker wanted to know how to do the same. I can't remember what I did.
Could you help?
Thanks,
Kevin
===================================================================
Hi Ken, (& da band).......
I was musing over the last N/L when I came across the chap who was talking
about 'sine' etc......I believe it was Paul Mathews.
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (2 of 9) [23/03/2005 05:50:21 p.m.]
I would like to use your newsletter to ask Paul (and yourself if you can throw light)
why he uses LOG to achieve his Trig solution.
I also ask this because I have no idea at all about using 'log' etc or how it works.
I have a problem understanding how Paul understands LOG yet doesnt
understand Trig...........yet he understands how to put it all together but still needs
to ask.
Paul, if you are listening, I too wish to know a heck of a lot more about sine,cos, &
etc than I do now, but putting in LOG has thrown more for a six as I dont
understand this side of Cad yet, let alone the math.
So, on that note Kenny, how bout' doing a MATH page. I am more than sure that
there are millions out here (there) who are in the same boat as me. Autocad
demands at least a reasonable understanding of geometry, and if us users dont
understand at that basic level then we are in deep trouble before we even open
the program.
Can you give us a "Kenny version" of how to use Sine, Cosine, Tangent etc?
Pete
==============================================================
Dear sir,
I would like to ask if it is possible to add my link at your site!!
My site is:
http://come.to/autolisppage
I do think Afralisp is a great and I would be happy if your visitors will
be able to visit my site as well.
Thanks in advance,
Michiel de Bruijcker
================================================================
The Answers
The question from Paul Matthews was :
However I have a problem with some basic trigonometry, and maybe I'm looking
at this too hard.
How does one work out the angle of a triangle knowing the lengths of it's
sides?
And some of the answers :
Hi Kenny,
This is the first time that I write to you.
I just wanted to say that arc sine does not equal to 1/sin . AutoLISP has
arc tan function that returns the angle in radians knowing the tangent of
the angle.
The following equetions can be useful :
sin a * sin a + cos a * cos b = 1
tan a = sin a / cos a
this means you can calculate tan of the angle if you have the sin or the
cos.
the arc tan function in AutoLISP is (atan ). It takes one or two arguments.
You can take a look at this function in the LISP help .
Have a nice week-end
Sherko
Amsterdam, The Netherlands
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (3 of 9) [23/03/2005 05:50:21 p.m.]
=========================================================
Kenny (& Paul)
Autolisp does have an inverse tan function: atan. And that's all you need
really.
;asin
;-1<=y<=1
;returns inverse sin in radians
(defun asin (y)
(atan y (sqrt (- 1 (* y y))))
)
;acos
;-1<=y<=1
;returns inverse cos in radians
(defun acos (y)
(atan (sqrt (- 1 (* y y))) y)
)
btw, 1/sin(x) would be sec(x) not the inverse sine. Arc sin is indeed the
inverse of sine but the notation "sin to the power -1" is just shorthand for
inverse sine, it does not mean literally raised to the power of minus 1;
i.e. 1/sin(x).
I hope this is a useful contribution. I have certainly had my "moneys worth"
from your newletter and web site. Thank you
jeff russon
======================================================
Hi Kenny,
I didn't see Paul Matthews's email address. You can forward him this
attached file for Trig functions in AutoLISP.
Kind regards.
Jasmina
;CODING STARTS HERE
;Trig functions in AutoLISP
;adapted from CADalyst tip 442, by John Howard
;
;CO-TANGENT
(defun cot (x)
(cond
((equal (sin x) 0.0 1.0e-16)
(if (minusp x)
-1.0e200
1.0e200
)
)
(T
(/ (cos x) (sin x))
)
)
)
;
;CO-SECANT
(defun csc (x)
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (4 of 9) [23/03/2005 05:50:21 p.m.]
(cond
((equal (sin x) 0.0 1.0e-16)
(if (minusp x)
-1.0e200
1.0e200
)
)
(T
(/ 1.0 (sin x))
)
)
)
;
;SECANT
(defun sec (x)
(cond
((equal (sin x) 0.0 1.0e-16)
(if (minusp x)
-1.0e200
1.0e200
)
)
(T
(/ 1.0 (cos x))
)
)
)
;
;TANGENT
(defun tan (x)
(cond
((equal (cos x) 0.0 1.0e-16)
(if (minusp x)
-1.0e200
1.0e200
)
)
(T
(/ (sin x) (cos x))
)
)
)
;
;ARC COSECANT
(defun acsc (x)
(cond
((equal x 1.0 1.0e-16)
(* pi 0.5)
)
((equal x -1.0 1.0e-16)
(* pi -0.5)
)
((> (abs x) 1.0)
(atan (/ (/ 1.0 x) (sqrt (- 1.0 (/ 1.0 (* x x))))))
)
(T
(prompt "\n*ERROR* (abs x) < 1.0 from ACSC function\n")
)
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (5 of 9) [23/03/2005 05:50:21 p.m.]
)
)
;
;ARC COSINE
(defun acos (x)
(cond
((equal x 1.0 1.0e-16)
0.0
)
((equal x -1.0 1.0e-16)
pi
)
((< (abs x) 1.0)
(- (* pi 0.5) (atan (/ x (sqrt (- 1.0 (* x x))))))
)
(T
(prompt "\n*ERROR* (abs x) > 1.0 from ACOS function\n")
)
)
)
;
;ARC SECANT
(defun asec (x)
(cond
((equal x 1.0 1.0e-16)
0.0
)
((equal x -1.0 1.0e-16)
pi
)
((> (abs x) 1.0)
(- (* pi 0.5) (atan (/ (/ 1.0 x) (sqrt (- 1.0 (/ 1.0 (* x x)))))))
)
(T
(prompt "\n*ERROR* (abs x) < 1.0 from ASEC function\n")
)
)
)
;
;ARC SINE
(defun asin (x)
(cond
((equal x 1.0 1.0e-16)
(* pi 0.5)
)
((equal x -1.0 1.0e-16)
(* pi -0.5)
)
((< (abs x) 1.0)
(atan (/ x (sqrt (- 1.0 (* x x)))))
)
(T
(prompt "\n*ERROR* (abs x) > 1.0 from ASIN function\n")
)
)
)
;
(princ "\nCOT, CSC, SEC, TAN, ACSC, ACOS, ASEC, ASIN \n")
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (6 of 9) [23/03/2005 05:50:21 p.m.]
(prin1)
;CODING ENDS HERE
==========================================================
Hello Kenny,
Try this simple one :
(defun cangle (a b c)
(setq max_val (max a b c))
(cond
((= max_val a)(setq a b b c))
((= max_val b)(setq b c))
)
(setq
A_ang (/ (* 180 (atan a b)) pi)
B_ang (/ (* 180 (atan b a)) pi)
C_ang (- 180.0 A_ang B_ang)
)
(print (strcat "Angle A is " (rtos A_ang) " degrees"))
(print (strcat "Angle B is " (rtos B_ang) " degrees"))
(print (strcat "Angle C is " (rtos C_ang) " degrees"))
(princ)
)
Lennart Ekelund
=================================================================
And from the wonder Llama himself :
*ahem*
'CODING STARTS HERE
Function ArcSin(x As Double) As Double
'Inverse Sin
If x = 1 Then
ArcSin = PI() / 2
ElseIf x = -1 Then
ArcSin = -PI() / 2
Else
ArcSin = Atn(x / Sqr(-x * x + 1))
End If
End Function
Function ArcCos(x As Double) As Double
' Inverse Cosine
If x = 1 Then
ArcCos = 0
ElseIf x = -1 Then
ArcCos = -PI()
Else
ArcCos = Atn(x / Sqr(-x * x + 1)) + PI() / 2
End If
End Function
Function Arccotan(x As Double) As Double
Arccotan = Atn(x) + PI() / 2
End Function
Function PI() As Double
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (7 of 9) [23/03/2005 05:50:21 p.m.]
PI = Atn(1) * 4
End Function
'CODING ENDS HERE
Thanks Randall, much appreciated.
If you are interested in grabbing some super-duper VBA examples and more, then
pop along to VB Design, the second best site on the web.
http://www.vbdesign.net
============================================
The Back Stoep
This is the transcript of the ACTUAL radio conversation of a US Naval
ship and the Canadians, off the coast of Newfoundland, Oct 95.
Radio conversation released by the Chief of Naval Operations 10-10-95.
CANADIANS: Please divert your course 15 degrees to the South, to
avoid a collision.
AMERICANS: Recommend you divert your course 15 degrees to
the North, to avoid a collision.
CANADIANS: Negative. You will have to divert your course 15
degrees to the South to avoid a collision.
AMERICANS: This is the Captain of a US Navy ship. I say again, divert
YOUR course.
CANADIANS: Negative. I say again, You will have to divert your course.
AMERICANS: THIS IS THE AIRCRAFT CARRIER USS LINCOLN.
THE SECOND LARGEST SHIP IN THE UNITED STATES ATLANTIC
FLEET, WE ARE ACCOMPANIED BY THREE DESTROYERS, THREE
CRUISERS AND NUMEROUS SUPPORT VESSELS. I DEMAND THAT
YOU CHANGE YOUR COURSE 15 DEGREES NORTH, I SAY AGAIN,
THAT'S 15 DEGREES NORTH, OR COUNTERMEASURES WILL BE
UNDERTAKEN TO ENSURE THE SAFETY OF THIS SHIP.
CANADIANS: We are a lighthouse. Your call.
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:majordomo@www.afralisp.com
with "unsubscribe afralisp-newsletter" in the BODY.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:majordomo@www.afralisp.com
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (8 of 9) [23/03/2005 05:50:21 p.m.]
with "subscribe afralisp-newsletter" in the BODY.
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
Have you seen Page 42?
http://www.afralisp.com/42.htm
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-09
http://www.afralisp.com/newsletter/2001/2001-09.htm (9 of 9) [23/03/2005 05:50:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Monday, November 19, 2001 15:45
AfraLisp Newsletter No 2001-10
http://www.afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
This is Kenny's Mum speaking here. Kenny is very sorry about the double e-mail's and the
other problems with the Newsletter. I've grounded him for 3 days and told him that anything
that gets sent from his computer must now be checked by me first. He's sitting in his room
sulking at the moment, but he must realise that this is all part of growing up.
Kenny's Mum
P.S. I've got nice recipe for tripe and onion's if anybody is interested.......
============================================================================
Thanks Mum, now can I write something? Ouch!! All right, I'm sorry........
Due to popular demand, and threats of physical violence to my body from certain people who
shall remain nameless, I've decided to extend the Logo Competition for another two weeks.
Every logo I receive will be posted on AfraLisp at http://www.afralisp.com/logo/logo.htm. So
pop along and have a look. Thanks to all who voted already but I'm going to have to ask you
to do it all over again in a couple of weeks.
Please do not send in your votes yet. I will let you know when the last logo has been posted
and voting can commence.
If you want to quickly find out "Whats New" on AfraLisp, pop along to :
http://www.afralisp.com/whatsnew.htm for all the latest site updates.
*****AND*****
Special Courses for our female subscribers. Check out the Back Stoep......
We've all heard that a million monkeys banging on a million typewriters
will eventually reproduce the entire works of Shakespeare.
Now, thanks to the Internet, we know this is not true.
================================================================
The Site
I decided to have a look at "AutoLisp and Debugging" this week as I've had a few queries on
this subject especially from people using earlier releases of AutoCAD. You can find this
article at : http://www.afralisp.com/lisp/debug.htm
Have you ever wanted to design your own bicycle? Then pop along to
http://www.afralisp.com/olisp.htm and download "Bike-Lisp". Clever little application and
good fun. Thanks Alan.
I'm looking for some ideas for tutorials using AfraLisp. Any ideas? Should I start looking at
Visual Lisp? Should I concentrate more on VBA? Or, should I carry on "as is" and just keep
on giving a mixture of everything? Should I start giving guitar lessons?
Feedback pleeeeease!!!!! Or, as the Froggies say "R.S.V.P."
How does a repository of "Classic" AutoLisp routines sound? You know the type I mean. The
one's that you know are out there, you've seen them a thousand times, but you can't find
when you need them. Let me know and I can start putting a collection together.
AfraLisp Newsletter No 2001-10
http://www.afralisp.com/newsletter/2001/2001-10.htm (1 of 5) [23/03/2005 05:50:22 p.m.]
(The scope for full scale major theft is enormous here!!)
========================================================================
Want some VB Code? Try these two sites :
VB Free Code
http://www.freevbcode.com/
VB Code
http://www.vbcode.com/
Lot's and lot's to steal.........
=========================================================================
And talking of Links, I've finally updated the Links page.
http://www.afralisp.com/links.htm
I've tested all the links, removed the dead one's, and added a few new live one's.
Any AutoLisp/VBA Links? Send them to me.
=========================================================================
Do you know that you can draw on the screen without hurting the current drawing?
Thought not!!
First assign coordinates to variables pt1 and pt2. Now run this :
(grdraw pt1 pt2 2)
This will draw a yellow line between the two points.
Add a 1 to the end to highlight the lines :
(grdraw pt1 pt2 2 1)
REGEN or REDRAW to restore your drawing.
"Honest boss, I did the drawing but when I regened it just disappeared".
========================================================
The Questions
Kenny,
I typed in (mem) at the command prompt and this is what came up:
Command: (mem)
; GC calls: 10; GC run time: 60 ms
Dynamic memory segments statistic:
PgSz Used Free FMCL Segs Type
512 26 101 74 1 lisp stacks
256 417 348 151 3 bytecode area
4096 50 10 10 4 CONS memory
32 749 1234 1234 1 ::new
4096 56 34 12 6 DM Str
4096 87 3 1 6 DMxx memory
128 3 508 508 1 bstack body
Segment size: 65536, total used: 22, free: 3
nil
Can you tell me what it all means? Also, could you explain the (atoms-family) function?
I know it's got something to do with lisp routines that are loaded. Finally, has VBA got
anything similar
Thank You,
Dave
The (mem) function displays statistics on AutoLISP memory usage. I'm not much of a
"memory" man myself but hopefully someone can expand on this for us.
(atoms-family) returns a list of the currently defined symbols. Each function and all variables
loaded into memory are regarded as symbols. That's why you declare your variables as
Global or Local. Global variables retain their values after your AutoLisp routine ends and
appear in the atoms list. Local variables lose their value and are removed from the list.
Randall, maybe you could be so kind as to answer the question regarding VBA?
================================================================
Hi, my name is Andrea.
I'm trying to make a lisp with the chroma dialog of Autocad...
But all I'm able to do is this....
(defun colord ()
AfraLisp Newsletter No 2001-10
http://www.afralisp.com/newsletter/2001/2001-10.htm (2 of 5) [23/03/2005 05:50:22 p.m.]
(setq dcl_id (load_dialog "acad.dcl")) ;Load the DCL file
(if (not (new_dialog "rq_chroma" dcl_id)) ;Initialize the dialog
(exit) ;Exit if this doesn't work
)
(start_dialog)
(unload_dialog dcl_id))
But the chroma does not appear and I don't have the key associated codes..
It's the same for the "open" dialog box....where can I find the key..??
I would like to modify the "open" dialog or create one but I really don't know how..
Could you help me ?
tx
Andrea,
Of course I can help you. This is an easy one.
Use the (acad_colordlg) and the (getfiled) AutoLisp functions.
In fact you can read a tutorial regarding the (getfiled) function at :
http://www.afralisp.com/lisp14.htm
Both functions are also well documented in the AutoLisp Reference book.
================================================================
Hi Kenny,
I've really learned alot from the Afralisp site, I'm doing pipework drawings
in 3-D using AutoCad 2000i and problem comes when i'm putting elevation from
the ground level and labelling. I would like the letters also to be in 3-D
so that i can plot either hidden or shaded.
How will i change a 3-D solid pipe to a single line?
Regards,
Kitonga mutuku
Come on you 3D fundies out there, help this guy.....
===============================================================
Kenny,
How do I load and run another Lisp program from my program.
I have the code (load "geotech") but when I try and run the Lisp it fails.
Matthew
Matthew,
What's probably happening is that the program "geotech" is defuned
(well I think it's a word) as c:geotech.
Try, (load "geotech") to load the routine, then (c:geotech) to run it.
Hey, another easy one....
=================================================================
Hello Kenny:
Would you be interested in creating a "Text Replacement" routine. This routine would allow
you to create a selection set and make several "Search and Replace" commands on it. For
instance if you were using a drawing to create a new drawing and the elevation on the old
was one meter lower than the new you might want to change all "97000" text instances to
"98000" but you also might want to change all "98000" instances to "99000". Presently with
the lisp routines I have now I have to make 2 selection sets and so must make sure I don't
mix up ones already selected.
Please let me know if you would be interested.
Charlie Peppard
Calgary, Alberta Canada
Charlie, sorry about the delay in posting your query.
I misplaced your e-mail but finally found it hidden behind the washing machine.
I must say that this is quite an interesting one. Let me think about a solution
and I'll get back to you. Anybody else got ideas on this one?
=========================================================================
Hi, my name is Andrea Andreetti
Every time I need information to make a lisp, your web site have it.
It is very helpful....thanks.
I have this in a txt file:
D:\Andrea\Lisp\
-------
M-0 LEGEND
M-1 VENTILATION 3rd FLOOR DEMOLITION
M-3 PLUMBING 3rd FLOOR
M-2 VENTILATION 3rd FLOOR NEW
FP-1 FIRE PROTECTION 3rd FLOOR
AfraLisp Newsletter No 2001-10
http://www.afralisp.com/newsletter/2001/2001-10.htm (3 of 5) [23/03/2005 05:50:22 p.m.]
and I would like to write a lisp to do this:
1) Search if "M-2" existing
2) If exist replace-it, if not add-it, but in order (bettween M-1 and M-2)
I really don't know how to do this......can you help me ??
tx.
================================================================
The Back Stoep
As Randall Rath is running a course on AutoCAD and VBA, I decided that I would offer some
courses specifically for our lady readers. So, as a special offer from AfraLisp, training
courses are now available for women on the following subjects :
1. Silence, the Final Frontier: Where No Woman Has Gone Before
2. The Undiscovered Side of Banking: Making Deposits
3. Parties: Going Without New Outfits
4. Man Management: Minor Household Chores Can Wait until After The Game
5. Bathroom Etiquette I: Men Need Space in the Bathroom Cabinet Too.
6. Bathroom Etiquette II: His Razor is His
7. Communication Skills I: Tears - The Last Resort, not the First
8. Communication Skills II: Thinking Before Speaking
9. Communication Skills III: Getting What you Want Without Nagging
10. Driving a Car Safely: A Skill You CAN Acquire
11. Telephone Skills: How to Hang Up
12. Introduction to Parking
13. Advanced Parking: Backing Into a Space
14. Water Retention: Fact or Fat
15. Cooking I: Bringing Back Bacon, Eggs and Butter
16. Cooking II: Bran and Tofu are Not for Human Consumption
17. Cooking III: How not to Inflict Your Diets on Other People
18. Compliments: Accepting Them Gracefully
19. PMS: Your Problem . . . Not His
20. Dancing: Why Men Don't Like To
21. Classic Clothing: Wearing Outfits You Already Have
22. Household Dust: A Harmless Natural Occurrence Only Women notice
23. Integrating Your Laundry: Washing It All Together
24. Oil and Gas: Your Car Needs Both
25. TV Remotes: For Men Only
Please register immediately as the courses are in great demand.
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter" archive can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
Have you seen Page 42?
http://www.afralisp.com/42.htm
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
AfraLisp Newsletter No 2001-10
http://www.afralisp.com/newsletter/2001/2001-10.htm (4 of 5) [23/03/2005 05:50:22 p.m.]
wrong with your P.C.
===============================================================
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-10
http://www.afralisp.com/newsletter/2001/2001-10.htm (5 of 5) [23/03/2005 05:50:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, November 23, 2001 21:48
AfraLisp Newsletter No 2001-11
http://www.afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
**********************************************
The Front Stoep
At last my daughter Kyla is home from boarding school. She's now finished school after
completing her final exams and all that is left is the wait for her results. Please keep your
fingers crossed for her, although she's supremely confident that she's done well.
Moi, well I'm in a thoroughly relaxed mood. Twelve more days and I'm on leave for a whole
month, I'm finally getting stuck into Visual Lisp, and all seems quiet on the Western Front.
My two sons, Stuart and Daniel are doing fine. Did I mention that Stuart is a Sound Engineer
and Daniel a trainee Paramedic? Anyway, at the moment, I'm one extremely happy camper,
although we had a bit of a hiccup with the band as Eddie, our drummer, had to be rushed
into hospital for an emergency back operation resulting in us having to cancel the last of this
years gigs.
That aside, enjoy this weeks Newsletter............
============================================================================
The Site
Due to popular demand, I've finally got around to writing tutorials on "Creating Linetypes"
and "Creating Hatch Patterns." You can find them at :
http://www.afralisp.com/lisp/ltype.htm for the Linetypes and
http://www.afralisp.com/lisp/hatch.htm for the Hatches.
Hey, check out Charles Sweeney's new Hatch Pattern website.
Goes with my tutorials. (Designer Tutorials???)
Well we are both Scottish, although I have my doubts about him as he's "giving" Hatch
Patterns away!!!! You're a traitor to your country Charles....A Scotsman "giving" things
away!!!!
http://www.hatchpatterns.com/
Ask Charles about his "Tartan" hatch.
He keeps it a closely guarded secret!!
Remember, if you missed a couple of issues, the "AfraLisp Newsletter" archive can be found
at :
http://www.afralisp.com/newsletter/newsletter.htm
================================================================
Watch the Tutorial Page. Visual Lisp is about to begin!!!!!!
http://www.afralisp.com/tutor.htm
================================================================
Last week I showed you how you can draw on your screen using the (grdraw) function.
Well, I've had a couple of e-mails from people asking what possible use this could be?
Well here's one :
;CODING STARTS HERE
;Show limits on screen
;This routine draws a rectangle corresponding to the current settings of LIMMIN and
LIMMAX.
;The rectangle is erased by a redraw/regen or by running the routine again.
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (1 of 6) [23/03/2005 05:50:24 p.m.]
(defun C:LR (/ pt1 pt2 r1 r2)
(setq pt1 (getvar "LIMMIN")
pt2 (getvar "LIMMAX")
)
(grvecs (list 256 (list (car pt1)(cadr pt2)) pt2
256 (list (car pt2)(cadr pt1)) pt1
256 pt1 (list (car pt1)(cadr pt2))
256 pt2 (list (car pt2)(cadr pt1))
)
)
(grdraw pt1 pt2 -1)
(grdraw (list (car pt1) (cadr pt2))
(list (car pt2) (cadr pt1))
-1
)
(princ "Limit rect info:")
(setq r1 (rtos (car (getvar "limmin")))
r2 (rtos (cadr (getvar "limmin")))
)
(prompt (strcat "\nLower left: " r1 "," r2))
(setq r1 (rtos (car (getvar "limmax")))
r2 (rtos (cadr (getvar "limmax")))
)
(prompt (strcat "\nUpper right: " r1 "," r2))
(if (= (getvar "LIMCHECK") 0)
(setq linf "off")
(setq linf "on")
)
(prompt (strcat "\nLimits are " linf))
(princ)
)
;CODING ENDS HERE
I "stole" this from Stig Madsen's new website "Intervision".
http://intervision.hjem.wanadoo.dk/
Thanks Stig, I hope you don't mind?
By the way, keep an eye on this website.
It's building up nicely and has got a lot of potential.
===========================================================================
The Questions
Is it possible to get a program to select a file just plotted and have it
sent to a backup folder ?
thanks,
Kevin
The mind is thinking aloud.........
How can you copy whilst the drawing is still open? SaveAs? SaveAs to another directory
under the same name, or different name then SaveAs again using the original path and
name? Would the original drawing be retained or deleted? Dangerous if retained, 'cos now
we've two drawings! How do you delete the original file? What happens if things go wrong
and you lose both drawings? Blame Randall! Yes.....
Mind is still thinking, quietly this time..........
Me thinks more explanation of request required.
Back to you Kevin.......Phew!
================================================================
Hi Kenny
I don't know if you can help me. I am after a lisp routine to break a
dimension line. There are various dbreak.lsp routines on the net but none of
them seem to work with AutoCAD 2000i. Any Suggestions?
Great news letter - Keep it up
Adrian Snape
Adrian, I've got a little routine that does what you want, but it only works on "exploded"
dimensions. I don't use associative dimensions. Why? Don't ask......(Go on ask, I dare you).
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (2 of 6) [23/03/2005 05:50:24 p.m.]
Here's the coding :
;CODING STARTS HERE
;This routine breaks dimension lines that are crossing.
;The break gap is 5 units both sides of the intersection point.
;Adjust to suit.
;This routine only works on non-associative dimensions.
(defun C:LCR ( / AR LN OL OS IN P1 P2 P3 P4 LINE1 LINE2 ENT1 ENT2 AN)
(setq AR 0.5)
(setvar "osmode" 0)
(setq ENT1 (car (entsel "\nSelect crossing line to break: "))
LINE1 (entget ENT1)
LN (cdr (assoc 8 LINE1))
P1 (cdr (assoc 10 LINE1))
P2 (cdr (assoc 11 LINE1))
AN (angle P1 P2)
ENT2 (car (entsel "\nSelect line to cross over: "))
LINE2 (entget ENT2)
P3 (cdr (assoc 10 LINE2))
P4 (cdr (assoc 11 LINE2))
IN (inters P1 P2 P3 P4)
BPT1 (polar IN AN (* AR (getvar "ltscale")))
BPT2 (polar IN (+ AN pi) (* AR (getvar "ltscale")))
);setq
(command "break" ENT1 BPT1 BPT2)
(princ)
);defun
;;;*==========================================================
(princ)
;CODING ENDS HERE
This routine uses the value of the system variable "Ltscale" to scale the break
value. Just substitute this with your scaling variable.
==========================================================
Hi Kenny,
It's 1st time i write u, so, first of all , good site, it's very helpful.
The question:
Thank to dxf codes and afralisp, now I can extract vertex of a 2d polyline,
(lwpolyline), but what about 3d poly (polyline)?
Thank,
umberto
==================================================================
Do you know of a way to rotate a line relative to an angled line with an
angle other than 0?
Kevin.
No need to use AutoLisp or VBA here. Just use the "Align" command.
"Align" must be one of the most under documented AutoCAD commands, yet one of the
most powerful. If you haven't looked at this command yet, do yourself a favour and do so
A.S.A.P.
In the meantime, Kevin replied with this :
Works but is cumbersome. I deal with Transmission lines and plotting angles
relative to another, align will work but is time consuming.
You could also use the reference option under the rotate command but it
isn't 100% reliable.
I remember seeing something a couple of months ago, either an Acad command
or Lisp routine that did the trick perfectly but I forgot to keep a record
of it.
I do appreciate your help.
Kevin.
Hey, if you get your hands on it Kevin, please send me a copy.
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (3 of 6) [23/03/2005 05:50:24 p.m.]
==================================================================
The Answers
Kenny,
Keep up the great work. I like the option of "carry on as is" with a
little more emphasis on visual lisp. The repository of classic lisp's
would be wonderful if you could categorize them somehow.
Sincerely,
Jim Basnett
Jim,
Visual Lisp is on it's way.
I'm still looking into the feasibility of the "Classic" section, although I'm very tempted.
Watch This Space........ " "
================================================================
Dear Kenny's Mum,
Please do not send me the nice recipe for tripe and onion's.
Thanks,
Tony Burns
Tony, you don't know what you're missing. Taste buds maybe. :-)))
================================================================
Do you know..........?
AutoLISP supports concatenations of car and cdr up to four levels deep. The
following are valid functions:
caaaar cadaar cdaaar cddaar
caaadr cadadr cdaadr cddadr
caaar cadar cdaar cddar
caadar caddar cdadar cdddar
caaddr cadddr cdaddr cddddr
caadr caddr cdadr cdddr
caar cadr cdar cddr
Can you imagine trying to pronounce cddddr!!
You'd sound like a machine gun.
===========================================================
A couple of interesting sites I popped into during my travels:
@Acad+
http://www.newz.net/acadplus/homeangl.htm
The "Mech" of Cad
http://www.microtec.net/mrochon/
And here's a site from some guy who seems to be a bit of a rookie at VBA.
Not bad though for a beginner. Check it out....
http://www.vbdesign.net
==================================================================
Remember, the "AfraLisp Logo Competition" is still open. Send your Logo to :
mailto:afralisp@mweb.na or pop along and have a look at all the entries at :
http://www.afralisp.com/logo/logo.htm
==================================================================
The Back Stoep
I've decided to give an early Xmas present to all AfraLisp Newsletter subscribers.
Other people give away screen savers, wallpaper or mouse pads. I though, have decided to
be different and give away a special "AfraLisp Coffee Holder". Just click on this link to
download; http://www.afralisp.com/zip1/coffee.zip or visit the download page at :
http://www.afralisp.com/vba.htm to grab online.
A couple of weeks ago I had a bit of a dig at the Yanks.
Now it's the English tribes turn :
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (4 of 6) [23/03/2005 05:50:24 p.m.]
Only in England... can a pizza get to your house faster than an
ambulance.
Only in England... do supermarkets make sick people walk all the way
to the back of the shop to get their prescriptions while healthy people
can buy cigarettes at the front.
Only in England... do people order double cheeseburgers, large fries,
and a DIET coke.
Only in England... do banks leave both doors open and chain the pens
to the counters.
Only in England... do they leave cars worth thousands of pounds on the
drive and put their junk and cheap lawn mower in the garage.
Only in England... do they buy hot dogs in packs of ten and buns in
packs of eight.
Only in England... do they use answering machines to screen calls and
then have call waiting so they won't miss a call from someone they didn't
want to talk to in the first place.
Only in England... are there handicap parking places in front of a
skating rink.
3 Englishmen die each year testing if a 9v battery works on their tongue.
142 English idiots were injured in 1999 by not removing all pins from new
shirts.
58 English artisans are injured each year by using sharp knives instead of
screwdrivers.
31 English university graduates have died since 1996 by watering their Christmas tree while
the fairy lights were plugged in.
19 English people have died in the last 3 years believing that Christmas
decorations were chocolate.
English Hospitals reported 4 broken arms last year after cracker
pulling accidents.
101 English people since 1999 have had to have broken parts of plastic toys
pulled out of the soles of their feet.
18 Englanders had serious burns in 2000 trying on a new jumper with a lit
cigarette in their mouth.
A massive 543 English football supporters were admitted to A&E in the last two years after
opening bottles of beer with their teeth.
5 English schoolteachers were injured last year in accidents involving out of control
Scalextric cars.
and finally.........
In the year 2000, eight Scotsmen cracked their skull whilst throwing up into the
toilet!
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (5 of 6) [23/03/2005 05:50:24 p.m.]
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-11
http://www.afralisp.com/newsletter/2001/2001-11.htm (6 of 6) [23/03/2005 05:50:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Friday, November 30, 2001 19:55
AfraLisp Newsletter No 2001-12
http://www.afralisp.com
mailto:afralisp@mweb.com.na
**********************************************
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
**********************************************
The Front Stoep
The Newsletter is a bit early this week as I have quite a few things that I need to tie up at
work before I start my leave next Wednesday. Don't worry, the Newsletter will continue until
just before Xmas and then it'll take a short break until the New Year.
The competition for the AfraLisp Logo is now closed. "Voting is now open!!!!" Please visit
http://www.afralisp.com/logo/logo.htm , choose which Logo you think is the best, and cast
your vote. The winner will be announced in next weeks Newsletter.
============================================================================
The Site
The Visual Lisp Tutorials
Some good news!!! The "Visual Lisp" section is up and running. (Fanfare of trumpets.......)
So far, I've posted 5 Tutorial sections, namely :
The Visual Lisp Editor - http://www.afralisp.com/vl/vl-edit.htm
The Beginning - http://www.afralisp.com/vl/vl-begin1.htm
Properties and Methods - http://www.afralisp.com/vl/pm1.htm
Arrays - http://www.afralisp.com/vl/array.htm
Selecting Objects - http://www.afralisp.com/vl/selsets.htm
Cooking Tripe and Onion's - in progress.
Please, just remember!! Visual Basic is NOT a replacement for AutoLisp, it is an extension to
AutoLisp. You will still require a good understanding and knowledge of AutoLisp to code in
Visual Lisp. (knowing VBA also helps.)
So, if you want to have a look at Visual Lisp, tell your wife to shut up and leave you in peace,
phone work and tell them you're sick, grab yourself a six pack of beers, and click on this URL
: http://www.afralisp.com/tutor.htm
Here, you will find a new section listing all the Tutorials dedicate to Visual Lisp.
Just to give you a taste, can you remember in Newsletter No 2001-02 when I included an
article on "Controlling Layering Standards" by Frank Zanders? This routine was written
using VBA. Well here's a similar application I wrote using Visual Lisp and Reactors :
;CODING STARTS HERE
(prompt " \nLoad Only....Do NOT Run...")
(vl-load-com)
;***********************************************************************
(vlr-command-reactor
nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor
nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor
nil '((:vlr-commandCancelled . cancelCommand)))
;*************************************************************************
(defun startCommand (calling-reactor startcommandInfo /
thecommandstart)
(setq OldLayer (getvar "CLAYER"))
(setq thecommandstart (nth 0 startcommandInfo))
(cond
((= thecommandstart "TEXT") (setvar "CLAYER" "4"))
((= thecommandstart "MTEXT") (setvar "CLAYER" "4"))
((= thecommandstart "DTEXT") (setvar "CLAYER" "4"))
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (1 of 6) [23/03/2005 05:50:25 p.m.]
((= thecommandstart "HATCH") (setvar "CLAYER" "6"))
((= thecommandstart "BHATCH") (setvar "CLAYER" "6"))
);cond
(princ)
);defun
;**********************************************************************
(defun endCommand (calling-reactor endcommandInfo /
thecommandend)
(setq thecommandend (nth 0 endcommandInfo))
(cond
((= thecommandend "TEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "MTEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "DTEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "HATCH") (setvar "CLAYER" OldLayer))
((= thecommandend "BHATCH") (setvar "CLAYER" OldLayer))
);cond
(princ)
);defun
;*****************************************************************************
(defun cancelCommand (calling-reactor cancelcommandInfo /
thecommandcancel)
(setq thecommandcancel (nth 0 cancelcommandInfo))
(cond
((= thecommandcancel "TEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "MTEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "DTEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "HATCH") (setvar "CLAYER" OldLayer))
((= thecommandcancel "BHATCH") (setvar "CLAYER" OldLayer))
);cond
(princ)
);defun
;*********************************************************
(princ)
;CODING ENDS HERE
=======================================================
When a user adds Text or Hatch to the drawing, the layer will automatically change to Layer
"4" or Layer "6" respectively. When the command is completed, or cancelled, the user is
returned to the original Layer he was on before he started the command. Save the file as
"LayMan.lsp", BUT please remember, that as this routine contains reactors, you must only
Load it and NOT Run it. If you want to use this routine on a permanent basis, you'll have to
ensure that it is loaded at startup. There is also no checking to ensure that the layers exist,
are frozen, switched off, etc. and no other form of error checking. I've got to leave something
for you to do!!!
================================================================
The Questions
Hi,....
I would like to undefine the (_.attedit)......with the dot
in fact i would like to replace the double click command
without turning off the "dblclkedit" command.
How can i do this...??
tx.
Andrea
=====================================================
Hello,
I am a new programmer in AutoCAD LT 2000. I need to write a program in VB
version 6 to access a drawing, read it, and set default values. In order to this I need to know
what libraries I need to reference. If you could help me I would really appreciate it.
Teresa Walkosz
==================================================================
What is the command name to invoke "bring to front" and " send to back"
I need to make a menu icon group to use it.
Gabriel Cals De Vit
Gabriel - Use these macros :
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (2 of 6) [23/03/2005 05:50:25 p.m.]
Bring to Front
^C^C^P(ai_draworder "_f") ^P
Send to Back
^C^C^P(ai_draworder "_b") ^P
==================================================================
Hi, I would like to replace this......
(setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1))))
(if ss1
(progn....blah ...blah....
to only one selection....like
(setq ss1 (entsel))
but is not working..!!?? why....any one can help me ??
Andrea Andreetti
Andrea,
The first expression is selecting everything in the drawing and filtering the entities. The next
expression, (entsel) only allows you to select a single entitity. Why would you want to filter a
single entity?
Now I stand corrected. Andrea, please make your way along to this site :
http://www.acadx.com
Select "AutoLisp" from the side-bar menu and then "I:EntSelf". This is the description of the
routine. (I nearly "stole" it , but then thought, "Hey Kenny, they probably need the traffic on
their site.")
This routine is useful when you have congested drawings that (entsel) would normally have
fits with. The advantage in this case, is that this routine acts like an (entsel), but really uses
an (ssget) with a crossing box the size of your pickbox. This permits the use of selection set
filters, to give you control over what the user selects.
Author
R. Robert Bell
See, you live and learn.
======================================================
The Answers
The question was :
Is it possible to get a program to select a file just plotted and have it
sent to a backup folder ?
And the answer is :
Copy and paste this coding into Notepad and save it as "EndPlot.lsp". You must only load
this application. "Do not run it, as it contains reactors".
Open the drawing you want to plot, and then load the application : (load "endplot")
Plot your drawing. At the end of the plot the application will first Save the drawing to the
current directory, and then SaveAs, to a directory called "c:/backup/". You can quite easily
change the directory path to suit your backup directory.
;CODING STARTS HERE
(prompt " \nLoad Only....Do NOT Run...")
(vl-load-com)
;*******************************************************
(vlr-command-reactor
nil '((:vlr-commandEnded . endPlot)))
;*******************************************************
(defun endPlot (calling-reactor endcommandInfo /
thecommandend drgName newname)
(setq thecommandend (nth 0 endcommandInfo))
(if (= thecommandend "PLOT")
(progn
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (3 of 6) [23/03/2005 05:50:25 p.m.]
(setq drgName (vla-get-name acadDocument))
(setq newname (strcat "c:\\backup\\" drgName))
(vla-save acadDocument)
(vla-saveas acadDocument newname)
);progn
);if
(princ)
);defun
;*********************************************************
(princ)
;CODING ENDS HERE
===============================================================
Kenny
I offer the following tip for you and your readers.
Upon my return to AutoCAD, after using AES (Architectural & Engineering Series CAD
program), I found AutoCAD was missing one very handy feature that AES had.
In AES it was possible to draw a line from any point to the X or Y component of any other
point.
I was aware that AutoCAD point filters could be used but found them to be very clumsy.
After a bit of poking around, I found I was able to automate the point filters and created the 'X
of...' and 'Y of...' object snaps in the POP0 menu as shown below.
The POP0 menu is found near the top of the acad.mns file which is located in the AutoCAD
'support' folder. Using the WordPad text editor, add the two lines starting with ID_PointXcom
and ID_PointYcom as detailed below. I find these two additions to be absolutely invaluable
as they save drawing and erasing temporary construction lines.
By way of explanation:
Start drawing a line from any point.
Invoke the Osnap menu (shift right click on my computer).
Select 'X of...' or 'Y of...' as required.
The Osnap menu is redisplayed.
You then pick from any of the traditional object snaps (end, mid, int, cen etc...)
You then pick on the required entity and the line is completed from its start location to the X
or Y component of the selected entity.
The above may sound a bit cumbersome but it works very easily and smoothly. Give it a try...
(I have since been told that you can use something called 'tracking' to achieve the same
function. I haven't tried this because I find it hard to imagine that it would be any easier.)
PS - You may notice I have also added 'Mid-way' to the POP0 menu. I stole this from the
Autodesk site. Very handy for drawing a line from and/or to a point midway between two
other points.
Regards
Craig Green
- Part acad.mns file starts here -
***POP0
**SNAP
[&Object Snap Cursor Menu]
ID_Tracking [Temporary trac&k point]_tt
ID_From [&From]_from
ID_MnPointFi [->Poin&t Filters]
ID_PointFilx [.X].X
ID_PointFily [.Y].Y
ID_PointFilz [.Z].Z
[--]
ID_PointFixy [.XY].XY
ID_PointFixz [.XZ].XZ
ID_PointFiyz [<-.YZ].YZ
[--]
ID_PointXcom [X of...]$p0=* ^P(progn (setq pt1 (getpoint "x of: ")) (command ".x" pt1 "@"))
^P
ID_PointYcom [Y of...]$p0=* ^P(progn (setq pt1 (getpoint "y of: ")) (command ".y" pt1 "@"))
^P
[--]
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (4 of 6) [23/03/2005 05:50:25 p.m.]
ID_OsnapEndp [&Endpoint]_endp
ID_OsnapMidp [&Midpoint]_mid
CAL_Mid3D [Mid-way]'CAL;(CUR+CUR)/2;
ID_OsnapInte [&Intersection]_int
ID_OsnapAppa [&Apparent Intersect]_appint
ID_OsnapExte [E&xtension]_ext
[--]
ID_OsnapCent [&Center]_cen
ID_OsnapQuad [&Quadrant]_qua
ID_OsnapTang [Tan&gent]_tan
[--]
ID_OsnapPerp [&Perpendicular]_per
ID_OsnapPara [Para&llel]_par
ID_OsnapNode [No&de]_nod
ID_OsnapInse [In&sert]_ins
ID_OsnapNear [Nea&rest]_nea
ID_OsnapNone [&None]_non
[--]
ID_Osnap [&Osnap Settings...]'_+dsettings 2
- Part acad.mns file ends here -
Thanks Craig, you are an Officer and a Gentleman.
===============================================================
The Back Stoep
Question to my wife :
"How many women does it take to change a light bulb?"
Answer from my wife :
"One. Only ONE!! And do you know WHY? Because no one else in this house knows HOW to
change a light bulb! They don't even know that the bulb is BURNED OUT! They would sit in
the dark for THREE DAYS before they figured it out.
And, once they figured it out, they wouldn't be able to find the light bulbs despite the fact
that they've been in the SAME CUPBOARD for the past 17 YEARS! But if they did, by some
miracle, actually find them 2 DAYS LATER, the chair they dragged to stand on to change the
STUPID light bulb would STILL BE IN THE SAME SPOT!! AND UNDERNEATH IT WOULD BE
THE WRAPPER THE STUPID @*!#$% LIGHT BULBS CAME IN! WHY? BECAUSE NO-ONE
EVER CARRIES OUT THE GARBAGE!! IT'S A WONDER WE HAVEN'T ALL SUFFOCATED
FROM THE PILES OF GARBAGE THAT ARE 12' DEEP THROUGHOUT THE ENTIRE HOUSE.
THE HOUSE!! IT WOULD TAKE AN ARMY TO CLEAN THIS #@*$!#@!... HOUSE!
I'm sorry...what did you ask me?"
Tara the noo,
Kenny Ramage Q.B.E.
===============================================================
AfraLisp : http://www.afralisp.com
===============================================================
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
===============================================================
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
===============================================================
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
===============================================================
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
===============================================================
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
===============================================================
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (5 of 6) [23/03/2005 05:50:25 p.m.]
Bye........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-12
http://www.afralisp.com/newsletter/2001/2001-12.htm (6 of 6) [23/03/2005 05:50:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sent: Thursday, December 06, 2001 11:00
--------------------------------------------------
AfraLisp Newsletter No 2001-13
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
"What's New at AfraLisp?"
http://www.afralisp.com/whatsnew.htm
--------------------------
The Front Stoep
--------------------------
"We have a winner!!!" (thunderous applause from the peanut gallery.)
Congratulations and a BIG well done goes to "Michael DeMott" whose
tremendous "AfraLisp" logo was voted the most likely to succeed by
you. Yes you! The winning logo was No 4 and received 54% of the
popular vote.
A big thank you to all the other contestants and to you, the readers, for
taking the time and effort to cast your votes. Michael's logo will now
become the official trademark of "AfraLisp" and will be proudly
displayed on the website. He will also be the lucky recipient of my band
"BedRock's" new CD Recovery.
http://www.bedrockband.com
Just in case you're wondering, I am now officially on leave and that's
the reason why the Newsletter is a bit early this week. (I'm not used to
sitting doing nothing yet. Just see me in a week or so.)
--------------
The Site
--------------
A new addition to the Visual Lisp Tutorials is "Viewing AutoCAD
Objects".
You would be surprised how many people are not aware of this useful
set of tools.
They're also a great learning guide.
http://www.afralisp.com/vl/view.htm
What do you know about Reactors? Hey, come back, don't run away!!
Believe me, they are a lot easier than you think. In fact, dealing with
reactors themselves,
is the straightforward part. It's the Callback function that requires a bit
of thought and effort.
So, be brave and pop along and have a look at them. It opens a whole
new world to AutoLISP.
http://www.afralisp.com/vl/reactor1.htm
Would you like to be able to delete any entity in your drawing by just
double-clicking
on it? Try this out :
;CODING STARTS HERE
(vl-load-com)
;**************
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (1 of 7) [23/03/2005 05:50:27 p.m.]
(prompt "\nDC-Delete loaded. Do NOT Run.....)
(vlr-mouse-reactor "Delete Object" '((:vlr-beginDoubleClick .
DC-Delete)))
(defun DC-Delete (theReactor thePoint / )
(setq objectPoint (car thePoint))
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets acadDocument))
(setq newsset (vla-add ssets "SS1"))
(vla-selectAtPoint newsset (vlax-3D-point objectPoint))
(setq theObject (vla-item newsset 0))
(vla-delete theObject)
(vla-delete (vla-item ssets "SS1"))
(princ)
);defun
;CODING ENDS HERE
Copy and paste this into the Visual Lisp Editor and save it as
"DC-Delete.lsp".
Now load the application but do NOT run it.
Double-click on any object in you drawing.
Abracadabra.....it's turned into a rabbit, albeit an invisible one.
Can you see the potental for this type of reactor? Double-click on a text
object,
and the text edit box opens. Double-click on a line and the properties
dialog opens.
Double-click on your liquor cabinet and the bar opens. Hey, the
possibilities are endless.
------------------------
The Questions
------------------------
I have over 1500+ document files (*.doc) that need to be renamed into
their original document numbers (this was due to WIN95 character
limitations
in file name size). I have a Excel spreadsheet that tracks the existing
file name and the original file name. Is it possible to write an Autolisp
routine that will read the Excel spreadsheet and automatically rename
the
document file into its original file name?
I hope you can help me.
Thanks.
Peter Rutkowski
Peter, I'll be discussing AutoCAD and Excel/Access in the next week or
so.
Don't move your eyes from this spot. (except to eat, of course).
----------------------------------
Is it possible to change the color of the line in "underlined text" created
with the %%u without changing the color of the text ?
Kevin
Kevin,
I don't know how to change the %%u, but this will do the same job.
Just change the layer/color to suit :
;;;CODING STARTS HERE
(defun C:ULINE ( / textent tb ll ur ul lrx1 y1 x2 y2 p1 p2)
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (2 of 7) [23/03/2005 05:50:27 p.m.]
(setvar "CMDECHO" 0)
(setq textent (car (entsel "\nSelect text: ")))
(command "UCS" "ENTITY" textent)
(setq tb (textbox (list (cons -1 textent)))
ll (car tb)
ur (cadr tb)
ul (list (car ll) (cadr ur))
lr (list (car ur) (cadr ll))
fact (* (getvar "LTSCALE") 0.3)
x1 (car ll)
y1 (cadr ll)
x2 (car lr)
y2 (cadr lr)
x1 (- x1 fact)
y1 (- y1 fact)
x2 (+ x2 fact)
y2 (- y2 fact)
p1 (list x1 y1)
p2 (list x2 y2)
);setq
;;;I use Ltscale as my scaling factor.
(command "LAYER" "M" "10" ""
"PLINE" p1 "W" (* (getvar "LTSCALE") 0.05) "" p2 ""
"UCS" "P"
);command
(princ)
);defun
(princ)
;;;CODING ENDS HERE
Kevin wrote back to me complaining :-))
That worked ok but it underlines the complete phrase. I was thinking
more
along the lines (no pun intended) of an underlined word within a
phrase or
sentence. Sometimes with larger text, the line and text seem to blotch
together. Is it possible that the underline could be changed to another
color for lighter printing
thanks,
Kevin
Any ideas?????
-----------------------
The Answers
-----------------------
Kenny,
I really like Logo #4 and my son Travis seems to think that #10 is the
best.
Keep up the good work and I appreciated the back stoep from this
week's newsletter. Also, as far as classes or seminars for men, I can
only think of one but it would greatly help when relating to others.
Ego management - A weekly class for every man
Elise Bauman
--------------------------
Hi Kenny,
In answer to Kevin's question re. rotating lines from a base other than
0, I
am enclosing a lisp routine that I have
used for several years to rotate the crosshairs to an angle other than 0,
and becomes the new 0 base until reset.
The easiest way to use this routine is simply execute the command, the
default choice is <P> for pick, enter to accept, and select the chosen
line
with the pick box. This then becomes the new X - 0 base line and you
can
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (3 of 7) [23/03/2005 05:50:27 p.m.]
then draw / rotate any other lines from this line with a true angle
selection. When finished execute the command again and the
crosshairs will
return to a normal UCS, includes other options ie. pre-set angles etc.
I cannot claim to be the author of this routine, since the original
version
was one that I picked up somewhere on my travels many years ago.
During some
downtime it was reworked by a lisp guru I was working with, and then
tweaked
again by myself (lisp hacker) over the past 3 years. That's the history,
and it works.
Enjoy visiting your site and looking at the tutorials, just never have
enough time to really get stuck into them. Not sure whether to really
learn
lisp properly or simply jump to visual lisp or even VBA, any
suggestions.
Off for the month of December hey, those were they days (I was a
contractor
in SA for 15 years), now it's work, work, work right up until Christmas
Eve
(beats not working though I guess).
And less of the English jokes as well, or we'll get ourselves back up to
Bannockburn and retake the Scottish Parliament (not sure what we'd
do with
it though, probably close it due to lack of interest).
Cheers,
Kev Knowles
;CODING STARTS HERE
(defun *roterr* (mm)
(setvar "ANGBASE" abase)
(setq *error* olderr)
(princ)
)
(defun rtd (a)
(/ (* a 180) pi)
)
(defun rotgo (an)
(setvar "SNAPANG" an)
(princ (strcat "\nCrosshair rotation angle " (rtos (rtd an) 2 4) "
degrees."))
)
(defun C:ROTATECROSS (/ pl pl1 pl2 angs str anssv midpt endpt)
(setq olderr *error* *error* *roterr* angs nil)
(if (= rot:ans nil) (setq rot:ans "P"))
(if (= (getvar "SNAPANG") 0.0)
(setq rot:ans "P")
(setq rot:ans "R")
)
(setq anssv rot:ans)
(setvar "CMDECHO" 0)
(setvar "SNAPMODE" 0)
(setq rot:ans (getstring (strcat "\nCrosshair ROTATION by
Pick/Select/Angle/30/45/60/Reset <" rot:ans ">: ")))
(if (/= rot:ans "") (setq rot:ans (strcase rot:ans)) (setq rot:ans anssv))
(cond
((= rot:ans "P")
(setq pl (entsel "\nPick line to rotate to :"))
(if (/= pl nil)
(progn
(setq pp (cadr pl))
(setq pl (entget (car pl)))
(cond
((or (= (cdr (assoc 0 pl)) "RAY")
(= (cdr (assoc 0 pl)) "XLINE")
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (4 of 7) [23/03/2005 05:50:27 p.m.]
)
(progn
(setq endpt (cdr (assoc 10 pl)))
(setq angs (angle pp endpt))
(rotgo angs)
)
) ;VALID ENTITIES
((or
(= (cdr (assoc 0 pl)) "LINE")
(= (cdr (assoc 0 pl)) "POLYLINE")
(= (cdr (assoc 0 pl)) "LWPOLYLINE")
)
(progn
(setq midpt (osnap pp "mid"))
(setq endpt (osnap pp "end"))
(setq angs (angle midpt endpt))
(rotgo angs)
)
) ;VALID ENTITIES
((or
(= (cdr (assoc 0 pl)) "MTEXT")
(= (cdr (assoc 0 pl)) "TEXT")
(= (cdr (assoc 0 pl)) "CIRCLE")
(= (cdr (assoc 0 pl)) "ELLIPSE")
(= (cdr (assoc 0 pl)) "ARC")
)
(princ "\nCan't do that entity.")
);INVALID ENTITIES
(t (princ "\nNothing picked."))
)
)
)
)
((= rot:ans "S")
(setvar "ORTHOMODE" 0)
(initget 1)
(setq pl1 (getpoint "\nPick first alignment point : ")
pl2 (getpoint pl1 "\nPick second alignment point : ")
angs (angle pl1 pl2)
)
(rotgo angs)
)
((= rot:ans "A")
(initget 1)
(setq angs (* pi (/ (getreal "\nEnter rotation angle : ") 180.0)))
(rotgo angs)
)
((= rot:ans "3")
(initget 1)
(setq angs (* pi (/ 30 180.0)))
(rotgo angs)
)
((= rot:ans "4")
(initget 1)
(setq angs (* pi (/ 45 180.0)))
(rotgo angs)
)
((= rot:ans "6")
(initget 1)
(setq angs (* pi (/ 60 180.0)))
(rotgo angs)
)
((= rot:ans "R")
(setq angs 0)
(rotgo angs)
)
(t (princ "\nInvalid input."))
)
(setq *error* olderr)
(princ)
)
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (5 of 7) [23/03/2005 05:50:27 p.m.]
(princ)
;CODING ENDS HERE
Thanks Kevin. In regards to your comment about the Scottish
Parliament, I can see
that you seem to have lost your sense of fear!!!
---------------------------
The Back Stoep
---------------------------
Well that's it for this week. I'm now going to start to prepare lunch for
my wife and daughter and open a nice bottle of dry red wine to allow it
to breath. We'll be having lunch today outside in the sun, with just the
fragrance of newly cut grass surrounding us. Peace, quiet and
tranquillity. Eat your hearts out.
I leave you with this :
It can buy a House
But not a Home
It can buy a Bed
But not Sleep
It can buy a Clock
But not Time
It can buy you a Book
But not Knowledge
It can buy you a Position
But not Respect
It can buy you Medicine
But not Health
It can buy you Blood
But not Life
It can buy you Sex
But not Love
So you see money isn't everything.
And it often causes pain and suffering.
I tell you all this because
I am your Friend,
and as your Friend I want to take away your pain and suffering...
So send me all your money
and I will suffer for you.
PS: (cash only please.......)
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (6 of 7) [23/03/2005 05:50:27 p.m.]
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-13
http://www.afralisp.com/newsletter/2001/2001-13.htm (7 of 7) [23/03/2005 05:50:27 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Friday 14th December 2001
--------------------------------------------------
AfraLisp Newsletter No 2001-14
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
--------------------------
The Front Stoep
--------------------------
Welcome , to this weeks AfraLisp Newsletter.
--------------
The Site
--------------
Have you noticed that AfraLisp now proudly displays it's new logo?
Look's nice hey? Thanks again Michael. I also took the opportunity to
re-organise and clean the site up a wee bit. All the main sections stay
in place, but if you have been linking to one of the sub-sections, you
may find the link has changed. Sorry!!!
As I've been busy updating the site this week, I only found time to add
one new section to the Visual Lisp tutorials. This is a tutorial on
Collections and you can find it at :
http://www.afralisp.com/vl/collect1.htm
I've also revised the "Selecting Objects" tutorial to include a section on
"Selection Set Already Exists". You can find this at :
http://www.afralisp.com/vl/selsets.htm
Don't forget, that if you what to find out "What's New" on Afralisp, just
pop
along to this page : http://www.afralisp.com/whatsnew.htm
------------------------
The Questions
------------------------
Kenny,
I am a bit slow on learning visual lisp and reactors.
The concept of a program which enables you to double clicking on
text and bring up the text edit box, as mentioned in your last
Newsletter,
appeals to me as I am still running AutoCAD 2000 which does not
support this feature.
Would it be possible for you to share the required code with us?
Regards
Craig Green
Craig, watch this space. I'm working on it!! (time, time, time).
----------------------
How can I modify the getfield dialog box..??
Or how can I create one ??
Is there any dcl similar ??
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (1 of 7) [23/03/2005 05:50:28 p.m.]
i would like to add a button on it !!
please help me !!
Andrea Andreetti
Andrea, using Visual Lisp functions, you can design your own
"getfiled" dialog. Check out this article by Bill Kramer :
http://www.autodesk-u.com/2000/0500/toolbox0500.html
----------------------------
I am looking for a simple VBA routine to insert title blocks in paper
space at 0,0
and be able to have the block updated or redefined as need be.
Can anyone help?
Tom
Tom, check this out :
http://www.afralisp.com/vba/attabvba.htm
----------------------------
I want to use revsurf command of AutoCAD with VBA to create an
elbow.
It doesn't work, what do I do?
Shariq
-----------------------------
Any Visual Basic for Autocad program that does the following:
1. Select a polyline
2. Find the number of vertices
3. Find the X,Y,Z coodinates of the vertices
4. Export the results to an Excel File.
I need the coding too to learn how to select
and extract properties form a drawing object.
Any ideas....... ?
Boum
Boum, here's a partial solution :
http://www.afralisp.com/lispa/lisp20.htm
-----------------------
The Answers
-----------------------
As things seem to be a bit quiet at the moment and questions and
answers seem to be a bit thin on the ground (I think everybody's on
holiday), I'll give you something to ponder on :
(mapcar) and (lambda).
As you know, LISP stands for "List Processing". There are quite a few
commands in AutoLisp that allow you to manipulate lists. (subst,
append, etc.)
But what about commands that will allow you to apply a function to
items in a list. Let's look at (mapcar) first.
(mapcar).
The function (mapcar) allows you to perform a "function" on each
element of the list.
Let's try a simple example :
What we want to do is add 1 to each element of a list.
(setq a 1)
(mapcar '1+ (list a))
This will return 2.
This is what happened :
(mapcar...adds 1 to the (list a) to make 2.
Now a longer list :
(setq a '(1 2 3 4 5 6 7 8 9 10))
(mapcar '1+ a)
This will return :
(2 3 4 5 6 7 8 9 10 11)
Just a few words on creating lists in AutoLisp.
There are two ways to create lists.
The first way is to use a command that will create a list.
Examples of this are (getpoint) and (entget).
Both of these commands will return a list.
Secondly, you could use the (list) command.
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (2 of 7) [23/03/2005 05:50:28 p.m.]
For example :
(setq a (list 1 2 3 4 5))
If you looked at variable a it would look like this :
(1 2 3 4 5)
The other way of writing this is :
(setq a '(1 2 3 4 5))
Both methods do the same thing, create a list.
Here is another example using (mapcar) :
Say you have a list of data stored in variable arglist
(setq arglist '(12.0 145.8 67.2 "M20"))
You want to place each item in the list in it's own variable to use
in your routine. One way to do it would be as follows :
(setq a (nth 0 arglist))
(setq b (nth 1 arglist))
(setq c (nth 2 arglist))
(setq d (nth 3 arglist))
This works, but is an extremely slow way of processing the data
as each variable requires a programme statement.
A much more efficient way is to use the MAPCAR technique.
(mapcar 'set '(a b c d) arglist)
This routine maps the SET function to each element of the first list
and it's corresponding element of the second list. SET is used instead
of SETQ to evaluate each quoted element of the first list.
With the currently set list c, it sets a to 12.0, b to 145.8,
c to 67.2 and d to "M20".
If you are reading a list from an external file, your routine may not
read back the elements of the list as they once were. Your routine will
read them back as strings. For example :
Your list should look like this :
(10 20 30 40 50)
But after reading the list in from the file, it looks like this :
("10" "20" "30" "40" "50")
You can use (mapcar) to convert the list from strings to integers :
(setq b (mapcar '(atoi) thelist))
Now this works fine if you are using an AutoLisp function, but how
would you
use (mapcar) with a user defined function?
Let's look at this example :
What we have is a list of angles that we want to convert to Radians.
(setq c '(23.0 47.8 52.1 35.6))
Firstly we would write a function to convert degrees to radians.
(defun dtr (a)
(* pi (/ a 180.0))
)
Our function to convert our list would look like this :
(setq d (mapcar '(dtr) c))
This function will run the (dtr) function against each element of list c.
In other words, the value of each element is passed to the (dtr)
function.
The function could also be written like this :
(setq d (mapcar (quote dtr) c))
(lambda).
Now this is where the (lambda) function comes into play.
(lambda) allows you to write the (dtr) function "in-line" within the
(mapcar)
expression without having to define a separate function.
(setq d (mapcar (quote (lambda (a) (* pi (/ a 180.0)))) c))
or
(setq d (mapcar '(lambda (a) (* pi (/ a 180.0))) c))
This function will convert all the angles in the list c to radians
and store them in variable d.
Let's look a bit closer at the (lambda) function.
(lambda (a) (* pi (/ a 180.0)))
is the same as
(defun (a) (* pi (/ a 180.0)))
Let's write a function to test this :
(defun c:test ()
(setq c '(23.0 47.8 52.1 35.6))
(setq d (mapcar '(lambda (a) (* pi (/ a 180.0))) c))
(mapcar 'set '(w x y z) d)
(princ)
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (3 of 7) [23/03/2005 05:50:28 p.m.]
)
!c should return (23.0 47.8 52.1 35.6)
!d should return (0.401426 0.834267 0.909317 0.621337)
!w should return 0.401426
!x should return 0.834267
!y should return 0.909317
!z should return 0.621337
To quote the AutoCad Customization Manual :
"Use the (lambda) function when the overhead of defining a new
function
is not justified. It also makes the programmer's intention more
apparent
by laying out the function at the spot where it is to be used."
In practice, (lambda) can be used anywhere you need a speedy
function
and you don't want the trouble of writing and making sure a (defun)
function is loaded.
----------------------------------
One of the most powerful commands in the Visual Lisp arsenal is the
"vlax-map-collection" function.
Load and run this in the Visual Lisp Editor :
(defun layer-dump ()
(vl-load-com)
(setq theList '())
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'vlax-dump-object)
(princ)
);defun
This will dump all properties of all the Layer objects in your drawing to
the console screen.
You are not limited to Visual Lisp functions within a
"vlax-map-collection" call. You can also use your own user defined
function. Let's say for some reason we wanted to make a list of all
Layers in your drawing, switch all Layers On and change every Layer
in the drawing to Color "5". This is how you could do it :
(defun layerMap ()
(vl-load-com)
(setq theList '())
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'layer-mod)
(princ)
);defun
(defun layer-mod (theLayer)
(setq dwgName (vlax-get-property theLayer 'Name))
(setq theList (append (list dwgName) theList))
(setq theList (reverse theList))
(vlax-put-property theLayer "LayerOn" ':vlax-true)
(vla-put-color thelayer 5)
);defun
As you can see, each Layer object is passed to the function
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (4 of 7) [23/03/2005 05:50:28 p.m.]
"layer-mod" as the argument. You could also write this as an inline
function using "lambda" :
(defun layerMap1 ()
(vl-load-com)
(setq theList '())
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers
'(lambda (theLayer)
(setq dwgName (vlax-get-property theLayer 'Name))
(setq theList (append (list dwgName) theList))
(setq theList (reverse theList))
(vlax-put-property theLayer "LayerOn" ':vlax-true)
(vla-put-color thelayer 5)
);lambda
);vlax-map-collection
(princ)
);defun
---------------------------
The Back Stoep
---------------------------
If the World was fair to Men...
1. Valentine's Day would be moved to February 29th, so it would only
occur on leap years.
2. On Mothers Day, you'd get the day off to go drinking.
3. St. Patrick's Day would be celebrated every month.
4. Instead of "beer-belly", you'd get "beer-biceps".
5. Tanks would be far easier to rent.
6. Every woman that worked would have to do so topless.
7. Birth control would come in ale or lager.
8. When the Police pull you over, every smart-alec answer you
responded with would actually reduce your fine. As in: Cop: "You know
how fast you were going?" You: "All I know is, I was spilling my beer
all over the place. " Cop: "Nice one, That's $20.00 off".
9. Every man would get four, real Get Out of Jail Free cards per year.
10. Telephones would cut off after 30 seconds of conversation.
11. Nodding and looking at your watch would be deemed as an
acceptable response to "I love you".
12. The funniest guy in the office would get to be CEO.
13. "Sorry, but I got wasted last night", would be an acceptable excuse
for absence and/or poor time keeping.
14. Lifeguards could remove people for violating "public ugliness"
laws.
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (5 of 7) [23/03/2005 05:50:28 p.m.]
15. Hallmark would make "Sorry, what was your name again ?" cards.
16. Lager would have the same effect as Viagra.
17. When it was time to leave work, a whistle would sound and you'd
get to slide down the back of a Brontosaurus like Fred Flintstone.
--------------------------------
And my wife's response :
If the World was fair to Men...you would hear your woman utter the
following:
1. You know, I've been complaining a lot lately, I don't blame you for
ignoring me.
2. That was fun. When will all your friends be over to play poker again?
3. The new girl in my office is a stripper. I've invited her over to dinner
on Friday.
4. While you were in the bathroom they went for it on fourth down and
missed. If they can hold them to a field goal they'll still cover.
5. I liked that wedding even more than ours. Your ex-girlfriend has
class.
6. That girl is wearing the same outfit as me. Cool, I'm going to go over
and talk to her.
7. I love hearing stories about your old girlfriends/sporting
triumphs/nights on the town with the guys/war stories/jokes etc, etc.
Tell me more.
8. I like using this new lawn mower so much more than the old one.
What a great Valentines Day present.
9. Let's just leave the toilet seat up at all times.
10. I'm so happy with my new hair do, I don't think I'll ever change it
again.
11. I love it when my pillow smells like your cigars and whiskey.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
You have subscribed to this Newsletter
using the following E-mail address :
mailto:
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (6 of 7) [23/03/2005 05:50:28 p.m.]
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-14
http://www.afralisp.com/newsletter/2001/2001-14.htm (7 of 7) [23/03/2005 05:50:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
***************************************
MERRY XMAS
***************************************
--------------------------------------------------
AfraLisp Newsletter No 2001-15
--------------------------------------------------
19th December 2001
--------------------------------------------------
http://www.afralisp.com
mailto:afralisp@mweb.com.na
--------------------------------------------------
AfraLisp is supported by :
"Contract CADD Group"
http://www.contractcaddgroup.com
--------------------------------------------------
Have you visited this site yet?
http://www.cadchat.com
----------------------------------------------------------
--------------------------
The Front Stoep
--------------------------
As this the last AfraLisp Newsletter for 2001, I would like to wish you
and your family, a very Happy Christmas and a Prosperous New Year.
May the force be with you.
The Newsletter will return in the first week of January, so if you have
any question, or answers, please feel free to send them in. I will be
online throughout the festive season. (maybe not quite sober, but
online!!!)
--------------
The Site
--------------
Stig Madsen very kindly took my VBA Menu coding and translated it to
Visual Lisp.
http://www.afralisp.com/vl/vlmenu1.htm
Nicely written and well worth a look.
Why not have a wee look at Stig's site "InterVision" while you're here :
http://intervision.hjem.wanadoo.dk/
-----------------------------------------------------------
I've also added a tutorial on "Visual Lisp and Errors".
http://www.afralisp.com/vl/vlerror.htm
If you are contemplating coding in VL, you'll need this.
---------------------------------------------------------
Here's a handy little VBA function :
'CODING STARTS HERE
Public Sub ColorToEntity()
'This subroutine sets each entities color from ByLayer
'to the color of the layer it's on.
Dim objEntity As AcadEntity
Dim objMS As AcadModelSpace
Dim objPS As AcadPaperSpace
Dim objLayers As AcadLayers
Dim objLayer As AcadLayer
Dim strLayer As String
Set objMS = ThisDrawing.ModelSpace
Set objPS = ThisDrawing.PaperSpace
Set objLayers = ThisDrawing.Layers
'process ents in modelspace
AfraLisp Newsletter No 2001-15
http://www.afralisp.com/newsletter/2001/2001-15.htm (1 of 4) [23/03/2005 05:50:29 p.m.]
For Each objEntity In objMS
strLayer = objEntity.Layer
Set objLayer = objLayers.Item(strLayer)
objEntity.Color = objLayer.Color
Next objEntity
'process ents in paperspace
For Each objEntity In objPS
strLayer = objEntity.Layer
Set objLayer = objLayers.Item(strLayer)
objEntity.Color = objLayer.Color
Next objEntity
End Sub
'CODING ENDS HERE
------------------------
The Questions
------------------------
I have a site with applications in autolisp.
Please, see at http://www.gr-acad.arq.br
thanks
e.fernal
I think this site is in Spanish.
(well I don't know, I can't speak it can I??)
-----------------------
How can I search the drawing table to see if a block is already defined
using AutoLISP. I think I need to use the TBLSEARCH function.
Russ Johnston
Russ - (setq blockInfo (tblsearch "BLOCK" "MYBLOCK"))
This will return the entity list if True, and nil if False.
-----------------------
What do you think to add CADLAndia
http://www.cadlandia.com
We translate your tutorials in italian on our site.
I'm very happy to see that you buy a domain.
Regards, Aniello
Saluti, Aniello
This is definitely in Italian.
-----------------------
The Answers
-----------------------
Want to create a layer using Visual Lisp?
;;;CODING STARTS HERE
;;;Returns a layer object or nil
;;;on creation failure
(defun mLayer (LayerName)
(vl-load-com)
(setq LayerName
(vl-catch-all-apply
'vla-add
(list
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
Layername
)
)
)
(if (vl-catch-all-error-p LayerName)
nil
LayerName
)
)
;;;CODING ENDS HERE
Bobby C. Jones
AfraLisp Newsletter No 2001-15
http://www.afralisp.com/newsletter/2001/2001-15.htm (2 of 4) [23/03/2005 05:50:29 p.m.]
http://www.acadx.com
---------------------------------------
Have you visited this site yet?
http://www.cadchat.com
---------------------------
The Back Stoep
---------------------------
***VIRUS WARNING***
If you receive an email entitled "Badtimes," delete it immediately.
DO NOT OPEN IT!!!
Apparently, this one is pretty nasty.
It will not only erase everything on your hard drive, but it will also
delete anything on disks within 20 feet of your computer.
It demagnetizes the stripes on all your credit cards.
It reprograms your ATM access code, screws up the tracking on your
VCR and uses subspace field harmonics to scratch any CD's you
attempt to play.
If you drive a Chevy, it will start missing like a Ford.
It will program your phone auto dial to call only your mother-in-law's
number.
This virus will mix antifreeze into your fish tank.
It will drink all your beer.
For goodness sake, are you listening?
It will leave dirty socks on the coffee table when you are expecting
company.
It will cause you to run with scissors and throw things in a way that is
only fun when someone loses an eye.
It will rewrite your backup files, changing all your active verbs to
passive tense and incorporating undetectable misspellings that
grossly change the interpretations of key sentences.
If the "Badtimes" message is opened in a Windows 95/98 environment,
it will leave the toilet seat up and leave your hair dryer plugged in
dangerously close to a full bathtub.
It will not only remove the forbidden tags from your mattresses and
pillows, it will also refill your skim milk with whole milk.
PLEASE, FOR THE LOVE OF PETE, WARN AS MANY PEOPLE AS YOU
CAN!
If you don't send this to 5,000 people in 20 seconds you'll burp so hard
that your right leg will spasm and shoot straight out in front of you,
sending sparks that will ignite the person nearest you.
Just thought you should know.
Tara the noo,
Kenny Ramage Q.B.E.
---------------------------------------------------------
AfraLisp : http://www.afralisp.com
---------------------------------------------------------
Did you miss a newsletter?
Are you a new subscriber?
The "AfraLisp Newsletter Archive" can be found at :
http://www.afralisp.com/newsletter/newsletter.htm
----------------------------------------------------------
To unsubscribe send e-mail to
mailto:afralisp@mweb.com.na?subject=Unsubscribe
stating your reasons in not less than 1000 words.
We will then hunt you down and make you
change your mind.
----------------------------------------------------------
To subscribe to AfraLisp send e-mail to
mailto:afralisp@mweb.com.na?subject=subscribe
----------------------------------------------------------
If you enjoy good music, visit :
"BedRock - The Band in the Sand"
http://www.BedrockBand.com
----------------------------------------------------------
Have you visited this site yet?
AfraLisp Newsletter No 2001-15
http://www.afralisp.com/newsletter/2001/2001-15.htm (3 of 4) [23/03/2005 05:50:29 p.m.]
http://www.cadchat.com
----------------------------------------------------------
All reasonable precautions have been taken to ensure no
viruses are present in this e-mail. AfraLisp cannot
accept responsibility for loss or damage arising from
the use of this e-mail or in fact, anything that goes
wrong with your P.C.
----------------------------------------------------------
Bye........Until Next Year........
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 2001-15
http://www.afralisp.com/newsletter/2001/2001-15.htm (4 of 4) [23/03/2005 05:50:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The AfraLisp Newsletter
****************************************
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Hi Homo-sapiens,
I've started a new section on AfraLisp entitled
"Quick VBA Tip's". Here's a sample :
Highlight Text
When you display a form, it's nice to highlight the text in a particular
text box so that the user does not have to delete the existing text before
typing in his new text string. Here's the coding :
**************************************************************************
Private Sub UserForm_Initialize()
UserForm1.TextBox1.SetFocus
'set focus to the textbox
UserForm1.TextBox1.SelStart = 0
'start at the first character
UserForm1.TextBox1.SelLength = Len(UserForm1.TextBox1.Text)
'highlight the text string
End Sub
*********************************************************************
Double Click a List Box
How do you create a double-click event for a list box?
Easy. From the Double-click event procedure of the list box, simply call the
click event procedure of the OK button :
*******************************************************************
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
CommandButton1_Click
End Sub
*******************************************************************
Private Sub CommandButton1_Click()
'Your coding goes here..............
End Sub
********************************************************************
If you have anything you would like published on this page, just drop me a
line. Remember, (I also have the AutoLisp Tip's and Trick's Page.)
=================================================================
Received this from Peter Lanzone :
Greetings Kenny how are you?
I have a question and hope you can help with this.
The way we have it set up for our engineering drawings is that engineering
AfraLisp Newsletter No 03-05-99
http://www.afralisp.com/newsletter/1999/03-05-99.htm (1 of 4) [23/03/2005 05:50:30 p.m.]
dept has their own server. However I copy all of the .dwg over to the web
server and convert them to dwf with your great util. I was curious if it is
possible for the engineers when they make a new dwg or change one that when
they click save a .dwg will save on their server and the .dwf will come over
to the web server automatically.
Do you happen to have something like that?
thanks!
Peter Lanzone
mailto:pete@essef.com
=============================================================
As I had nothing to do that evening, I decided to knock together a little
application for Peter. It worked O.K. in testing but now Peter's busy trying
it out in the working environment. If you are interested in something like
this, keep your eye on AfraLisp or send me a note.
==============================================================
Here's a new AutoLisp site :
AutoCAD Tech Center
AutoLisp / ARX / menu customization.
GIS/Mapping/GPS AM/FM programming / Data Conversion
http://members.xoom.com/rakesh_rao/cadgis.htm
===============================================================
Hi Kenny,
knowing you for a specialist in AutoCAD-Programming, today I'd like to ask
for your advice.
I have to write some applications for AutoCAD14. I think, it would suit me
best to do it in VB (in which I'm a poor beginner), because I can create an
.exe, and nobody of my favorite workmates ;-) will possibly get silly ideas
to change something in it. The other disadvantage of VBA: Users often run
several instances of AutoCAD, and in this case a vbaload produces a message,
that the VBA-Project can only be opened as write-protected, blahblahblah.
(Or do you know, how to resolve this?)
Will it be useful to make a VB-Application, or will it mean too much
trouble for me?
Could you possibly give me an example, how to start an VB-Application from
AutoCAD and how to get reply to this instance of AutoCAD, which called the
application?
Thanks in advance,
Kathrin
==============================================================
Here's my reply to Kathrin :
Kathrin,
What to use VB or VBA? Let's look at VB first :
1) You can compile it into an EXE file which means the source code is
protected.
2) You can run multiple instances (within reason) of the application.
3) You have more comprehensive controls available but you will need to
distribute them to your users who will then have to install them.
And now VBA :
1) You can give it a password which will give you the same level of
protection as an EXE file.
AfraLisp Newsletter No 03-05-99
http://www.afralisp.com/newsletter/1999/03-05-99.htm (2 of 4) [23/03/2005 05:50:30 p.m.]
2) VBA is an integral part of AutoCAD so you do not need VB to modify
or create your coding. Also, all controls are available to all AutoCAD
users.
In your case, I would recommend VB since you will need to run multiple
instances. I have posted 2 stand-alone VB applications on AfraLisp that will
show you how to connect with AutoCAD. They will also show you how to run a
stand-alone application from within AutoCAD. Hope this helps....
=================================================================
Hi, saw your afralisp site. Nice work! Anyway, I have 9 copies of Autocad
12 for windows to sell for R8500 each, very much usable to upgrade to
Autocad 14 or 2000 at a saving of a couple of thousand Rands. Fully legal,
registered, with dongles, of course. Would you allow me to post a message
to this effect to your mailing list? Any ideas where I could advertise this
as well? I think Autodesk will allow upgrading only for the next couple of
months, and I want to avoid sitting with expensive software I cannot use.
Johan Beyers jnr
Filmatic Packaging Systems
Tel: +27 21 862 2192
Fax: +27 21 862 4605
jbeyersjnr@filmatic.com
http://www.filmatic.com
We are exhibiting at Interpack!
Dsseldorf 6-12 May 1999,Hall 7, Stand 7H17B
================================================================
Right, I'm off to Windhoek. (The "big silver bird in the sky" leaves in 2
hours). All the best and keep well........
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
AfraLisp Newsletter No 03-05-99
http://www.afralisp.com/newsletter/1999/03-05-99.htm (3 of 4) [23/03/2005 05:50:30 p.m.]
Search
Powered by CORBIMITE.com
AfraLisp Newsletter No 03-05-99
http://www.afralisp.com/newsletter/1999/03-05-99.htm (4 of 4) [23/03/2005 05:50:30 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Hi Everyone,
Here's a letter that I've been expecting for some time :
Hi Kenny
It seems that since your VBA class that you have made AutoLisp your second
choice in programming AutoCAD. I mean, you haven't made any more tutorials
about AutoLisp or any new AutoLisp programs at your sight. If I'm wrong please
let met know.
You mentioned once that you have done all you can do with AutoLisp and are
now looking at VBA. Well, AutoLisp is not limited but the programmers
imagination can be, this is actually true about any programming language.
I don't want to be too critical, you have a great sight and are providing a
good public service. What I'm trying to say is I am interested in AutoLisp
programming not VBA or VB or ARX or ADS. If a person is serious about
programming for AutoCAD then AutoLisp and DCL is the way to go. The other
previously mentioned programming languages I consider either TOYS or just
bad approaches to customizing AutoCAD. Just don't forget about AutoLisp!
Joseph E. Willis
=========================================================================
When I wrote that I'd done about all I could do with AutoLisp, I was
refering to the Tutorial Section. (Although, I admit, I was wrong about
that).
Concerning the lack of new AutoLisp applications or Tutorials, I did post
three new tutorials last month and I have a whole new section on User Get
functions and User Input Validation which I hope to have posted within the
next week or so.
I don't agree with what Joseph is saying about AutoLisp being the only
programming language suitable for AutoCAD. Here's an article I wrote for
Randall Raaths "ACAD Code of the Day" concerning this issue :
Visual Basic or AutoLisp?
I've lost count the number of times I've been asked that question. As far as
I'm concerned, it's not a difficult question to answer. Use both......
Each of them have got their strengths and weaknesses.
I mean, look at AutoCAD's DCL language. It's a positive pain in the
posterior designing dialogs in AutoCAD whereas with VB it's a pure pleasure.
And the AutoLisp coding for dealing with dialog's? Say no more. (If you
don't believe me have a look at the AutoLisp code required to hide a
dialog).
On the other side, look how simple it is to deal with blocks in AutoLisp. I
still haven't figured out how to explode a block in VB without resorting to
coding that sends commands to the command line. AutoLisp also deals with
lists in a much more friendlier manner than VB. (Well I think so, so there).
And having to declare all your variable types in VB really threw me at
first. I can now see the reasoning behind it and it does result in faster
more elegant application.
It's difficult to say when and where to use AutoLisp or VB. If you are
having to deal with the operating system or external files, then VB is
AfraLisp Newsletter No 12-05-99
http://www.afralisp.com/newsletter/1999/12-05-99.htm (1 of 3) [23/03/2005 05:50:31 p.m.]
definitely the route to take. On the other hand, if you are doing fairly
straightforward AutoCAD based programming then I would stick to AutoLisp.
I must also mention, that it is much easier to protect your source coding
using VB or VBA. I know you can compile your AutoLisp files if you use
Visual Lisp, but have you seen the size of file that is returned?
So, I've had my say and you've heard the verdict, so stop procrastinating
and start learning AutoLisp AND Visual Basic......
=========================================================================
Here's a difficult one that I hope that one of you can help moi with. I'm
looking for a AutoLisp/VBA function/application/module that can return the
value of a 'recipriversexclusion'. (Ahhh, I hear you yell). This is a number
whose existence can only be defined as being any number other than itself.
I hope you can help me out with this, because, without the solution to this
mathematical mystery, I will never finish my Application nominally entitled
'AutoCAD the Internet and Time Travel'..........
==========================================================================
Garland Freeman sent me this query :
Hi my name is Garland Freeman and I am from the Pittsburgh, PA in the U.S..
I wanted to know if you could tell me if it is possible to write a routine
to automatically purge a drawing before you save?
If you know anything that would help me I would appreciate it.
Thank you,
Garland Freeman Jr.
Drafting/Design
mailto:freemang@aquatech.com
=======================================================================
Here's the coding I sent him :
(defun c:pend ()
(command "PURGE" "A" "" "N")
(command "QSAVE")
(princ)
);defun
(princ)
=======================================================================
Pretty basic, but effective...........
I've had lot's of people e-mailing me with problems with their AutoLisp
routines. On inspecting the coding I almost always find a variable named the
same as an AutoLisp function. Do you know that naming a variable the same as
an AutoLisp function (or even an AutoCAD command name) is one of the most
common bug's. I've done it myself numerous times!!! You can also get a
similar type of bug if you don't declare your variables as local. The
program seems to run fine then all of a sudden it crashes. Nine times out of
ten, it's because you are picking up a value from an undeclared variable in
another function. So, if you have a problem with your AutoLisp routines,
check you variable names and Pleeeease, declare them.
==========================================================================
Now, somebody looking for some help :
Kenny,
I stumbled across your site whilst looking for some bits and pieces for my
Auto Cad Dwgs.
Now as I have never used Cad before I purchased R14 and here I am. Do you
know where I might be able to find some electrical symbols or even some
sites that have some shareware type of things.
If it sounds silly it is that I'm even new to this Internet thing as well.
AfraLisp Newsletter No 12-05-99
http://www.afralisp.com/newsletter/1999/12-05-99.htm (2 of 3) [23/03/2005 05:50:31 p.m.]
Leigh Greig
You can contact Leigh at mailto:brooza@kew.hotkey.net.au
=========================================================================
Well, that's about it for this week. Here, in sunny Namibia we have got a
long weekend coming up. So, if you send me E-Mail and you get no response,
don't worry, I'm not ignoring you, I'm just not in the office. I will pop-in
over the weekend and try and answer some of your queries/suggestions etc.
But, if not, I will be back in the office on Monday.
Cheers for Now...........
P.S. Has anybody seen Elvis today???
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 12-05-99
http://www.afralisp.com/newsletter/1999/12-05-99.htm (3 of 3) [23/03/2005 05:50:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Hi All,
I've had a flood of new subscribers to this Newsletter over the past
week or two. Welcome and Enjoy and please feel free to E-Mail me with any
queries/ suggestions/money that you may have. Any complaints, please send
them to the following address : mailto:rwrath73@worldnet.att.net :-))
==================================================================
I've added a few things to AfraLisp since the last time we spoke.
1) AutoLisp Visual Basic Functions
VBFUNC1.LSP contains Visual Basic type functions for the AutoLisp
programming language. There are quite a few useful functions in VB, which
are not available in AutoLisp that would come in rather handy, especially
if you are a VB programmer working in AutoLisp.
This was sent to me by Roger Farley and you'll find it on the "Other
AutoLisp" Page.
2 )Roger also sent me a good AutoLisp Tip on Applying Points.
You'll find this on the AutoLisp "Tips 'n Tricks" page.
Thanks again Roger, and I'm looking forward to receiving some more
of your good ideas.
3 )I've added two more AutoLisp Tutorials to AfraLisp. The first takes
a close look at the "Eval" function, and the second shows you how to
go about designing an AutoLisp Macro Recorder. Pop along and have a
look.
4) I think I've mentioned before that Randall Raath publishes a daily
newsletter entitled ACAD-A Code a Day, in which he gives extremely
valuable help/explanations/tips etc. on the use of Visual Basic and
AutoCAD. Well, he's very kindly given me permission to post all of his back
issues of the Newsletter on AfraLisp. So, if you are into Visual
Basic, this is the page for you. You can find it at :
http://members.tripod.com/~kramage/rr.htm
=================================================================
Letters :
Here's a free plug :
Hi,
My name is Wendy Clasen. I am the Marketing Assistant at Eagle Point
Software. We develop CAD software for the Architecture, Engineering and
Construction market. Our applications run on AutoCAD, MicroStation,
IntelliCAD, and Stand Alone (No CAD required).
Please consider listing us on your site. Our web address is :
http://www.eaglepoint.com. You may also want to look at
http://www.icadusersgroup.com.
It is an internet-based group for IntelliCAD 98 by Visio.
Please let me know if there is anything else that we need to do.
Sincerely,
Wendy Clasen
AfraLisp Newsletter No 27-05-99
http://www.afralisp.com/newsletter/1999/27-05-99.htm (1 of 3) [23/03/2005 05:50:33 p.m.]
Marketing Assistant
Eagle Point Software
===============================================================
Hello Kenny,
Can you please spare a few minutes to assist me as you have clearly mastered
something I am having problems with. What is the definition of a 'BULGE' ?
In your VBASteel you have created a lightweightpolyline, then defined the
value 'newBulge' to create the root radii. I'm sorry, but I cannot
understand the way 'newBulge' is defined. When I did my steel section VB
programme I had to resort to drawing individual elements. Any assistance
would be appreciated.
Regards
Peter Brown
==================================================================
I sent Peter the explanation of 'Bulge'. It's a little bit to long and
complex to try and explain it here, but if anybody needs to know more about
'Bulge', please feel free to drop me a line.
==================================================================
Sir,
Could you please check the link on your web site to the "Change to reference
layer" lisp routine. It appears to be broken.
Also, would you know of any decent Excel add-on that will convert an excel
spreadsheet to a Acad block, or at least allow you to insert a spreadsheet
into a Acad drawing? I've tried the OLE method, but not too much luck and
problems when emailing drawings to third parties.
Thanks for your time.
David Tennent. mailto:david.tennent@ahw.com.au
==================================================================
Thanks David, it was broken but is now fixed. Next, I have a query from an
old friend of mine :
==================================================================
I am searching for a "helix.lsp" that I can use to create a spring or
circular ramp in 3D. Is there such an animal ?
Regards
Steve Raubenheimer mailto:stever@netactive.co.za
==================================================================
O.K. Enough is enough and the end is nigh.
Talk to you again soon.............
P.S. Coming up soon on AfraLisp :
"Auto-Breaking Blocks" and "Auto-Pipe Shade"......
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

AfraLisp Newsletter No 27-05-99


http://www.afralisp.com/newsletter/1999/27-05-99.htm (2 of 3) [23/03/2005 05:50:33 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 27-05-99
http://www.afralisp.com/newsletter/1999/27-05-99.htm (3 of 3) [23/03/2005 05:50:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Crikey I'm early this week. It must be the weather!! (More likely whether or
not my brain is functioning). Or it could be because it's the first day of a
new month. Or even because it's the last year of this century? Or even
because my cricket team, South Africa, is through to the Super Six in the
cricket World Cup? (Which we are going to win, by the way). Anyway, enough
blathering and on with this weeks items.
First, I received 3 clever applications from Lintang Darudjati :
Hot Blocks v1.2
A block manager with an INI style customization file and a dialog box,
performing collection-grouping, file path display, and slide previews as
'hot thumbnails'. Build your own dwg block library with it, and make them
ready to be inserted easily, anytime.
Slide Factory v1.0
Automates the process of creating multiple slides and slide-libraries. It
creates slide files for all DWG files found in a user-selected folder. It
also creates a slide library file (SLB) if desired. Just select a folder
containing one or more DWG files, and the rest of process is in Slide
Factory's hands.
Layer Color Fixer v1.0
A small program for AutoCAD users. It fixes layer colors for plotting
purposes (via a dialog box) by assigning layer colors to an INI-style config
file that matches specific pen settings.
========================================================
You can download all 3 applications from the "Other AutoLisp" page :
http://members.tripod.com/~kramage/olisp.htm
or directly from Lintangs site at :
http://www.geocities.com/RainForest/1073/
mailto:lintangd@geocities.com
===========================================================
I've also updated the "Acad Code a Day" page. Almost fully up to date, just
got one more week to add. Again, if you are into Visual Basic, Randall
Raaths newsletters have some invaluable information, so pop along and have a
look.
===========================================================
Here's a query I received from Mike Boerner :
Hi Ken..
I read your tutorial on DCL and found it very helpful. I was wondering if
you help me out, or point me in the right direction for the answer to my
next question; How do you enable/disable tiles by using toggles?
Y'know.. if you click on a toggle, it will turn on a previously greyed-out
area and allow the user to select choices from that area..
The ACAD manuals aren't that helpful. They discuss that you SHOULD use
them.. but don't tell you HOW to use them..
I appreciate your time..
Thanks..
Mike Boerner
Westcoast Energy Inc.
(604)691-5156
mailto:mboerner@wei.org
==========================================================
This was my reply to Mike :
Mike,
Let's hope this helps. Say for example you have a radio button with
AfraLisp Newsletter No 01-06-99
http://www.afralisp.com/newsletter/1999/01-06-99.htm (1 of 3) [23/03/2005 05:50:33 p.m.]
the key of "rb6" which tells us that the user has selected a slotted hole.
The following will happen when the user selects the radio button :
(action_tile "rb6" "(setq hole \"slot\")
;store hole type
(mode_tile \"eb1\" 0)
;enable edit box
(mode_tile \"myslider\" 0)
;enable slider
(mode_tile \"eb1\" 2)")
;switch focus to edit box
=================================================
As you can see, "mode_tile" is the command you use to enable or disable
another tile. Mode_Tile has five code values :
0 - Enable Tile
1 - Disable Tile
2 - Set focus to tile
3 - Select Edit Box Contents
4 - Flip Image Highlighting on or off
You can see this in action in a sample application that I wrote as part of
my tutorial "Dialogue Boxes Step by Step" You can find it at :
http://members.tripod.com/~kramage/lisp71.htm
==========================================================
Kenny
I need your help. I have written a routine that I want to operate on
multiple drawings. The sequence goes like this. I select a prototype plan
drawing by dialog box or input prompt. I saveas the drawing to a new name.
The routine then edits the drawing, then the routine saves the changes and
should load the next selected prototype drawing, however the routine stops
upon loading the next prototype drawing. I have the
system variable set to lispinit 0. The routine is in memory but does not
continue on the newly loaded drawing. I know that lisp memory is reloaded on
a per drawing basis if lispinit set to 1. It seems that the .open command
creates problems. Any help will be appreciated.

Andrew
==========================================================
If anyone can help Andrew, you can contact him at :
mailto:AndrewJ@tamsconsultants.com
==========================================================
In being search for nice lisp programs I found your page
It looks very useful, I hope I'll be able to use some things.
I think it's a very good idea to make pages like that, I just started to
discover the power of NET, so I do not really know how to seek and
find what I need.
I was looking for answer for many questions (how to..,and how to..), but
now have one (maybe stupid, but I was almost shot by my boss) the question
is: why I can't plot the True Type fonts if they are made in 255 color?
Maybe is this wrong with me..
Thank You very much.
Kaczor :)
ps1. sorry for English
==========================================================
AfraLisp Newsletter No 01-06-99
http://www.afralisp.com/newsletter/1999/01-06-99.htm (2 of 3) [23/03/2005 05:50:33 p.m.]
You can contact Kaczor at :
mailto:gurbiel@powernet.pl
==========================================================
Dear Kenny,
I've looked at your site (not completely) and I think that you are a Civil
Eng. because of your steel/structural lisp programs. Is it correct? Well,
I'm looking for a lisp code or an auxiliary routine to export an dwg/dxf to
an iges file. (AutoCAD -> ansys)
Do you know some place where I can find it?
Regards,
Pietro Ferrazzo
==========================================================
Pietro can be contacted at :
mailto:costa@fec.unicamp.br
==========================================================
Right, that's it for this week. I'll leave you with a bit of humour :
Did you hear about the two parrots sat on a perch?
One turned to the other and said "Do you smell fish?"
==========================================================
Think about it...................

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 01-06-99
http://www.afralisp.com/newsletter/1999/01-06-99.htm (3 of 3) [23/03/2005 05:50:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Howzit Peoples,
Today I'm feeling slightly discombobulated. (Look it up, I
did!)
I've had a heck of a week but, South Africa are still doing well in the
World Cup Cricket. (Watch it Aussies, we're going to mollicate you on
Sunday).
AfraLisp News
I've added a few new things to AfraLisp :
1) Redefining Commands Tutorial :
Most AutoCAD users know that it is possible to undefine an AutoCAD
command and then redefine it to do something else. But, very few
people seem to use this very useful feature. I find it very handy to
stop people changing system settings that divert from drawing office
standards.
http://members.tripod.com/~kramage/tutor.htm
2) ISO Hole Base Tolerances :
Written By : Pete Best mailto:plbest@global.co.za This routine will
display and print ISO hole base tolerances. (Sorry Pete, I know that you
sent this to me ages ago, but for some reason I forgot about it.)
http://members.tripod.com/~kramage/olisp.htm
3 )Flatten :
FLATTEN sets the Z-coordinates of these types of objects to 0 in the
World Coordinate System:
"3DFACE" "ARC" "ATTDEF" "CIRCLE" "DIMENSION"
"ELLIPSE" "HATCH" "INSERT" "LINE" "LWPOLYLINE"
"MTEXT" "POINT" "POLYLINE" "SOLID" "TEXT"
Written By Mark Middlebrook mailto:markmiddlebrook@compuserve.com
http://members.tripod.com/~kramage/olisp.htm
4) Roughen :
ROUGHEN.LSP: AutoLISP program to "roughen" a polyline. Also Written
By Mark Middlebrook mailto:markmiddlebrook@compuserve.com
Use ROUGHEN when you want to turn a polyline or line into an
irregularly zigzaggy line. For example, you can use roughened lines to
designate existing concrete surfaces that have been roughened for
better adhesion with new concrete.
http://members.tripod.com/~kramage/olisp.htm
5) Random Number Generator on the Tips 'n Tricks Page
http://members.tripod.com/~kramage/tips.htm
6) Referencing DCL Files :
If you look in your AutoCAD Support directory, you will find a file
entitled Base.Dcl. This file contains the DCL definitions for the
basic, predefined tiles and tile types. It also contains definitions
for commonly used prototypes. You will also find Acad.Dcl in this
directory. This file contains the standard definitions of all dialogue
boxes used by AutoCAD. But, did you know that a DCL file can also use
tiles defined in another DCL file by naming the other file in what is called
AfraLisp Newsletter No 11-06-99
http://www.afralisp.com/newsletter/1999/11-06-99.htm (1 of 5) [23/03/2005 05:50:35 p.m.]
an include directory. http://members.tripod.com/~kramage/tutor.htm
7) Functional Synopsis of DCL Files :
Many people have requested a listing of all of the available DCL
tiles alongwith a working AutoLisp example of each tile. In this
tutorial we will have a look at each tile, the DCL coding for it, as well
as the AutoLisp coding required to make the dialogue box tile
functional. http://members.tripod.com/~kramage/tutor.htm
Please note that this tutorial will only be available on-line from
Monday 14th June.
=========================================================================
Letters :
I've got a need for a lisp routine that automatically puts numbers on
telephone jacks as they are put into a drawing. The numbers would have to be
sequential, (it wouldn't work any other way would it?) with me supplying the
first part of the number, i.e. TC1 -1-001. The TC1 is the name of the
telecom room which changes depending on the amount of floors in the
building,
and the amount of telecom rooms per floor. The second number would either be
the rack number, or the patch panel number. This number may or may not
change, depending on the customers standards. The only number that would
need to grow sequentially would be the last number, the 001. If this has
made any sense to anyone some help would be greatly appreciated, thanks!
Steve Cherry mailto:SCherry@mabc.com
=========================================================================
Just what the heck is cricket? I know what A CRICKET is, little buggers with
wings and feet that go criiiiiiick criiiiiick at night, but what is cricket?
Steve Cherry mailto:SCherry@mabc.com
=========================================================================
Answer : Steve, I feel sorry for you. Cricket is like baseball but with
proper rules...
=========================================================================
Would it be possible to set up zip file for the complete month of Acad Code
a Day?
Thanks
Chuck
=========================================================================
I am here to please. You will find it's already been done....
=========================================================================
Pietro,
I saw your message posted in Kenny Ramage's news letter about converting
DWG/DXF to IGES. I believe that you have to purchase a translator to
convert AutoCAD R14 to IGES (you might want to check Autodesks web site to
verify this). I also want to point you to Ansys's web site. They have a
product called DesignSpace. DesignSpace will read models from Autodesk's
Mech Desktop, Solidworks and a few other programs. Hope this helps you.
Here is the link to Ansys's page on DesignSpace.
http://www.ansys.com/Products/DesignSpace/DS/index.html
Don Jacobsen
Richland, WA, USA
=========================================================================
G'day Kenny
I hope you can help me this a AutoLSP problem.
I know how to sort a list of strings alphabeticaly using- ACAD_STRLSORT
EG: (setq random (list "c" "a" "e" "d" "b"))
(setq order (acad_strlsort random))
order would equal- "a" "b" "c" "d" "e"
How can I sort a list containing real numbers?
so the list- (5 3 10 6 2 8 4 7 1 9)
becomes- (1 2 3 4 5 6 7 8 9 10).
AfraLisp Newsletter No 11-06-99
http://www.afralisp.com/newsletter/1999/11-06-99.htm (2 of 5) [23/03/2005 05:50:35 p.m.]
Hope to hear from you soon,
Dave.
=========================================================================
I sent Dave an explanation of sorting in AutoLisp. I cannot post it on
AfraLisp because I stole it. If anybody would like a copy, just drop me a
line.
=========================================================================
Kenny,
In your last e-mail message, dated 6/1/99, you mentioned that this is the
last year of this century. I beg to differ with you. The year 2000 will be
the last year of the 20th century. That is why it is called the 20th
century. It takes 100 years to make a century and since there was no year
0, a century goes from year 1 to year 100.
So I will forgive you for this tiny mistake as you do such an excellent job
on the AutoCAD stuff. But please no more slip-ups on the century stuff in
the future.
Regards,
Mark
=========================================================================
Hey Mark, why have one party when you can have two!!!
=========================================================================
In response to Andrew's question regarding lisp functions and
continuing lisp routines between drawing sessions. I had a similar
problem with wanting to plot multiple drawings. I came upon the
realization then, that lisp, no matter how you slice it, ALWAYS ceases
to continue after opening a new drawing. ie. once the "OPEN" command is
used the lisp routine is broke and will not continue. However, I came
upon a solution which you may find valuable. Rather than write my lisp
program in a xxxx.LSP file I wrote the program in script (xxxx.SCR)
format. The difference is that script will not interrupt because of an
open command. The only minor modification you must do is add the command
"RESUME" as the last command in your S::STARTUP lisp routine and all is
well. The script will continue until the program is complete.
Alternately, you can temporarily add the name of the lisp routine to the
S::STARTUP routine to execute automatically upon opening of the drawing.
This is good if you are using an external database for drawing names and
such that will be lost when the variables are cleared between editing
sessions. Below is an example of a script file.
open "next_dwg"
saveas "new_name"
(c:my_lisp_routine)
save
open "next_dwg"
saveas "new_name"
save
etc....
etc....
etc....
===========================
or you can do this temporarily to do it
(defun s::startup()
(command ".saveas" new_name)
(my_lisp_routine)
(command ".save")
(if next_dwg
AfraLisp Newsletter No 11-06-99
http://www.afralisp.com/newsletter/1999/11-06-99.htm (3 of 5) [23/03/2005 05:50:35 p.m.]
(command ".open" next_dwg)
)
)
The reason this works is because the S::STARTUP function is executed
EVERY time a new drawing is opened. However, it must be defined in the
ACAD.LSP file for it to work. If you do not have one it is a good idea
to create one in order to efficiently run housekeeping routines on
every drawing.
If you need help with a specific problem let me know.
Keith Blackie
BCI Computer Solutions
mailto:blackie@isgroup.net
=========================================================================Tha
nks Keith.....
=========================================================================
Kenny,
Thank you for your "Creating Macros" tutorial. It helped me understand
the basics of writing my own menu.
Anyway, I have a question. I would like to create a simple pull down menu
that opens an html document located on my hard drive. The line in my menu
looks like this:
ID_MnSTD [&Standards]
ID_STD [MBIA-SBD CAD Standards]^C^Cbrowser;c:\temp\Standard.htm
I realized as soon as I ran this the first time that the backslash "\"
kills my intentions. It seems that I need the path to be read as a whole,
but I don't have a clue as to how to accomplish this.
Any suggestions you have would be appreciated and again thank you.
Robert
*****************************************************
Robert T.Cunningham
Matsushita Battery Industrial Corp. of America
Storage Battery Division
Telephone Number: (706) 569-9979
Internet Address: mailto:rcunningham@mbiabattery.com
========================================================================
Robert,
This should work for you. You may have to change the path statements
to suit your setup :
(startapp "c:/program files/internet explorer/iexplore.exe"
"c:/temp/index.htm")
The first part is the name of the AutoLisp function, namely 'startapp'.
The second quoted section is the path to the application you want to start.
(Explorer or Netscape?)
The third quoted section (which is optional) is the name of the file that
you would like to open in the application.
Just remember that you use forward slashes instead of backslashes in
AutoCad.
=========================================================================
Wow, a long one this week. Please keep the letters coming and thanks to
everybody who provided answers to some of our readers queries.
AfraLisp Newsletter No 11-06-99
http://www.afralisp.com/newsletter/1999/11-06-99.htm (4 of 5) [23/03/2005 05:50:35 p.m.]
All the best and have a pleasant weekend......
P.S. What is yellow and lives off dead beetles?
Answer: Yoko Ono!
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 11-06-99
http://www.afralisp.com/newsletter/1999/11-06-99.htm (5 of 5) [23/03/2005 05:50:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
****************************
Hello, Welcome and Hi,
Oh, We are cheerful today, aren't we? That's because I've just
been sat here chuckling, and thinking of some of the stupid
things that I've done (or people working with me have done),
whilst working with AutoCAD and AutoLisp.
Here's a few of the more memorable :
i) Don't phone the IT department yelling and screaming
that your computer cannot connect to the network before
checking that the network cable is plugged into your computer.
ii) Check that there is ink in the plotter cartridge before
dismantling the plotter to find out why it won't plot.
iii) When asked to clean up your drawing directory and move all
completed drawings to the archives, don't move all the
system, PCP, VBA files as well.
iv) When attempting to create a copy of a drawing file, don't
open a blank drawing and save-as the same filename therefore,
overwriting the original file. No, you cannot retrieve
the original drawing.
v) If your system seems to be running slow, check that you
haven't got 5 instances of AutoCAD running. (Everytime
this person left his workstation, instead of closing
AutoCAD, he would just minimise it. On his return, he
would start a new session!!!!)
vi) Don't try and plot using 3mm thick cardboard as a plotter
medium. It doesn't work and tends to damage the plotter.
(Believe it or not, he got one plot before things
went haywire.)
vii) Don't leave stiffy disks on the digitiser. They tend
to get wiped clean!!! (14 instances and still counting.)
viii) Don't add miss-spelt names to the spell checker dictionary.
(even if you're sure the dictionary is wrong). They will
then always be miss-spelt.
ix) If you have drawn something on Acad, calculated it by hand,
and the results differ, you have drawn it or calculate
it wrong. The computer is always correct, it's the user who's
the idiot. (You would be surprised how often I get told
AfraLisp Newsletter No 18-06-99
http://www.afralisp.com/newsletter/1999/18-06-99.htm (1 of 4) [23/03/2005 05:50:36 p.m.]
that the computer made a mistake....)

x) Don't balance tea/coffee/beer on your keyboard. It will
fall off. (We've lost 3 keyboards so far this year....)
And now AutoLisp:
i) Don't name your variables after AutoLisp functions or
AutoCAD commands, e.g., angle, t, point, etc. (I still
tend to do it - what a plonker!!)
ii) Whilst editing an AutoLisp routine, and wondering why
nothing seems to change when you run it, make sure that
you haven't got another copy of the same routine somewhere
in your search path.
iii) Be careful when you open a file to "write" to it. Any
existing data will be lost. (It took me ages to figure
out why I kept on losing all my data in a particular
file. I should have opened the file to "append".)
iv) When writing what you think is a brilliant, new routine
that everybody will want, check that AutoCAD hasn't
already got a command that does exactly the same thing.
(I once spent 6 hours doing something like this.)
v) Don't try and write AutoLisp whilst you're drunk!!!!
You get some very interesting results, and your
coding looks like gibberish the next day.
And one final word concerning Visual Basic.
Don't mess with the system registry, etc. unless you really
know what you are doing.
(I know you warned me Randall, but I had to fiddle.)
Safe Mode here we come....
Have you made a fool of yourself lately? Let me know......
=================================================================
Here's a new AutoLisp Quick Tip's section that I'll incorporate
every week :
This weeks tip may seem quite basic to some of you more experienced
AutoLispers. If that is so, just close your eyes when you read
the next section.
This weeks Quick Tip - Setq
Setq is the basic assignment function and probably the most widely
used function used in AutoLisp, but I still see a lot of coding
written like this :
(setq a 26.0)
(setq b "Bolt")
(setq c pt1)
(setq d a)
But did you know that you can also write the preceding code
like this :
(setq a 26.0 b "Bolt" c pt1 d a)
AfraLisp Newsletter No 18-06-99
http://www.afralisp.com/newsletter/1999/18-06-99.htm (2 of 4) [23/03/2005 05:50:36 p.m.]
or, to make it even more readable:
(setq a 26.0
b "Bolt"
c pt1
d a
)
As you can see, it saves a lot of typing, (which means less room
for error) and is much more efficient and faster.
===============================================================
Have you downloaded Volo View Express yet?
This AutoCAD 2000-compatible viewer supports DWG, DXF, and DWF
files as well as ACIS solids and embedded raster images. You
can view multiple layouts and control layer display and named
views. The download is large (15Mb Full Install; 10Mb Minimum Install) but
is
well worth it and it's FREE!!!
You can download at : http://www.autodesk.com/volo
=================================================================
Letters :
Dear Kenny,
Just to let you know that I have put a link to your site
on my CAD Links page. I hope you don't mind. I've kept
my CAD web page going as a hobby over several years
and have quite a few links on it now. I do not require
that you put a reciprocal link on your page, you can if
you want and may be call it " Australian CAD Links ".
If you do want to put a links in (or just have a look) a
direct URL to my CAD page (bypass my framed index)
Go to :-
<http://www.users.bigpond.com/johncoom/johncooc.html>
If you want to see all of my Framed website, click below
All the best yours John
John Coombes Melbourne Australia
mailto:johncoom@onaustralia.com.au
http://www.users.bigpond.com/johncoom/
==================================================
John has got a lot of interesting stuff on this site, and it's not all
AutoCAD.
===============================================================
Thanks to Dave for this little tip:
How to enter information for the Description
section of "About WHIP"
When viewing a DWF file and selecting About WHIP! from the
right-click shortcut menu, a Description section is shown.
How can information be entered into this section?
This information can be predefined in the AutoCAD R14
drawing before creating the DWF file.
In the R14 drawing, type USERS1 at the command prompt,
and set a value (a description for the DWF file). This
information will then be included when creating a DWF file,
and displayed in the Description section of "About WHIP".
This system variable is not saved in the Registry or drawing.
The information will be lost when the drawing is exited.
AfraLisp Newsletter No 18-06-99
http://www.afralisp.com/newsletter/1999/18-06-99.htm (3 of 4) [23/03/2005 05:50:36 p.m.]
Note: In order to have this functionality in AutoCAD R14, you
need to install the AutoCAD Internet Utilities (AIU) 3.1, even
for R14.01. The AIU can be downloaded from
http://www.autodesk.com/products/acadr14/features/aiu30b.htm
Note: For AutoCAD 2000 the Description information is taken
from the Title section of the Drawing Properties dialog box
found in the Summary tab.
=================================================================
Before I finish, I'd like to leave you with this :
Join the army....
Travel to exotic and foreign countries....
Meet diverse and interesting people....
And kill them....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 18-06-99
http://www.afralisp.com/newsletter/1999/18-06-99.htm (4 of 4) [23/03/2005 05:50:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Hi Everyone,
I've posted a few new thingy-me-jigs on AfraLisp :
DCL Tile Attributes
This tutorial will give you a detailed explanation of all attributes used in
the design and implementation of dialogue boxes used within
AutoCAD/AutoLisp.
I have provided a sample image file of each of the various aspects of
attributes, and the sample DCL Coding that was used to create the dialogue.
The sample AutoLisp coding required to display each dialogue can be found in
the downloadable tutorial.
http://members.triod.com/~kramage/tutor.htm
Watson: Artificial Intelligence
I'm not going to say anything about this. Try it...
http://members.tripod.com/~kramage/olisp.htm
I've also updated the VBA Quick Tips Section :
http://members.tripod.com/~kramage/vbatips.htm
and, of course, Randall Raaths 'A Code A Day':
http://members.tripod.com/~kramage/rr.htm
===============================================================
Letters :
Things I have done:
When you go downstairs to talk to the new young and cute receptionist - make
sure your zipper isn't open. (And I thought it was my great sense of humor
that was making her giggle.)
When making degrading comments about the boss - make sure he isn't standing
behind you.
Things my co-workers have done:
When you type in delete *.* at the DOS prompt and it says "are you sure you
want to delete everything?" Be sure your current directory isn't the root
drive of C:
Before calling me for help because the "erase" command in AutoCAD doesn't
work - make sure you are typing it in correctly at the command prompt.
mailto:DRJACOBSEN@wnp2.com
===============================================================
I enjoy your web site you are providing a great service to those of us in
the cad arena especially in the area of VBA and AutoLisp programming. I
notice that most of your VBA code is based for AutoCAD R14 have you had a
chance to check any of the new features of AutoCAD 2000.
Thanks,
Michael J. Smith
AfraLisp Newsletter No 23-06-99
http://www.afralisp.com/newsletter/1999/23-06-99.htm (1 of 3) [23/03/2005 05:50:37 p.m.]
mailto:mjsmith@catt.com
===============================================================
As I explained to Michael, I haven't as yet received AutoCAD 2000, although
it is on order. (Remember, I'm in the middle of a desert and it gets
delivered by camel.)
================================================================
Hi, I just down loaded your visual basic app for mass purging files. when I
load it in vb6 I get the error msrdc20.ocx not found. When I try and run it
the error active X component not loaded ? do you know if there is a fix to
this. I presume there is a difference between vb5 and 6 do you know if there
is a fix to this
thanks
Graham Steele
mailto:gsteele@wrallp.com
================================================================
Hi Kenny,
Your tutorial about "dialog boxes step by step" is very easy to
understand and helped me to learn a lot about using them in a very short
time. Thank you very much.
But I think there is a little mistake in it:
In samp5 you explain how to add a drop down list, but in the lisp to this
point you add already some code according to the next point about the
slider.
(defun C:samp5 () ;define function
..........
(action_tile "rb1" "(setq hole \"site\")") ;store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;store hole type
(action_tile "rb6" "(setq hole \"slot\") ;store hole type
(mode_tile \"eb1\" 0) ;enable edit box
(mode_tile \"myslider\" 0) ;enable slider
(mode_tile \"eb1\" 2)") ;switch focus to edit box
Greetings, Michael
================================================================
Thanks Michael, I've fixed it.....
================================================================
I'll leave you with this :
Paddy gets a phone call from Murphy.
"Paddy," says Murphy, "Oi've got a problem"
"What's the matter?" replies Paddy.
"Oi've bought a jigsaw and it's too hard, none of the pieces fit
together, and oi can't find any edges."
"What's the picture of?" asks Paddy
"It's of a big cockerel," Murphy replies.
Paddy says, "Alroight, Murphy, Oi'll come over and have a look."
He gets to Murphy's house and Murphy opens the door. "Oh, thanks for
coming, Paddy." He leads Paddy into the kitchen and shows him the jigsaw
on the kitchen table. Paddy looks at the jigsaw, then turns to Murphy and
says, "Fer goodness sakes Murphy, put the cornflakes back in the packet."
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
AfraLisp Newsletter No 23-06-99
http://www.afralisp.com/newsletter/1999/23-06-99.htm (2 of 3) [23/03/2005 05:50:37 p.m.]
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 23-06-99
http://www.afralisp.com/newsletter/1999/23-06-99.htm (3 of 3) [23/03/2005 05:50:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Ground Control to Major Tom,
I've got something quite different this week that I think you all will like.
Randall Rath the "Wonder Llama", has deemed to come down off his mountain
top and contribute some words of wisdom to this newsletter. Enough said,
over to Randall......
=================================================================
Lisp Manager
Lambertus Oosterveen asked for a lisp manager that would show a list of all
lisp files in a given directory and the first couple of remark lines for
each file. I teamed up with Ralph (My wonder Llama from Tibet) to get the
job done, so we are pleased to present Power Tool # 42 (Exclusive to
AfraLisp readers: for $42.00 you can have a stand alone VB project that will
load the selected lisp file into AutoCAD or add all of the selected files as
a menu. Contact Ralph, he has all of the details)...
You will need to open your VBA editor with a new project and add to it a
user form and a normal code module (if you have no idea how to do this, both
Kenny and I have pages on our sites that explain this rather well, but mine
is better) [Who say's so - Kenny] Set the name property of the form to
frmLispManager, don't worry about the name of the code module - the default
name "Module1" is fine.
Now for the controls to add to the form:
One list box - keep default name, "ListBox1"
One text box - keep the default name, "TextBox1"
Four command buttons - keep default names, "CommandButton#" (where # = 1
thru 4)
Arrange the controls however you like to begin with, after you have added
all of the code and run the application, you can move them to an
aesthetically pleasing position and size them to your fancy (Ah, the power
of VBA)! For the form paste in this code:
'Begin Code Block
Option Explicit 'this should be the first line in the code module
Dim strFolderPath As String
Dim strOldPath As String
Private Sub CommandButton1_Click()
Dim colFiles As New Collection
Dim lngFileCount As Long
Dim strPrompt As String
Dim strTitle As String
strPrompt = "Enter the path to your favorite lisp folder"
strFolderPath = InputBox(strPrompt, STR_TITLE)
If strFolderPath <> "" Then
If (Right(strFolderPath, 1) <> "\") Then
strFolderPath = strFolderPath & "\"
strOldPath = strFolderPath
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (1 of 9) [23/03/2005 05:50:38 p.m.]
End If
Else
strFolderPath = strOldPath
Exit Sub
End If
ListBox1.Clear
FindLisp colFiles, strFolderPath
For lngFileCount = 1 To colFiles.Count
ListBox1.AddItem colFiles.Item(lngFileCount)
Next
End Sub
Private Sub CommandButton2_Click()
Dim dblShell As Double
Dim strEditFile As String
If ListBox1.Text <> "" Then
strEditFile = "Notepad.exe " & strFolderPath & ListBox1.Text
dblShell = Shell(strEditFile, vbNormalFocus)
Else
MsgBox "You need to select a lisp file to edit", vbInformation, STR_TITLE
End If
End Sub
Private Sub CommandButton3_Click()
' Reserved for future use - add your code to shell to your favorite lisp
editor
End Sub
Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub ListBox1_Click()
Dim strText As String
Dim strOpenFile As String
Dim intLinecount As Integer
strOpenFile = strFolderPath & ListBox1.Text
TextBox1.Text = ""
On Error GoTo Err_Trap
Open strOpenFile For Input As #1
Do While intLinecount < 3
Line Input #1, strText
If Left(strText, 27) = "AutoCAD PROTECTED LISP file" Then
TextBox1.Text = "Protected Lisp File"
Close #1
Exit Sub
End If
TextBox1.Text = TextBox1.Text & strText & vbCrLf
intLinecount = intLinecount + 1
Loop
Close #1
Exit Sub
Err_Trap:
If Err.Number = "62" Then
If MsgBox("This file has no line breaks, would you like to edit it?",
vbYesNo,
STR_TITLE) = vbYes Then
Shell "notepad.exe " & strOpenFile, vbNormalFocus
Close #1
Exit Sub
End If
Else
MsgBox Err.Description, vbOKOnly, Err.Number
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (2 of 9) [23/03/2005 05:50:38 p.m.]
End If
Close #1
End Sub
Private Sub UserForm_Initialize()
Me.Caption = "Lisp Manager"
TextBox1.MultiLine = True
CommandButton1.Caption = "Select Directory"
CommandButton2.Caption = "Edit With NotePad"
CommandButton4.Caption = "Exit this program"
End Sub
'End Code Block
Now for the normal module add this code:
'Begin Code Block
Option Explicit
Public Const STR_TITLE = "VB Design - Home of 'The Wonder Llama'"
Public Sub FindLisp(colLisps As Collection, strDir As String)
Dim strFiles As String
strFiles = Dir(strDir & "*.*")
Do While (strFiles <> "")
If (Len(strFiles) > 4) Then
If (UCase(Right(strFiles, 3)) = UCase("lsp")) Then
colLisps.Add strFiles
End If
End If
strFiles = Dir
Loop
End Sub
Sub LispManager()
frmLispManager.Show
End Sub
'End Code Block
You can then run the Lisp Manager Macro to see the whole project work. Hey
Lambertus, What do you say to adding a few more functions then sending this
into Cadalyst or entering it into the VBA macro contest at AutoDesk?
=================================================================
Thanks very much for this application Randall. If you are having problems
building this application, I will have it posted on AfraLisp in the near
future.
Randall can be contacted at any of the following :
URL - VBDesign. http://vbdesign.hypermart.net
E-Mail - VBDesign. mailto:vbdesign@xoommail.com
E-Mail - Randall Raath. mailto:rwrath73@worldnet.att.net
Just for interests sake (and to show Randall that I'm as clever as he is), I
decided to build a similar application using AutoLisp. Here's the coding :
DCL Coding First :
///DCL coding starts here
lmanager : dialog {
label = "Lisp Manager - from AfraLisp" ;
: list_box {
key = "selections";
width = 80;
}
: row {
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (3 of 9) [23/03/2005 05:50:38 p.m.]
: spacer { width = 1; }
: button {
label = "&Select File";
key = "accept";
width = 12;
fixed_width = true;
}
: button {
label = "&Edit File";
key = "edit";
width = 12;
fixed_width = true;
}
: button {
label = "&Load File";
key = "load";
width = 12;
fixed_width = true;
}
: button {
label = "&Cancel";
is_cancel = true;
key = "cancel";
width = 12;
fixed_width = true;
}
: spacer { width = 1; }
}
}
///DCL coding ends here
;;;AutoLisp Coding Starts Here
(defun c:lmanager ( / lname userclick userclick1 userclick2 fname flist
rline)
(setq lname nil)
(setq flist '("This List Box will Preview the first 10 lines of"
"a selected Lisp File. Just click on the Select File"
"button to open the Lisp File Dialog Box"

"*****************************************************************"
"If you would like to open the lisp file to edit it"
"in Notepad, click on the Edit File Button."

"*****************************************************************"
"To load the Lisp File click the Load Lisp Button."

"*****************************************************************"
"Brought to you by AfraLisp -
http://members.tripod.com/~kramage/"))
(showdialog)
(princ)
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (4 of 9) [23/03/2005 05:50:38 p.m.]
);defun
(defun getlines ()
(setq lname (getfiled "Select File In Directory To Process" "" "lsp"
0))
(setq fname (open lname "r"))
(setq flist '("Lisp File Preview"))
(repeat 10
(setq rline (read-line fname))
(setq flist (append flist (list rline)))
);repeat
(close fname)
(princ)
);defun
(defun showdialog ()
(setq userclick nil)
(setq userclick1 nil)
(setq userclick2 nil)
(setq dcl_id (load_dialog "lmanager.dcl"))
(if (not (new_dialog "lmanager" dcl_id)
);not
(exit)
);if
(start_list "selections")
(mapcar 'add_list flist)
(end_list)
(if (not lname)
(progn
(mode_tile "edit" 1)
(mode_tile "load" 1)
)
(progn
(mode_tile "edit" 0)
(mode_tile "load" 0)
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (5 of 9) [23/03/2005 05:50:38 p.m.]
)
)
(action_tile
"edit"
"(done_dialog) (setq userclick1 T)"
);action tile
(action_tile
"load"
"(done_dialog) (setq userclick2 T)"
);action tile
(action_tile
"accept"
"(done_dialog) (setq userclick T)"
);action tile
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
);action_tile
(start_dialog)

(unload_dialog dcl_id)
(if userclick
(progn
(getlines)
(showdialog)

);progn
)
(if userclick1
(progn
(startapp "Notepad.exe" lname)
(setq userclick1 nil)
)
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (6 of 9) [23/03/2005 05:50:38 p.m.]
)
(if userclick2
(progn
(load lname)
(setq userclick2 nil)
(alert (strcat "\nFile " lname " Loaded"))
)
)
);defun
(princ)
;;;AutoLisp Coding Ends here
================================================================
Again, I will have this application posted on AfraLisp soon.
================================================================
I received this from Ezhini Natarajn
Hi Kenny,
I have been writing AutoLisp Programs for a while now.
But, I am definitely not a seasoned programmer. When I ran into your
Website.
I am very impressed by your generosity to share your knowledge with
others like me who are trying to learn.
I am in the middle of a little project, but I am stuck. Please see if
you can help. Here is the situation:
;-------------------------------------------------------
There is a list of names as strings:
(setq NameList1 ("name1" "name2" "name3" "name4" "name5"))
Then I have another function such as:
(defun MakeLayer ( LayerName)
;here should I make this LayerName as global or local variable?
(command "layer" "m" LayerName "" "")
)
I want to use each of the elements in the list called NameList1 in the
place of the variable LayerName. So, the function makes so many layers
one after another using the names in the NameList1.
I think some how I could use "mapcar". But I am not sure how I would do
it. I would greatly appreciate any help from you.
-Ezhini Natarajn
=================================================================
Here's the solution I sent him :
(defun c:makelayer (/ NameList1 index name lname)
(setq NameList1 '("name1" "name2" "name3" "name4" "name5"))
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (7 of 9) [23/03/2005 05:50:38 p.m.]
(setq index 0)
(repeat 5
(setq name (nth index NameList1))
(makethelayer name)
(setq index (1+ index))
);repeat
(princ)
);defun
(defun makethelayer (lname)
(command "Layer" "m" lname "")
);defun
(princ)
=================================================================
I also received a great tutorial from Nir Sullam showing how to create a
Progress Bar in DCL:
A DCL Progress Bar Tutorial
Nir sullam mailto:nirsul@actcom.co.il
anySOFT http://www.actcom.co.il/sysoft/freesoft.htm
This short tutorial will teach you how to create a nifty little Progress Bar
in your dialog box. (such as the one in the PLOT dialog box).
This is needed when your program reports the user about its operation and
progress when it usually takes some time.
One example is when you select a large amount of objects and the program
makes some changes to them. If the process consumes time - the program needs
to inform the user in percentage or in numbers.
================================================================
You can find this tutorial at the following URL :
http://members.tripod.com/~kramage/lisp53.htm
================================================================
Here's a little tip for you all :
Manipulating files from within AutoCAD
Did you know that you can move, delete, copy, and rename files that
are in any of the AutoCAD directories from within AutoCAD? To try
this, click File | Open to open the Select File Dialogue Box. Now
highlight one of the files or folders, then right click to open the
menu that allows you to manipulate the files.
You can also move folders inside of other folders to create a tree
structure for drawing files. If you set up a drawing file folder
using Windows Explorer in your AutoCAD directory, you can even
manage your drawing files this way. Don't forget to set up the
AutoCAD preference area to point to your drawing file folder. Just
be careful what you modify, because you could really mess up your
support files.
================================================================
I've also updated the AfraLisp VBA Quick Tip's page with a couple of little
gems. Point your browser to:
http://members.tripod.com/~kramage/vbatips.htm
================================================================
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (8 of 9) [23/03/2005 05:50:38 p.m.]
Well, that's it for this week. But before I go :
Did you here that Randall Raath was bitten by a dog with rabies?
But, after a series of injections and a couple of days in intensive care,
the doctor's said the dog would be O.K. Cheers for this week....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 06-07-99
http://www.afralisp.com/newsletter/1999/06-07-99.htm (9 of 9) [23/03/2005 05:50:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Peace and Goodwill to all Mankind.
How be you all. I be fine. Bit of a quite week. Not much e-mail for a
change. (It must be my deodorant.) Couple of new things on AfraLisp that you
may be interested in.
Firstly, I've started an AfraLisp Message Board. So if you're looking for
help and advice pertaining to AutoLisp or VB, leave a message and I'm sure
some kind sole will help you out of your dilemma.
Secondly, here's something you will probably find very handy:
AfraLisp HTMHelp AutoLisp Tutorial
This is a digested version of all the AutoLisp Tutorials found on the
AfraLisp
Tutorial Page. It is in HTMLHelp format and contains a Contents and Index
section
Thanks to Jim Methven mailto:JImMethven@umist.ac.uk for compiling this
tutorial.
(Jim is Senior lecturer in the Mechanical Engineering Department at UMIST in
Manchester, U.K.)
You can find this at http://members.tripod.com/~kramage/htmlhelp.htm
=======================================================================
Letters :
I'm working for consulting engineers in Cape Town and I am looking for a
lisp routine that will allow me to :
1. Pick points in my drawing which extract automatic the X,Y and allow me to
enter the Z and a description and
2. A routine that draw the batter ticks on a slope.
Thanks
Jochem van Bruggen
mailto:Jochemvb@bks.co.za
=======================================================================
Now here's the embarrassing one :
Hi there Kenny
I thought you might like to know that I have solved my menu problem. The
problem is with the first line 'menugroup=test'. Your tutorial does not show
the = symbol in the first line. I just thought you would like to know,
because there might be other people out there battling to get there menus
running as well.
Regards
Adrian Flack
mailto:adrianf@bks.co.za
=======================================================================
AfraLisp Newsletter No 10-07-99
http://www.afralisp.com/newsletter/1999/10-07-99.htm (1 of 3) [23/03/2005 05:50:39 p.m.]
Thanks Adrian, I owe you a drink.........I've fixed the tutorial and I'm
very sorry if it caused anybody problems. (What a plonker I am!!!!)
=======================================================================
I couldn't resist adding this one :
THE GREAT HANDSOME KENNY:
Superb Site! Why is it that one has to go a third of the way around
the World to find a decent CAD Site? No matter --Your Site is one
of the best I have visited if not THE BEST.
Noticed a small problem with your instructions when I tried to use
some of your lisp routines. Got a Computer--Got a Monitor!
Nothing was said about the fact that I was going to need a
Keyboard and a Mouse would also come in mighty handy. OK got
all that stuff and found out none of the routines would do anything.
What's going on here. Finally with the help of several intelligent
tech support sites the problem was finally diagnosed! HURRAh!
Seems like I also needed AutoCAD. So here we are with all the
appropriate stuff and things are looking a lot better.
Can't seem to get a download on your compressed Tutorial. 80%
of the time I can't make a connection to AfraLisp.exe site. The few
times that I do it starts to download at around 8 to 9 KB a second
and quickly drops down to around 98 BYTES a second and just
seems to hang. Have finished the download about four times but
only 126KB is in the file when I try to execute it and get error
message. Can you Please E-Mail me the file?
Downloaded your error trapper and it is without a doubt the best
that I have come across in six months of searching the WWW.
I agree with you on the idea that the error routine is not
documented very well from AutoDesk along with a couple dozen
other items. Very confusing!
Also have a FEW routines that do not work the way that I would
like. Don't know how you feel about working on NOVICE LISPERS
problems but let me know if you have the time to take a peek.
Thanx in Advance;
Scrutch
mailto:scrutch@wavecom.net
=======================================================================
Scrutch???????
=======================================================================
I went to see the doctor yesterday :
Me: "Doctor, I can see into the future".
Doctor: "When did this start?"
Me: "Next Monday......."
=======================================================================
Enjoy your weekend.....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
AfraLisp Newsletter No 10-07-99
http://www.afralisp.com/newsletter/1999/10-07-99.htm (2 of 3) [23/03/2005 05:50:39 p.m.]
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 10-07-99
http://www.afralisp.com/newsletter/1999/10-07-99.htm (3 of 3) [23/03/2005 05:50:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
****************************
Greetings and Salutations,
I bet you thought you'd got rid of me!! No
such luck. Due to unforeseen circumstances, (work!!) I've been travelling
the length and breadth of South Africa gathering information on the best way
to go about sorting diamonds. Fun, hey. The only nice thing about it was
that I got to fly around in a little Citation jet. (I wish my computer moved
that fast.) Hey, I felt like a millionaire. Every time I boarded the plane I
was giving all the other people at the airport the "royal" wave. No toilet
on board though, so you had to be careful how much champagne and caviar you
consumed. (I should be so lucky...)
Anyway, on to some AfraLisp news. I've only added one new thing to AfraLisp.
That's a "DCL Model". This will show you the function sequence required in
designing a dialogue box using DCL and AutoLisp. You can find it at :
http://members.tripod.com/~kramage/lisp51.htm
I've also revamped the front page. Please let me know what you think and
whether it loads fast or slow.
========================================================================
Sorry, no letters this week as I've got about 200 e-mails that I need to
catch up on. I will be sending out a bumper edition next time alongwith a
couple of new things. (Are you reading this Randall?) So, I'm going to love
you and leave you and finish with this thought.......
"We know the speed of light......
But, does anybody know the speed of dark?"
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

AfraLisp Newsletter No 22-07-99


http://www.afralisp.com/newsletter/1999/22-07-99.htm (1 of 2) [23/03/2005 05:50:40 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 22-07-99
http://www.afralisp.com/newsletter/1999/22-07-99.htm (2 of 2) [23/03/2005 05:50:40 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Houston, we have a problem........
My new Acad2000 package has gone on walk-about. It was put on the truck in
Windhoek and was never seen again. It was supposed to be delivered to me on
Wednesday but now it looks like I'll have to wait for another two weeks for
another copy to be dispatched. Well, this is Africa!!! I'm sorry for not
being able to answer the numerous Acad2000 queries that I receive, but I am
saving them and will get around to dealing with them as soon as possible.
I've finally got around to creating a stand alone, downloadable, HTML
version of ALL the tutorials found on AfraLisp. This includes all the
AutoLisp and DCL source coding. You can find it at :
http://members.tripod.com/~kramage/html.htm
I'm afraid that, even when compressed, it's a bit large (1.8Mb). Sorry!!!!
===========================================================================
Randall Raath has got a brand new VB Application called "Towel". Drop him a
line at mailto:rwrath73@worldnet.att.net for further info. and details on
this superb programme.
===========================================================================
Did you know that 42 is the natural vibration frequency of human and white
mouse DNA?
===========================================================================
Kenny
I know the speed of dark! Zero(0). There is no such thing as dark, it is
only the absence of light.
Regards,
Mark
==========================================================================
Mark, if the speed of dark is zero then what happens if it slows down even
further to say -100. Does this mean that everything starts to look like a
negative photograph?
==========================================================================
Hey there Kenny - Ken Dispoto here.
I'm the fellow who asked for your help in getting a plot date stamp lisp
routine.
Thanks for putting one together - I works pretty good!
My question today is not as involved (I don't think).
I would like to find a way to insert symbols (fuses, contacts, sw's, etc)
into a horizontal or vertical line and have the line break around it. Have
you anything tucked in your bag of tricks?
Thanks again - and keep cool!
Ken D...
==========================================================================
Hi Kenny,
AfraLisp Newsletter No 30-07-99
http://www.afralisp.com/newsletter/1999/30-07-99.htm (1 of 4) [23/03/2005 05:50:41 p.m.]
I wrote to you a couple of weeks ago about getting a routine that I was
working on to work. This routine would allow a user to pick 2 points after
a block was inserted and would break that line between the 2 points. I
guess I could also do it by having the btrim command invoked right after it
was inserted that way might be better. Anyway you said that you were
working on something like that and that you would post it on your web page
so I was wondering if you've posted it somewhere else in your new layout and
I missed it?
Thanks in advance,
Tim K.
===========================================================================
O.K. guys, I get the message. You will find a tutorial complete with a
sample application for Auto-Breaking Blocks on AfraLisp at the following
URL:
http://members.tripod.com/~kramage/lisp52.htm
Now don't ever say that I'm not good to you!!!
===========================================================================
Hi Kenny,
Do you know if there is a Lisp Manager available that shows all the Lisp
routines in a chosen directory at the left and the first REMark lines in
the Lisp routine at the right.
I think with such an application a lot of AutoCAD users would be very happy.
Best regards,
Lambertus Oosterveen
mailto:l.oosterveen@royalhuisman.com
===========================================================================
Sounds like a good idea. Anybody know of anything like this?
===========================================================================
Dear Kenny,
I Am still quite new to VB, as you might guess from my question none the
less I am trying. I need to code for simple tasks such as cut, copy, paste,
bold, and align. I would be grateful for your expert help,
Thank you Kindly
Ronnie van Wyk
Mailto:julron@lantic.co.za
===========================================================================
What is the VBA equivalent to EntGet in AutoLisp and how do you extract the
dxf codes of AutoCAD entities.
John Rodrick
mailto:johnr@apptechsys.com
===========================================================================
Did you know that light reflects off water at 42 degrees to make a rainbow?
===========================================================================
This code below gets me the name of the group of an object in AutoCAD, along
with the name is a description field in the group command in AutoCAD how do
I access this in VB. I can not find a property for the value that is in the
description field when I create a group in AutoCAD.
Private Sub Command1_Click()
Dim AcadApp As Object
Dim AcadDoc As Object
Dim gpitem As Integer
Set AcadApp = GetObject(, "AutoCAD.Application")
Set AcadDoc = AcadApp.ActiveDocument
AcadApp.Visible = True
If Err Then
Err.Clear
'Start AutoCAD if it is not running.
Set AcadApp = CreateObject("AutoCAD.Application")
If Err Then
AfraLisp Newsletter No 30-07-99
http://www.afralisp.com/newsletter/1999/30-07-99.htm (2 of 4) [23/03/2005 05:50:41 p.m.]
MsgBox Err.Description
Exit Sub
End If
End If
For gpitem = 0 To AcadDoc.Application.ActiveDocument.Groups.Count - 1
groupname = AcadDoc.Application.ActiveDocument.Groups.Item(gpitem).Name
MsgBox groupname
Next
AcadApp.Update
End Sub
John Rodrick
mailto:johnr@apptechsys.com
==========================================================================
This week I'm going to finish off with something completely different :
Life in the 1400's (1442 to be exact)
Most people got married in June because they took their yearly bath in May
and were still smelling pretty good by June. However, they were Starting to
smell, so brides carried a bouquet of flowers to hide the b.o. Baths equaled
a big tub filled with hot water. The man of the house had the privilege of
the nice clean water, then all the other sons and men, then the women and
finally the children. Last of all the babies. By then the water was so
dirty you could actually loose someone in it. Hence the saying, "Don't
throw the baby out with the bath water".
Houses had thatched roofs. Thick straw, piled high, with no wood
underneath. It was the only place for animals to get warm, so all the pets
dogs, cats and other small animals, mice, rats, bugs lived in the roof.
When it rained it became slippery and sometimes the animals would slip and
fall off the roof. Hence the saying, "It's raining cats and dogs," There was
nothing to stop things from falling into the house. This posed a real
problem in the bedroom where bugs and other droppings could really mess up
your nice clean bed. Therefore, they found that if they made beds with big
posts and hung a sheet over the top, it addressed that problem. Hence, those
beautiful big 4 poster beds with canopies. The floor was dirt. Only the
wealthy had something other than dirt, hence the saying "dirt poor". The
wealthy had slate floors that would get slippery in the winter when wet. So
they spread thresh on the floor to help keep their footing. As the winter
wore on they kept adding more thresh until when you opened the door it would
all start slipping outside. A piece of wood was placed at the entryway,
hence a "thresh hold".
They cooked in the kitchen in a big kettle that always hung over the fire.
Every day they lit the fire and added things to the pot. They mostly ate
vegetables and did not get much meat. They would eat the stew for dinner
leaving leftovers in the pot to get cold overnight and then start over the
next day. Sometimes the stew had food in it that had been in there for a
month. Hence the rhyme: peas porridge hot, peas porridge cold, peas
porridge in the pot nine days old."
Sometimes they could obtain pork and would feel really special when that
happened. When company came over; they would bring out some bacon and hang
it to show it off. It was a sign of wealth and that a man "could really
bring home the bacon." They would cut off a little to share with guests and
would all sit around and "chew the fat."
Those with money had plates made of pewter. Food with a high acid content
caused some of the lead to leach onto the food. This happened most often
with tomatoes, so they stopped eating tomatoes... for 400 years.
Most people did not have pewter plates, but had trenchers - a piece of wood
with the middle scooped out like a bowl. Trencher were never washed and a
lot of times worms got into the wood. After eating off wormy trenchers,
AfraLisp Newsletter No 30-07-99
http://www.afralisp.com/newsletter/1999/30-07-99.htm (3 of 4) [23/03/2005 05:50:41 p.m.]
they would get "trench mouth."
Bread was divided according to status. Workers got the burnt bottom of the
loaf, the family got the middle, and guests got the top, or the "upper
crust".
Lead cups were used to drink ale or whiskey. The combination would
sometimes knock them out for a couple of days. Someone walking along the
road would take them for dead and prepare them for burial. They were laid
out on the kitchen table for a couple of days and the family would gather
around and eat and drink and wait and see if they would wake up. Hence the
custom of holding a "wake". England is old and small and they started
running out of places to bury people. So, they would dig up coffins and
would take their bones to a house and re-use the grave. In reopening these
coffins, one out of 25 coffins were found to have scratch marks on the
inside and they realized they had been burying people alive. Therefore,
they thought they would tie a string on their wrist and lead it through the
coffin and up through the ground and tie it to a bell. Someone would have to
sit out in the graveyard all night to listen for the bells. Hence on the
"graveyard shift" they would know that someone was "saved by the bell" or he
was a "dead ringer".
===========================================================================
Have nice weekend.....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 30-07-99
http://www.afralisp.com/newsletter/1999/30-07-99.htm (4 of 4) [23/03/2005 05:50:41 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Happy Birthday to Us,
O.K. I know it's not quite Friday, but I've got to say it sometime.
It's been an interesting year. I started off AfraLisp with the intention of
creating a small AutoLisp site for a few of my buddies and myself. I then
started with the Tutorials and the bug bit me. AfraLisp has had over 28000
visitors in the past year, that's about 2400 per month. I've received
hundreds of E-Mails from all over the world asking for help and advice and
I've also received lot's of E-Mails giving help and advise. I must say that
I have enjoyed every minute of it. Thanks to you all for making it such a
super year and let's hope the next year is just as good, if not better.
On this, the first birthday of AfraLisp, I hereby present to you, (at no
charge, and no strings attached,) a special BIRTHDAY SURPRISE from AfraLisp.
This is an incredible AutoLisp application never before seen in the realms
of AutoCAD, and for that matter, in the realms of any other CADD package.
To use it is simple. Just download Birth1.Zip and unzip the LSP and DCL
files into any directory in your AutoCAD support path. Then type (load "birth1")
at the command prompt and then birth1 to run.
Note: You must have a drawing open for this application to work correctly.
Any drawing will do, but the larger the drawing, with lot's of detail, the
better.
You can find the AfraLisp Birthday Surprise at :
http:\\members.tripod.com\~kramage\birth.htm
Enjoy..............................
==========================================================================
Oh, by the way. I've updated Randall Raath's "A Code A Day". The whole of
the month of August is now available for download. You can find it at :
http:\\members.tripod.com\~kramage\rr\rr.htm
==========================================================================
No letter's this week, I'm afraid, 'cos it's our birthday, but here's
something you may enjoy.
The Five Stages of an AutoCAD Draughtsman
i) ILLITERATE - you wouldn't lower yourself to learning AutoCAD. If
AutoCAD skills were bullets, you'd still be hunting with a bow. You can be
heard muttering darkly about the joys of Microstation. Small children are
afraid of you. Your wife's name is Mildred and your hobby is Serbian
match box collecting. You think that the Internet is evil and should
be censored. (preferably by Jesse Jackson.) You use a moped to commute to
and from work. You wear Brylcream.
ii) NOVICE - you grudgingly learn the bare minimum that it takes to keep
your job. You often find ways to convince others to press keys on your
computer. Your drawings are never to scale. You "invent" your own layering
system. (for each different drawing??) You have never opened any of
the AutoCAD Manuals. Your breathe normally smells of alcohol, dope or
AfraLisp Newsletter No 02-08-99
http://www.afralisp.com/newsletter/1999/02-08-99.htm (1 of 2) [23/03/2005 05:50:42 p.m.]
onions. (often all three.) You are a shop steward in the union. You
named your son "Chuck", after yourself and refer to him as "Junior".
iii) APPRENTICE DRAUGHTSMAN - you readily learn how to draw on the
computer. "It won't plot!!" is your theme song. You do silly
things like loosing your toolbars and deleting system files. You will
quite happily fiddle with the System Registry without breaking out into a
cold sweat. You've read through all the AutoCAD Manuals twice, without
understanding one single word. You are in awe of people who can write
AutoLisp routines.
iv) JOURNEYMAN DRAUGHTSMAN - you have a bag of tricks that makes AutoCAD
a breeze. You enjoy trading techniques with others, and learn as often
as you teach. You always have the best screensaver. Apprentice Draughtsmen
call you "Sir". You have drawn on a board. You claim that you are paid
to think, not to draw, and that AutoCAD is just another tool to help you
draw quicker. The bosses enjoy talking to you. You are slowly wading
your way through the intricacies of AutoLisp.
v) MASTER DRAUGHTSMAN - you have forgotten more about AutoCAD than most
people will ever know. You have a transcendent grasp of the trade-offs of
each and every decision made in a drawing. You understand the AutoCAD
Customisation Manual. In fact, you go to bed with it. You enjoy
programming in DCL. The bosses do not understand a word you say. You wear
different coloured socks. Your dream in life is a new AutoCAD Upgrade but
then you get pissed off when it still doesn't do what you want it to do.
You named your first child "Setq".
As Always,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 02-08-99
http://www.afralisp.com/newsletter/1999/02-08-99.htm (2 of 2) [23/03/2005 05:50:42 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Greetings Earthlings,
I must apologize for missing last weeks letter but
I've been down with the flu and I've (Again!!) been away on business.
(Botswana this time...)
This week I'm going to dedicate the letter to readers questions. So please,
if you think you can help, drop the poor soul a line and try and put him/her
out of his/her misery. (Got to be politically correct you know.) Here we
go...
Letters :
Dear Kenny
I've found your tutorials very helpful and I would be very grateful if you
could help me solve a problem.
I need to write a lisp routine which gets its variables from another file
(*.txt or *.xls). How do I open the file and get the variable values?
For example, if I want to draw a rectangle with points a,b,c,d and I have a
file where a=2,3 b=6,3 c=6,5 d=2,6 in one instance and different values for
a,b,c,d in another instance, how should I write the AutoLisp code for
opening a file to refer to its data, run the AutoCAD commands and then close
the file?
Please send me a small example. I need it very much to enable me to get
employment in a drafting firm.
Please e-mail me at mailto:misquita@webace.com.au soon.
Thank you very much
Mark Misquitta
(an Indian who has just migrated to Australia)
=======================================================================
Sir,
I'm taking the liberty of approaching you with a specific problem that I
can't seem to solve, even with a pile of manuals, as the manuals only seem
to cater for procedures providing everything goes right first time.
Judging from the material that you published it appears as if you know
what your talking about.
Problem :
When loading a partial menu using the "tools , customise menu" method, the
partial menu that is loaded is lost every time the program is closed. Why
does it only loose only certain partial menu's? Is there a link between
the loaded partial menu and the actual location of the said menu? In this
case, I placed all the partial menu's in the "support" folder, where all the
standard menus reside. Surely there should be no problem finding the
partial menu upon starting up. What points the starting up procedure towards
the
specific partial menu?
Please help, the so called boffin supplier that I bought the software from
doesn't know how.
AfraLisp Newsletter No 15-08-99
http://www.afralisp.com/newsletter/1999/15-08-99.htm (1 of 5) [23/03/2005 05:50:43 p.m.]
Regards
Andreas Blignaut
Johannesburg
mailto:lublig@iafrica.com
=======================================================================
Kenny,
I am trying to extract a "Bill of Materials" from my drawings. The
attributes
are a product code number and a quantity. The idea being to export this
information into a spreadsheet where pricing etc will be added. I use
attributes that are assigned to blocks and therefore when I insert the block
into the drawing I can select which attributes are required for the project.
The problem being if I assign say ten attributed to one block and then array
that block twenty times then extract the attributes to a comma delimited
file I end up with twenty lines of junk, which have to be processed before
dumping them into a spreadsheet. (which I have not managed to accomplish.)
I tried to use a routine where I selected a selection set, and which
returned the entity information, except there was no information which
related to the attributes assigned to the selected inserted block. This is
where I require your expertise. Below is an idea of how I
would like my information extracted - eventually!!
Code Qty
QSCB25 123
QSS150 300
etc.
What would you suggest and how would I go about it?
I have tried to obtain help from others on this issue but to no avail.
I will appreciate any information you could give me.
Regards
Paul
mailto:nufdraw@global.co.za
=======================================================================
Hi Kenny,
Here is a trial I made and got stuck!!! Please see how I can get over the
hurdle here:
;Dwginfoi.lsp
;Collects pieces information about the drawing and attaches
;them as extended entity data to a selected entity
;----------------------------------------------------------
;**** MY QUESTION ****
;I have trouble constructing lists with dotted pairs in them
;like the associative code - period - the data with out quotes marks as in
strings
;How can I collect the information such as dwgname, dwgprefix, date, time
;etc and then construct a list to pass that as the -3 associative and
;append that to the existing entity data list?
;----------------------------------------------------------
(defun c:dwginfoi (/ UserName ThisDwgName ThisObject OldXDataList
NewXDataList a1 a2 b1 c1)
(setq
UserName (getvar "loginname")
ThisDwgName (getvar "dwgname")
AfraLisp Newsletter No 15-08-99
http://www.afralisp.com/newsletter/1999/15-08-99.htm (2 of 5) [23/03/2005 05:50:43 p.m.]
) ;collecting some
information later I will add a few more items
(setq a1 (list 1000 UserName)) ;the value returned by UserName is a string
in quotes
(setq a2 (list 1000 ThisDwgName)) ;same here so they dont work as dotted
pair when i try to append later
(setq b1 (list 'EzXData a1 a2))
(setq c1 (list -3 b1))
(setq ThisObject (entsel "\nPick an Object")); Here I let the user pick an
object, later it will be automated to pick a certain block using tblsearch
(setq OldXDataList (entget (car ThisObject)))
(regapp "EzXData")
(setq NewXdataList (append OldXdataList c1));Here i am trying to append the
list c1 to the existing entity data list
(entmod NewXdataList)
);end of lisp
(princ);exit quietly
;-------------------
Thanx Kenny.
-Ezhini
mailto:enatarajan@jkaarchitecture.com
=======================================================================
Hi. I have a question regarding VB for AutoCAD.
I don't have any knowledge about VB/VBA for ActiveX AutoCAD.
I am looking for a most convenient way to simulate 3D objects for my
project.
I have a project which needs to simulate a robot arm graphically.
Can VB/VBA simulate the arm which has six joints? The graphical joints
should be controlled independently with certain angles and lengths
according to user's input. Is it too complicated for VB? Or is there any
other way for my purpose rather than using C++ with other graphical
libraries?
Please, help me out. I'd like to be in a right direction.
Thanks.
Yong-Kwon Cho
mailto:choyk@mail.utexas.edu
=======================================================================
Hi Kenny.
I have viewed the AfraLisp page and have a question. We have a database in
Microsoft Access. The database contains data on various points. Such as
height of an object, type of the object and so on. This information is then
required to be used in AutoCAD to draw the point at the coordinates given
along with selected characteristics of the point. Sometimes the points are
not continuous. Do you have any suggestions.
Joseph Sukhnandan
mailto:jsukhnandan@bel.com.bz
=======================================================================
Dear Kenny
I contacted you last week with regard to attribute extraction. You suggested
I read your Exbolt.lsp file which I have
done, and I learnt a great deal in terms of modifying entity lists, but I
have to admit I am lost (two bottles of Bell's later!) and need your advice.
Lets assume I want to assign two bolts to the selected hole (God knows
why!!!), how do I modify my entity list to show both bolts and their
respective sizes and grades, and in fact repeat should I want to select yet
another bolt, and inform the user?
Look forward to your reply
AfraLisp Newsletter No 15-08-99
http://www.afralisp.com/newsletter/1999/15-08-99.htm (3 of 5) [23/03/2005 05:50:43 p.m.]
Regards
Paul Butler
Durban, South Africa
mailto:nufdraw@global.co.za
=======================================================================
Kenny
I'm trying to build parametric models of a circular grid.
The trouble is I can't find a way of building it using mechanical desktop
(runs on top of AutoCAD r14).
In there plan view, there are 4 sections to the grid held together by a
supporting structure. The grid is then made up of criss-crossed rods at a
certain distance apart
from each other. Therefore, if the size of the overall grid increases more
rods will have to be added to the model.
-Do you know how I can do this?
I've been trying to write an AutoLisp program on mechanical desktop which
can determine the number of rods required and draw them. However drawing
them is the
problem - I don't know how I can show the intersections between the rods
and the supporting structure. At the moment I'm using
3d faces for the supporting structure and solid cylinders
for the rods - these were inputted by using a lisp macro. The cylinders
simply don't intersect with the 3d face. I don't
know if should be using a supporting structure which is solid rather than
just a 3d face - but then again I don't know where to find sample AutoLisp
code which
shows how to create solid objects and join them together.
I'm desperately stuck with this problem and need to find a solution
quickly. If you can offer any advice, no matter how small, on how I could
model this grid ( 3d, or 3d solid, or even 2d) on mechanical desktop- I
would be extremely grateful.
Thanks for your time
Dave Dormer
mailto:david.dormer@strath.ac.uk
=======================================================================
Kenny,
I posted a message earlier and it is not on the board anymore. I
have not
look recently for responses, have I missed it or is there a way to look at
it again. The subject was auto purge in mechanical desktop.
Thanks for your help
Mark Ruback
=======================================================================
Mark, the messages on the board are automatically deleted after 2 weeks. I
suppose I really should change it to a month, or even longer. Any
suggestions?
=======================================================================
That's all Folk's. Speak to you next week. I'd like to leave you with one
thought :
Y2K?
Because it's there...
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
AfraLisp Newsletter No 15-08-99
http://www.afralisp.com/newsletter/1999/15-08-99.htm (4 of 5) [23/03/2005 05:50:43 p.m.]
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 15-08-99
http://www.afralisp.com/newsletter/1999/15-08-99.htm (5 of 5) [23/03/2005 05:50:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http:\\members.tripod.com\~kramage\
mailto:kramage@namdeb.com.na
****************************************
Welcome Lisper's and VB'rs,
I don't know if you are aware, but it will
be AfraLisp's first birthday next week Friday. (3rd September.) I am going
to have something *special* available for you on AfraLisp to celebrate our
coming of age, so pop along on Friday and have a look. Remember, it will
only be available Friday the 3rd:-)).
By the way, it's a long weekend this weekend in Namibia. I will not be in
the office from Thursday through till Sunday. (I'm going through to Luderitz
with the band for the German carnival. Oh my poor liver!!!) So, if you send
me any e-mail and I don't reply immediately, you know the reason. I'll try
my best to get back to you sometime on Monday.
=========================================================================
I received a cracker of a Visual Basic application from Ramon Castro
(mailto:RamonC@ci.ftlaud.fl.us). called RC-Batcher. This is a very useful
tool that allows you to select multiple files from multiple directories, and
then run any user defined AutoLisp routine against them. Very, very handy
for batch processing. You can find it at :
http:\\members.tripod.com\~kramage\vba14.htm
=========================================================================
Letters:
Hi the Kenny
A quick query!! (even though the answers are not always so quick.)
What is the difference between Lisp, Visual Lisp, and Visual Basic, and
which would you say is the best to use for writing programs for AutoCAD?
(Using Release 14.) If Visual Lisp is the way to go, where can I get a
compiler/editor?
Regards,
Adrian Flack
mailto:adrianf@bks.co.za
=======================================================================
Adrian,
AutoLisp is a subset of the Lisp language specially modified to suit
AutoCAD. The AutoLisp interpreter is build into AutoCAD therefore, AutoLisp
files do not need to be compiled. Visual Lisp is a new version of AutoLisp
that is basically the same except that you can compile the AutoLisp files.
It also has it's own graphical interface that you must use to be able to
edit and compile the files. (Normal AutoLisp can be edited using any ASCII
text editor such as Notepad). Visual Lisp and any subsequent compiled
AutoLisp files can only be used with R14 and R2000. You have to purchase
Visual Lisp for use with R14 (available from Autodesk) but it is build into
R2000.
Visual Basic is a descendant of the BASIC programming language first
developed
in the 1960's. BASIC (which is short for 'Beginner's All-purpose Symbolic
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (1 of 9) [23/03/2005 05:50:44 p.m.]
Instruction Code') is probably well known to most computer programmers.
Microsoft Visual Basic allowed programmers to create stand-alone Windows
applications which previously required the use of complex C programming
languages. Visual Basic for Applications is a subset of Visual Basic,
designed
specifically for certain applications such as MS Word, Excel, Access, etc.
With the release of AutoCAD R14, AutoCAD included VBA as part of the
AutoCAD package. VBA for AutoCAD includes most of the functions and controls
available in the stand-alone version of Visual Basic alongwith certain
functions
and controls specifically designed for AutoCAD.
In regards to what is the best to use for programming in AutoCAD, here is an
article I wrote for this newsletter a few months back on just this subject:
Visual Basic or AutoLisp?
I've lost count the number of times I've been asked that question. As far as
I'm concerned, it's not a difficult question to answer. Use both......
Each of them have got their strengths and weaknesses.
I mean, look at AutoCAD's DCL language. It's a positive pain in the
posterior designing dialogs in AutoCAD whereas, with VB it's a pure
pleasure.
And the AutoLisp coding for dealing with dialog's? Say no more!! (If you
don't believe me have a look at the AutoLisp code required to hide a
dialog.)
On the other side, look how simple it is to deal with blocks in AutoLisp. I
still haven't figured out how to explode a block in VB without resorting to
coding that sends commands to the command line. AutoLisp also deals with
lists in a much more friendlier manner than VB. (Well I think so, so
there!!)
And having to declare all your variable types in VB really threw me at
first. I can now see the reasoning behind it and it does result in faster
more elegant application.
It's difficult to say when and where to use AutoLisp or VB. If you are
having to deal with the operating system or external files, then VB is
definitely the route to take. On the other hand, if you are doing fairly
straightforward AutoCAD based programming then I would stick to AutoLisp.
I must also mention, that it is much easier to protect your source coding
using VB or VBA. I know you can compile your AutoLisp files if you use
Visual Lisp, but have you seen the size of file that is returned?
So, I've had my say and you've heard the verdict, so stop reading and start
learning AutoLisp AND Visual Basic......
Just one more thing on the same subject. To run VBA you will need to have a
basic understanding of AutoLisp because AutoLisp "triggers" the VBA
programs. My advice to you would be as follows :
i) Start with straightforward AutoLisp
ii) Move onto Visual Lisp. (Basically the same)
iii) Get stuck into VBA.
Also, at this stage in time, you will find a lot more information on
programming using AutoLisp than you will on VBA in regards to AutoCAD.

P.S. I wonder what Randall Raath's thoughts are on this subject?
========================================================================
After I'd wrote the previous expanation I received this :
I am currently working for an architecture office in Miami, and I will like
to learn VB, the question is which version should I purchase?.....in your
web page you explained somehow VB and VB for Applications, and I know that
there is other versions.....would I limit my choices if I used only VB for
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (2 of 9) [23/03/2005 05:50:44 p.m.]
Applications, or is the program essentially the same as the standard VB with
add-ons for cad?....
please if you could respond to this questions I would sincerely appreciate
it...
David San Roman
mailto:david@dpz.com
=======================================================================
This was my response :
David,
VB is a standalone application that can do everything VBA can plus
more. VBA is a subset of VB specifically design to suit the application that
it is developed for. (e.g.. You get VBA for Excel, VBA for AutoCAD, VBA for
PowerPoint, etc.) VBA is not standalone but is part of the host application.
It has certain characteristics, (controls, properties, etc.) designed to
suit that application. VB can access all of the VBA functions build into an
application by creating a reference to that application. If you are working
with AutoCAD R14 or R2000, VBA for AutoCAD is part of the program, whereas,
if you wish to use VB, you will have to purchase it separately. Hope this
explanation helps.
=========================================================================
Mark Misquitta wrote in last week asking for help on Reading and Writing to
external data files. Keith Blackie very kindly sent in this reply:
Mark,
I have spent a great deal of time writing routines which read data from
files within autolisp and I believe I have an example which might be of
use to you.
The first thing I am going to do is assume that you are familiar with
autolisp enough to construct a viable function.
What we need to do first is obtain the file which has the data to be
read into the function. This could be a static name or one which is set
dynamically by the user. Here are examples of each:
(setq file_name "rect.dat") ;;; this is a static name which will never
change
(setq file_name (getstring "\nData file name: "));;; user types in file
name dynamically set
(setq file_name (getfiled "Data Files" "" "" 8)) ;;; dynamically sets
name through AutoCAD dialog box
(setq file_name (getfiled "Data Files" "" "txt" 8) ;;;sets a TXT
extention filter for files, others file types may be filtered as well by
adding a semicolon between extensions ie. TXT;DAT;CDF;SDF
Now that we have the file name saved as file_name we can now commence to
opening it. We must save the file handle to a variable otherwise you
cannot close the file and you cannot access the data contained within
it. Example follows:
(setq fn (open file_name "r"));;;set file handle FN to a file open for
reading ie. FILE_NAME Note: The variable file_name can be replaced with
a static text name as in the following example:
(setq fn (open "myfile.dat" "r"))
The lower case "r" is a case sensitive notation that the file is open
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (3 of 9) [23/03/2005 05:50:44 p.m.]
for reading, alternately it can be "w" for writing and "a" for appending
Note: if a file is opened for writing and it already exists, the data in
that file will be lost.
Ok, now we know what file to open and we have opened it and saved the
file hande to a variable name FN, so now what...
We can now read the information contained within the file a couple of
different ways. One it to read each line and the other is to read each
character. For simplicity I will only cover the reading of the lines.
Here is what we have so far:
(defun c:fread()
(setq file_name (getfiled "Data Files" "" "" 8))
(if (setq fn (open file_name "r"))
(setq data_string (read-line fn))
(princ (strcat "\nCannot open " file_name " for reading! "))
)
)
This looks good but.. We must continue reading the file and assigning it
to variables until the entire file is read ... or until the desired
number of variables are read from the file. Then we must close the file.
That is easy.
(defun c:fread()
(setq file_name (getfiled "Data Files" "" "" 8))
(if (setq fn (open file_name "r"))
(progn
(setq data_string (read-line fn))
(while data_string
(subroutine_to_handle_data)
(setq data_string (read-line fn))
)
(close fn)
)
(princ (strcat "\nCannot open " file_name " for reading! "))
)
)
As you can see we have obtained FILE_NAME and attempted to open it as
FN, If we were successful then we read the data into variable
DATA_STRING. From this point it is easy to test for a value in
DATA_STRING, if there is no value the loop will break, meaning the end
of the file has been reached. At his point we can close the file using
the close function.
Note: If the file cannot be opened then the user will be told the file
could not be opened.
After the first bit of data is read then you can call a function which
will interpret the data and parse it according to your needs, after
which it will read another string of data.
If you want to cut and paste the final example, you can do so and use it
as a working example, just define the data handling routine and you will
be in business.
Keith Blackie
Owner
BCI Computer Solutions
mailto:blackie@isgroup.net
========================================================================
Thanks Keith for your concise explanation. Looking forward to more of the
same :-))
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (4 of 9) [23/03/2005 05:50:44 p.m.]
========================================================================
Another person last week who had a problem with loading partial menu's was
Andreas Blignaut. Adrian Flack sent in this possible solution:
Andreas as far as I am aware the problems you are experiencing are caused by
the following:
If you are using R13 it is a bug in the system, try typing .quit at the
command prompt to save your settings. The point before quit is important.
If you are using R14 it might be necessary to load the .mnu file instead of
the .mns file. Just be careful doing this, because any changes made to the
mns file and not the mnu file will be lost when loading the mnu file. You
could also try .quit and see if that works. The reason for using .quit is
that some users undefine the quit command.
Please let me know if this works for you.
Regards
Adrian Flack
mailto:adrianf@bks.co.za
========================================================================
Thank's guys, it's always nice when people respond to other people's
problems.
========================================================================
Hey Kenny!,
Haven't spoke in a while. I thought I would drop a line and ask if you would
mention a company at your web site.
The story:
I recently needed to convert an old SHX AutoCAD font originally created by
my boss for AutoCAD R10 to AutoCAD R14 in a TTF font. Since Acad dims use
mtext, and mtext uses TTFs, this was a logical path. The SHX font contained
half-stacked fractions in 16th increments. We wanted something that could be
inserted into mtext, via the mtext editor, like you can a symbol font. We
originally tried to create from scratch the Unicode version like my boss did
for the SHX version. Too difficult for me, so I located a company via the
web:
David W. Edwards - Dave Edwards Consulting - Maker of TC Fonts
mailto:info@tcfonts.com
http://www.tcfonts.com
The original contact was back in March of this year. I had forgotten all
about it, until I received an e-mail three weeks ago from Mr. Edwards. Below
is the pasted copy of his e-mail:
Mr. Farley...
I'm sorry I haven't gotten back with you sooner, but some time ago you asked
about creating a TrueType from a custom SHX. We normally don't have a
problem with these but several of your characters blew our custom programs
out of the water. It took "forever" to figure out what going wrong.
That all said - attached is a TTF font that matches your HROMANS. We have
also included a custom Hromans.SHX. In order for this to work, the custom
character have to be copied to different locations (a Windows TTF)
requirement. You should use the new SHX file (store your original in a safe
place just in case). The custom characters start at ASCII 160.
I have also included a DOC on how to make the SHX use the TrueType in Text.
Because of the delay, there will not be a charge for this. Let me know if
you have any trouble and let us know if we can do anything else for you.
David W. Edwards
I followed his instructions in the very detailed document he sent me and the
font works PERFECTLY! This company's behavior, and specially Mr. Edwards',
is truly a class act. In all of my years in the computer industry I have
never experienced a vendor with this level of customer satisfaction. I had
forgotten that he was working on it!
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (5 of 9) [23/03/2005 05:50:44 p.m.]
I believe that a company of this caliber deserves any accolades that could
be reasonably afforded them. Please consider them worth mentioning to your
valuable visitors.
Thanks,
Rog. mailto:rfarley@one.net
========================================================================
Tip of the Week
Here's a handy little routine for you that underlines text.
Written by James J. Olszewski.
;;;Start Lisp Coding Here.
(defun C:UN (/ ED ER ES)
(setvar "CMDECHO" 0)
(setvar "HIGHLIGHT" 0)
(command "TEXTEVAL" 1)
(setq ED (entget (car
(nentsel "\nPick TEXT to underline:"))))
(setq ER (cdr (assoc 1 ED)))
(setq ES (strcat "%%u" ER))
(setq ED (subst (cons 1 ES) (assoc 1 ED) ED))
(entmod ED)
(setvar "CMDECHO" 1)
(setvar "HIGHLIGHT" 1)
(princ)
)
(princ)
;;;End Lisp Coding Here.
=========================================================================
And one from me :
;;;Start AutoLisp Coding Here.
;;;This routine will draw centre lines of an arc
;;;Written by Kenny Ramage
(defun C:CLARC ( / CEN RAD CP X1 X2 X4 Y1 Y2 Y3 Y4 P1 P2 P3 P4)
(setq CEN (entget (car (entsel "\nPick ARC: "))))
(if (/= "ARC" (cdr (assoc 0 CEN)))
(alert "This is NOT \nan Arc \nPlonker!")
(progn
(setvar "CMDECHO" 0)
(setq RAD (cdr (assoc 40 CEN))
CP (cdr (assoc 10 CEN))
X1 (- (car CP) ( * RAD 1.2))
Y1 (cadr CP)
P1 (list X1 Y1)
X2 (+ (car CP) (* RAD 1.2))
Y2 (cadr CP)
P2 (list X2 Y2)
X3 (car CP)
Y3 (- (cadr CP) (* RAD 1.2))
P3 (list X3 Y3)
X4 (car CP)
Y4 (+ (cadr CP) (* RAD 1.2))
P4 (list X4 Y4)
);setq
(command "LAYER" "M" "3" ""
"LINE" P1 P2 ""
"LINE" P3 P4 ""
);command

);progn
);if
(princ)
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (6 of 9) [23/03/2005 05:50:44 p.m.]
);defun
(princ)
;;;End AutoLisp Coding Here.
========================================================================
THE CONTRACT DRAUGHTSMANS PHRASE BOOK
AGENT:
Grabbing bastard. Usually suffers from amnesia.
FLAT WEEK:
Disease with often fatal results. Symptoms: Frequent
phone calls to other agents, stabbing pains in the bank
statement. Only known cure is liberal application of
overtime, three times daily.
CLIENT:
A person who is convinced that he knows what he wants,
better than any self-respecting contractor. Usually
proved to be incorrect.
OVERTIME:
Time specified for doing work which was impossible,
for many reasons, to complete during normal
hours i.e. private work, long lunches, etc.
DOUBLE TIME:
Heaven, the contractor's ultimate ecstasy.
FRIDAY:
Payday. Can also be day on which D.C.M'S are awarded.
D.C.M. (Abbr. Don't Come Monday.)
Normal termination of contract. Extremely vulgar.
LONG TERM CONTACT:
Term used by agents to denote any job thought to be
lasting more than 20 minutes.
STAFF DRAUGHTSMAN: (vulg.)
A derogatory expression used to indicate an
administrative overhead.
IMMEDIATE REQUIREMENT:
Expression used by agents, which means "You will not hear
anything more about this job for six months."
RATE:
An imaginary figure for a job. Always less than the
correct figure.
AGENTS MARGIN:
A supposedly small figure which is capable of doing big
things, like buying big cars and foreign holidays.
LOCAL CONTRACT:
A job within 1000 miles of your home.
OFF-SHORE CONTRACT:
Must be able to swim to work without getting drawings wet.
CV:
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (7 of 9) [23/03/2005 05:50:44 p.m.]
A set of lies submitted to an agent and bearing no
resemblance to events or persons living or dead.
RESUME:
A set of lies submitted to client by an agent bearing no
resemblance to the above-mentioned set of lies.
JOB SATISFACTION:
Something only occurring on the last Friday of each month
(payday).
GRUB-SCREW: (n.Latin)
Term used to denote contractor having dinner date
with attractive female staff member (usually very
rare).
INTERVIEW:
One and only opportunity for client to try to
impress contractor with his expertise. (Seldom
effective due to persistent questions about rate).
TAX INSPECTOR:
1. Evil being, demoniacal thing .
2. Nasty bogey man used to frighten infant
contractors if they are naughty.
TIME SHEET:
1. Agency Time Sheet - 2nd most important piece of
paperwork after salary cheque.
2. Client Time Sheet - A device invented solely to
annoy and wake up contractor for at least 10 minutes per
week.
EXPENSES:
Money expended by contractors in legitimate course
of his business. i.e. booze bills, squash club fees,
gambling accounts, etc.
DEMOB HAPPY:
State of euphoria existing in last seven days of contract.
STATUTORY HOLIDAY:
Government legislation designed to reduce
contractor's income.
CONTINGENCY PLANNING:
Constantly having CV updated and ready for
E-Mailing.
ENGINEER:
Lowly paid contractor-in-training. (See also under
"Staff man".)
MANAGER:(Old English. "Man-ager")
Painful irritant. Noted for constant moaning about costs and completion
dates.
DECISION:
Almost extinct. Lack of this item responsible for
huge quantities of wasted work and a contractor's major
source of income.
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (8 of 9) [23/03/2005 05:50:44 p.m.]
C.A.D.:
Expensive plaything used to reduce company profits and
provide useful part-time employment.
Cheers 'Till Next Week,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:kramage@namdeb.com.na
AfraLisp :
http:\\members.tripod.com\~kramage\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:kramage@namdeb.com.na
In the body of the message type :
Un-subscribe AfraLisp

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 25-08-99
http://www.afralisp.com/newsletter/1999/25-08-99.htm (9 of 9) [23/03/2005 05:50:44 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Hi Everyone,
I bet you're all wondering why AfraLisp changed URL's? Very
simple really. I started to receive numerous E-mails from AfraLisp visitors
stating that they were having problems in downloading files. I contacted the
service provider and was informed that they do not encourage downloads as it
slows down their server and they loose advertising opportunities. (??) I was
then told, in no uncertain terms, to desist in this evil, vile and
despicable practice or face a shut-down of the site and possible
assassination. Needless to say, I immediately packed my bags and headed for
the hills, only stopping once for a quick beer. (O.K. two.) Anyway, I hope
everyone likes the format of the new site and have book marked the new
address. (Just in case you haven't, you'll find it at the top and bottom of
this letter.)
Hey guess what? My ACAD2000 package has finally arrived. ;-))) Keep an eye
on AfraLisp for some AY2K orientated applications that I'll be posting in
the near future. (Don't worry, I won't neglect the R12/13/14 users.)
===========================================================================
Here's a couple of AutoLisp/VBA links you may be interested in looking at :
AutoCAD Resource Site
http://members.xoom.com/LarryLP/
Magic site.....well worth a visit.
Note! The URL for this site is soon to change to:
http://www.llpsite.com/
Australian CAD Links
http://www.users.bigpond.com/johncoom/johncooc.html
Say no more Bruce....
AutoLisp Programming
http://pw1.netcom/~rogh/autolisp.htm
Some good basic AutoLisp Programming Examples
Architectural Eng. Standards
http://calstate.edu/tier3/PPD/AE/CAD_STDS.html
Good site if you need to develop CAD Standards.
Lintang on the Web
http://geocities.com/RainForest/1073/
Some great applications. All Freeware.
Have a look at the CadViewer...
Have you seen the new VB-Design site layout?
http://vbdesign.hypermart.net/
Randall is still busy with it, but looking good...
========================================================================
Just remember, that if you are interested in VBA/VB, Randall Raath publishes
a daily (yes, daily) newsletter entitled "A Code A Day" containing all
AfraLisp Newsletter No 08-09-99
http://www.afralisp.com/newsletter/1999/08-09-99.htm (1 of 5) [23/03/2005 05:50:46 p.m.]
sorts of VBA/VB coding examples. If you would like to receive this brilliant
newsletter, just send an E-Mail to Randall at :
mailto:rwrath73@worldnet.att.net
AfraLisp also hosts the archives for this newsletter. (including a Monthly
downloadable Zip file.) You can find them at :
http://afralisp.hypermart.net/rr/rr.htm
=========================================================================
Letters :
Is there a way to access or otherwise add a drawing preview window to a file
open/save dialogue box? It is useful to see a preview of a block file prior
to
inserting it.
mailto:rdietel@lselectric.com
========================================================================
Hello.
I am an AutoCAD R14 user and lisp programmer trying to teach myself VBA.
Your AfraLisp site has been a life saver for me during this learning
process. (I have it set as my homepage). I have two reasons for contacting
you.
The first is to request that you e-mail me a zip file that you have posted
on your site called RC-BATCHER.ZIP. I have downloaded it directly, but
when I open it, I get a message that it is not a valid archive.
(One of the first download problems!!! - Kenny.)
The second is to ask your advice (if you don't mind offering it) on a small
problem I have encountered writing a VBA program. I have started a program
that collects and displays the title block attributes of a drawing. The
attributes can be edited and the changes can be made to other drawings
within the same directory. I want to provide the option of printing each
drawing that is updated using the Plot.PlotToDevice method. My problem is
this: I added a combo box to display all of the available plot devices I
have set up in AutoCAD. I tried to use the "getplotdevicenames" method to
populate the combo box, but had no luck. The example code in the R14 VBA
help file for this method didn't work. Is there a trick to get this to
work? I am hoping that you have used this before and could send me your
own example code.
Thanks for having such a helpful web site.
Erik Huddlestun
mailto:erikh@stevensind.com
==========================================================================
Do you have any idea what level of VBA is in AutoCAD 15/2000 (=.0075?)
I am wanting to purchase tutorial books, but don't know if it is VBA 5,
VBA 6, or totally unrelated to a numeric release.
Thanks in advance
Stephen S. Sitchcox
Lisper
mailto:hdesign@ica.net
==========================================================================
Hello:
In regard to VBA for AutoCAD, is there a way to access the bitmap image
stored
inside of drawing files so that it can be displayed on a form?
Per your suggestion, I took a visit to your home page. Interesting! I
AfraLisp Newsletter No 08-09-99
http://www.afralisp.com/newsletter/1999/08-09-99.htm (2 of 5) [23/03/2005 05:50:46 p.m.]
wonder,
what is it that you do, since the mine is closed? Just curious.
(The mine is "closed" to the general public. You need security clearance to
gain entry.-Kenny)
Regards,
Ron Dietel
mailto:rdietel@lselectric.com
==========================================================================
I am just starting to read info. on AutoLisp programs. I have a project at
work where I will have to draw up approx. 700 drawings that are identical
except for the length and width, I am using AutoCAD 14, but soon will be
using
Acad 2000 and Mech. Desktop.
I need an AutoLisp or Visual Lisp program where I can have only one AutoCAD
drawing and all other pertinent info. stored in an external database. If I
have to make a change that will affect 100 of these drawings, I would rather
make the changes in a database then to open, revise, save, and close all
these
drawings. I heard that Mech. Desktop has the capability to do this but it
want
allow the user to give each drawing a separate drawing number and also it is
only good for modeling purpose only, please comment. I was also looking at
some of lisp programs in the Into the Database-Page III section. I skipped
over the Page I and II sections and tried to work this lisp and could not
get it to work. Should the part where
it states dialogue coding looks like this: be inserting into the lisp
program
or saved separate, you didn't state exactly what one should do with this.
mailto:MQJ3311@aol.com
==========================================================================
Greetings Kenny,
I was curious if there was a lisp routine out there that you are aware of
that will batch change title block info?
I would like to replace text with a bitmap log or vice versa.
Thanks,
Peter Lanzone
mailto:Planzone@Essef.com
==========================================================================
Tip of the Week
This week we have a simple but effective Copy/Rotate routine.
;;;<-Start AutoLisp Coding Here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Rotate/Copy - RotCop
;;;This routine will Copy a selected group of entities and then
;;;Rotate them about a user selected Base point.
;;;Written by Kenny Ramage
;;;AfraLisp@afralisp.hypermart.net/
;;;http://afralisp.hypermart.net/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(prompt "\nRotate-Copy Loaded....
\nType Rotcop to run....")
(defun C:RotCop ( / a n ip ang index e)
(setvar "Cmdecho" 0)
(setq a (ssget)
n (sslength a)
AfraLisp Newsletter No 08-09-99
http://www.afralisp.com/newsletter/1999/08-09-99.htm (3 of 5) [23/03/2005 05:50:46 p.m.]
ip (getpoint "\nBase Point : ")
ang (* (getangle ip "\nRotation Angle : ") (/ 180 PI))
index 0
);setq
(repeat n
(setq e (ssname a index)
index (1+ index)
);setq
(command "Copy" e "" ip "@"
"Rotate" e "" ip ang
);command
);repeat
(command "Redraw")
(setvar "Cmdecho" 1)
(princ)
);defun
(princ)
;;;End AutoLisp coding here->
=========================================================================
I'm going to finish off this weeks letter with something I received from
Steve Cherry :
There was an draughtsman who had an exceptional gift for fixing all things
mechanical. After serving his company loyally for over 30 years, he happily
retired. Several years later his company contacted him regarding a seemingly
impossible problem they were having with one of their multi-million dollar
machines. They had tried everything and everyone else to get the machine
fixed, but to no avail. In desperation, they called on the retired
draughtsman
who had solved so many of their problems in the past.
The draughtsman reluctantly took the challenge. He spent a day studying the
huge machine. At the end of the day he marked a small x in chalk on a
particular component of the machine and proudly stated, "This is where your
problem is". The part was replaced and the machine worked perfectly again.
The company received a bill for $50,000 from the draughtsman for his
service.
They demanded an itemized accounting of his charges.
The draughtsman responded briefly:
One chalk mark ------------------ $1
Knowing where to put it ----- $49,999
It was paid in full and the draughtsman retired in peace.
Steve Cherry
mailto:SCherry@mabc.com
==========================================================================
Keep Well and Cheers 'till next week.....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All code provided as is, with no warranty as to its fitness or use.
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
AfraLisp Newsletter No 08-09-99
http://www.afralisp.com/newsletter/1999/08-09-99.htm (4 of 5) [23/03/2005 05:50:46 p.m.]
mailto:unsubscribe@afralisp.hypermart.net
In the body of the message type :
Un-subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send E-Mail to :
mailto:subscribe@afralisp.hypermart.net
In the body of the message type :
Subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 08-09-99
http://www.afralisp.com/newsletter/1999/08-09-99.htm (5 of 5) [23/03/2005 05:50:46 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Calling All Ships,
I'm sorry to say that this weeks newsletter is a wee bit
short due to some inconsiderate person making me work. What is the world
coming to? Anyway, I've posted a couple of new things on AfraLisp. First is
a Tutorial on using the "DIR" command from within AfraLisp :
The "DIR" command is a DOS (remember that dark place) command that displays
a list of a directories files and subdirectories. But did you know that you
can use the "DIR" command from within AutoLisp? This is a great function for
obtaining a list of files in a directory, especially useful for Batch
Processing Routines.
You can find this at http://afralisp.hypermart.net/tutor.htm
Secondly, Lisp to VBA :
To demonstrate the use of VBA in AutoCAD, I've taken a few of the more
common AutoLisp routines, and converted them to VBA Applications. This will
hopefully help the AutoLisper who is trying to migrate from AutoLisp To VBA.
These routines should be familiar to most AutoLispers and by having a good
understanding of how the routine is written in AutoLisp, you should find it
very easy to follow and understand the VBA logic and coding.
This one will be an ongoing process, with routines being added, as and when
I complete them. (I'm also still trying to figure out my own way around
VBA.)
This can be found at http://afralisp.hypermart.net/vba.htm
===================================================================
Letters :
New FREE stuff at LOTW:
------------------------------------------
CADieu Viewer+ ver 1.0.
FREEWARE . Stand-alone app . Win NT/95/98 . 1.1 MB
An AutoCAD files viewer + Slide library manager in one. Previews
AutoCAD r13/14/2000's dwg, dwt, sld, slb, wmf, bmp, gif, jpg, pcx, tif,
lsp, rtf, txt, and any text files, create slides and slide library, and
extract slides from slide library. From within this program, you can
directly open,load, insert, attach, or import previewed files into current
AutoCAD drawing session. CADieu Viewer+ also provides 'quick viewing'
of those files formats from Windows Explorer's right-click popup menu by
adding new 'View with CADieu..' and 'Browse with CADieu..' menu item.
If you are HotBlocks user, this program is a must-have.
Coming soon at LOTW:
---------------------------------
CADieu Viewer+ ver 1.1 - With hatch pattern preview.
You can download CADieu Viewer+ (and other free stuff) from :
LOTW :
http://www.geocities.com/RainForest/1073
or CADSyst :
http://www.cadsyst.com/utilc.html#cadviewr.zip
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (1 of 7) [23/03/2005 05:50:47 p.m.]
Regards
Lintang Darudjati
http://www.geocities.com/RainForest/1073
==================================================================
Kenny,
greetings...
I was wondering if you knew (or know of) a 'drawing' (per se) of all the
steel sections done on a 24 x 36 (sorry 'bout the units, ...an' I'm from
Canada too...ay)
Its like its a poster. A couple of detailers in our fabrication shop have
these. But, instead of making copies, I would like to do a new crisp plot of
it.
Thanks
Brent Allen
Misc. Ink
mailto:misc-ink@pangea.ca
==================================================================
Tip of the Week :
;;;AutoLisp Coding starts here
;;; FLATTEN.LSP version 2k.01, 25-Jun-1999
;;;
;;; FLATTEN sets the Z-coordinates of these types of objects to 0
;;; in the World Coordinate System:
;;; "3DFACE" "ARC" "ATTDEF" "CIRCLE" "DIMENSION"
;;; "ELLIPSE" "HATCH" "INSERT" "LINE" "LWPOLYLINE"
;;; "MTEXT" "POINT" "POLYLINE" "SOLID" "TEXT"
;;;
;;;-----------------------------------------------------------------------
;;; copyright 1990-1999 by Mark Middlebrook
;;; Daedalus Consulting
;;; e-mail: mailto:markmiddlebrook@compuserve.com
;;;
;;; Thanks to Vladimir Livshiz for improvements in polyline handling
;;; and the addition of several other object types.
;;;
;;; You are free to distribute FLATTEN.LSP to others so long as you do not
;;; charge for it.
;;;
;;;-----------------------------------------------------------------------
;;; Revision history
;;; v. 2k.0 25-May-1999 First release for AutoCAD 2000.
;;; v. 2k.01 25-Jun-1999 Fixed two globalization bugs ("_World" & "_X")
;;; and revised error handler.
;;;-----------------------------------------------------------------------
;;;*Why Use FLATTEN?
;;;
;;; FLATTENing is useful in at least two situations:
;;; 1) You receive a DXF file created by another CAD program and discover
;;; that all the Z coordinates contain small round-off errors. These
;;; round-off errors can prevent you from object snapping to
;;; intersections and make your life difficult in other ways as well.
;;; 2) In a supposedly 2D drawing, you accidentally create one object with
;;; a Z elevation and end up with a drawing containing objects partly
;;; in and partly outside the Z=0 X-Y plane. As with the round-off
;;; problem, this situation can make object snaps and other procedures
;;; difficult.
;;;
;;; Warning: FLATTEN is not for flattening the custom objects created by
;;; applications such as Autodesk's Architectural Desktop. ADT and similar
;;; programs create "application-defined objects" that only the
;;; application really knows what to do with. FLATTEN has no idea how
;;; to handle application-defined objects, so it leaves them alone.
;;;
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (2 of 7) [23/03/2005 05:50:47 p.m.]
;;;-----------------------------------------------------------------------
;;;*How to Use FLATTEN
;;;
;;; This version of FLATTEN works with AutoCAD R12 through 2000.
;;;
;;; To run FLATTEN, load it using AutoCAD's APPLOAD command, or type:
;;; (load "FLATTEN")
;;; at the AutoCAD command prompt. Once you've loaded FLATTEN.LSP, type:
;;; FLATTEN
;;; to run it. FLATTEN will tell you what it's about to do and ask you
;;; to confirm that you really want to flatten objects in the current
;;; drawing. If you choose to proceed, FLATTEN prompts you to select objects
;;; to be flattened (press ENTER to flatten all objects in the drawing).
;;; After you've selected objects and pressed ENTER, FLATTEN goes to work.
;;; It reports the number of objects it flattens and the number left
;;; unflattenened (because they were objects not recognized by FLATTEN; see
;;; the list of supported objects above).
;;;
;;; If you don't like the results, just type U to undo FLATTEN's work.
;;;
;;;-----------------------------------------------------------------------
;;;*Known limitations
;;; 1) FLATTEN doesn't support all of AutoCAD's object types. See above
;;; for a list of the object types that it does work on.
;;; 2) FLATTEN doesn't flatten objects nested inside of blocks.
;;; (You can explode blocks before flattening. Alternatively, you can
;;; WBLOCK block definitions to separate DWG files, run FLATTEN in
;;; each of them, and then use INSERT in the parent drawing to update
;;; the block definitions. Neither of these methods will flatten
;;; existing attributes, though.
;;; 3) FLATTEN flattens objects onto the Z=0 X-Y plane in AutoCAD's
;;; World Coordinate System (WCS). It doesn't currently support
;;; flattening onto other UCS planes.
;;;
;;;=======================================================================
(defun C:FLATTEN (/ tmpucs olderr oldcmd zeroz ss1 ss1len
i numchg numnot numno0 ssno0 ename elist
etype yorn vrt crz
)
(setq tmpucs "$FLATTEN-TEMP$") ;temporary UCS
;;Error handler
(setq olderr *error*)
(defun *error* (msg)
(if (or
(= msg "Function cancelled")
(= msg "quit / exit abort")
)
;;if user cancelled or program aborted, exit quietly
(princ)
;;otherwise report error message
(princ (strcat "\nError: " msg))
)
(setq *error* olderr)
(if (tblsearch "UCS" tmpucs)
(command "._UCS" "_Restore" tmpucs "._UCS" "_Delete" tmpucs)
)
(command "._UNDO" "_End")
(setvar "CMDECHO" oldcmd)
(princ)
)
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (3 of 7) [23/03/2005 05:50:47 p.m.]
;;Function to change Z coordinate to 0
(defun zeroz (key zelist / oplist nplist)
(setq oplist (assoc key zelist)
nplist (reverse (append '(0.0) (cdr (reverse oplist))))
zelist (subst nplist oplist zelist)
)
(entmod zelist)
)
;;Setup
(setq oldcmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "._UNDO" "_Group")
(command "._UCS" "_Delete" tmpucs "._UCS" "_Save" tmpucs "._UCS" "_World")
;set World UCS
;;Get input
(prompt
(strcat
"\nFLATTEN sets the Z coordinates of most objects to zero."
)
)
(initget "Yes No")
(setq yorn (getkword "\nDo you want to continue <Y>: "))
(cond ((/= yorn "No")
(graphscr)
(prompt "\nChoose objects to FLATTEN ")
(prompt
"[press return to select all objects in the drawing]"
)
(setq ss1 (ssget))
(if (null ss1) ;if enter...
(setq ss1 (ssget "_X")) ;select all entities in database
)
;;*initialize variables
(setq ss1len (sslength ss1) ;length of selection set
i 0 ;loop counter
numchg 0 ;number changed counter
numnot 0 ;number not changed counter
numno0 0 ;number not changed and Z /= 0
counter
ssno0 (ssadd) ;selection set of unchanged entities
) ;setq
;;*do the work
(prompt "\nWorking.")
(while (< i ss1len) ;while more members in the SS
(if (= 0 (rem i 10))
(prompt ".")
)
(setq ename (ssname ss1 i) ;entity name
elist (entget ename) ;entity data list
etype (cdr (assoc 0 elist)) ;entity type
)
;;*Keep track of entities not flattened
(if (not (member etype
'("3DFACE" "ARC" "ATTDEF"
"CIRCLE" "DIMENSION" "ELLIPSE"
"HATCH" "INSERT" "LINE"
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (4 of 7) [23/03/2005 05:50:47 p.m.]
"LWPOLYLINE" "MTEXT" "POINT"
"POLYLINE" "SOLID" "TEXT"
)
)
)
(progn ;leave others alone
(setq numnot (1+ numnot))
(if (/= 0.0 (car (reverse (assoc 10 elist))))
(progn ;add it to special list if Z /= 0
(setq numno0 (1+ numno0))
(ssadd ename ssno0)
)
)
)
)
;;Change group 10 Z coordinate to 0 for listed entity types.
(if (member etype
'("3DFACE" "ARC" "ATTDEF" "CIRCLE"
"DIMENSION" "ELLIPSE" "HATCH" "INSERT"
"LINE" "MTEXT" "POINT" "POLYLINE"
"SOLID" "TEXT"
)
)
(setq elist (zeroz 10 elist) ;change entities in list above
numchg (1+ numchg)
)
)
;;Change group 11 Z coordinate to 0 for listed entity types.
(if (member etype
'("3DFACE" "ATTDEF" "DIMENSION" "LINE" "TEXT"
"SOLID")
)
(setq elist (zeroz 11 elist))
)
;;Change groups 12 and 13 Z coordinate to 0 for SOLIDs and
3DFACEs.
(if (member etype '("3DFACE" "SOLID"))
(progn
(setq elist (zeroz 12 elist))
(setq elist (zeroz 13 elist))
)
)
;;Change groups 13, 14, 15, and 16
;;Z coordinate to 0 for DIMENSIONs.
(if (member etype '("DIMENSION"))
(progn
(setq elist (zeroz 13 elist))
(setq elist (zeroz 14 elist))
(setq elist (zeroz 15 elist))
(setq elist (zeroz 16 elist))
)
)
;;Change each polyline vertex Z coordinate to 0.
;;Code provided by Vladimir Livshiz, 09-Oct-1998
(if (= etype "POLYLINE")
(progn
(setq vrt ename)
(while (not (equal (cdr (assoc 0 (entget vrt))) "SEQEND"))
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (5 of 7) [23/03/2005 05:50:47 p.m.]
(setq elist (entget (entnext vrt)))
(setq crz (cadddr (assoc 10 elist)))
(if (/= crz 0)
(progn
(zeroz 10 elist)
(entupd ename)
)
)
(setq vrt (cdr (assoc -1 elist)))
)
)
)
;;Special handling for LWPOLYLINEs
(if (member etype '("LWPOLYLINE"))
(progn
(setq elist (subst (cons 38 0.0) (assoc 38 elist) elist)
numchg (1+ numchg)
)
(entmod elist)
)
)
(setq i (1+ i)) ;next entity
)
(prompt " Done.")
;;Print results
(prompt (strcat "\n" (itoa numchg) " object(s) flattened."))
(prompt
(strcat "\n" (itoa numnot) " object(s) not flattened.")
)
;;If there any entities in ssno0, show them
(if (/= 0 numno0)
(progn
(prompt (strcat " ["
(itoa numno0)
" with non-zero base points]"
)
)
(getstring
"\nPress enter to see non-zero unchanged objects... "
)
(command "._SELECT" ssno0)
(getstring "\nPress enter to unhighlight them... ")
(command "")
)
)
)
)
(command "._UCS" "_Restore" tmpucs "._UCS" "_Delete" tmpucs)
(command "._UNDO" "_End")
(setvar "CMDECHO" oldcmd)
(setq *error* olderr)
(princ)
)
(prompt
"\nFLATTEN version 2k.01 loaded. Type FLATTEN to run it."
)
(princ)
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (6 of 7) [23/03/2005 05:50:47 p.m.]
;;;eof
;;;AutoLisp Code Ends here
==================================================================
Well, that's it for this week. I'll leave you with this thought :
30% of car accidents are caused by people who have been drinking.
But that means that 70% are caused by people that do not drink??
Cheers and have a nice weekend.....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:unsubscribe@afralisp.hypermart.net
In the body of the message type :
Un-subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send E-Mail to :
mailto:subscribe@afralisp.hypermart.net
In the body of the message type :
Subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 17-09-99
http://www.afralisp.com/newsletter/1999/17-09-99.htm (7 of 7) [23/03/2005 05:50:47 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Friends, Romans and Gentlemen,
Apologies for the gap in Newsletters, but
I've been overrun at work upgrading the office system to suit AutoCAD 2000.
Quite a job, I must say. As well as that, our main E-Mail server, which is
situated at our Head Office in Johannesburg, decided to call it a day. So,
I've been without E-mail for over a week now!! Apologies to anyone who tried
to get through to me and just got bounced back. If you sent me a message and
I did not reply, would you be so kind as to re-send. I'll try and reply to
the backlog of questions and queries during this week. Using the words of
the BBC "Please do not adjust your set's. Normal service will resume as soon
as possible".
=============================================================
A couple of new items on AfraLisp. As the majority of the work I've been
doing whilst upgrading the office system is VBA based, I've, again, been
fiddling about with some VB applications. (Don't worry all you Lisper's. I
haven't forgotten you, I've just taken a temporary detour.)
Firstly, I've posted an AfraLisp Screensaver. Simple, but I like it :-))
Secondly, there's a full working version of Change Text. This allows you to
do all sorts of things to text within your drawings. Very similar to the
AutoCAD Change Text AutoLisp File.
And thirdly, I've added a VB version of SuperPurge. Have a look at this one
as you all might find this a very useful tool to have within your arsenal.
You can find all these applications (and more) at:
http://afralisp.hypermart.net/vba.htm
I've also updated Randall Raath's "A Code a Day" including the download file
for the month of September. You can find this at :
http://afralisp.hypermart.net/rr/rr.htm
=============================================================
Letters :
Hello Kenny,
I contacted you about a year ago when I was learning to program in lisp,
when your tutorials proved very useful. Now I'm a bit further, and I am
CAD-systems administrator at my company. Today I got really p****d off
when I opened a DWG made by one of our two senior designers. A couple of
months ago we implemented a company DWG-standard which included a
statement about dimlfac (contents... it must be set to 1) and about
dimaso (contents.... it must be switched ON). These two senior designers
just refuse to make dwg's according to these standards, because, as they
say, have always used Acad like this. Apparently they totally missed the
concept of advancing technology, and that they are using ACAD2000 now
instead of R10.
Bottom line (Just wanted you to know the background of my question): I
saw your example of redefinition of the explode command. Is there a way
AfraLisp Newsletter No 06-10-99
http://www.afralisp.com/newsletter/1999/06-10-99.htm (1 of 5) [23/03/2005 05:50:48 p.m.]
to just disable those two commands for normal users, except
administrators (me), through a simple lisp-routine? Hope you can help me
on this one.
Thanks in Advance,
Martijn Budding mailto:budje@igr.nl
=============================================================
...HEY KENNY, I DON'T CARE WHAT ANYBODY SAY, YOU ARE THE GREATEST IN THE
LISP WORLD!!! IN YOUR SITE(AFRALISP) I'VE LEARNED THING THAT I NEVER IMAGING
THAT EXIST.....THANKS!!!!....CONTINUE DOING THAT. A LOT OF PEOPLE ARE
SUPPORTING YOUR SITE HERE IN NEW YORK...KEEP GOING AND GOOD LUCK.
MY PROBLEM:
I'M WORKING WITH A TITLE BLOCK THAT HAVE 26 LINES OF ATTRIBUTES, AND IT
HAPPEN THAT I HAVE TO CHANGE THE 2 VERY LAST OF THEM (CHANGE THE DATE AND
ISSUE).
WHEN THE DDEDIT COMMAND PROMPT ME TO SELECT THE ATTRIBUTE, I SELECT THE
ATTRIBUTE THAT I WANT TO CHANGE AND THE DIALOG BOX APPEARS WITH THE VERY
FIRST ATTRIBUTE
HIGHLIGHTED. I'D LIKE TO KNOW IF YOU HAVE ANY TIP OR LISP PROGRAM THAT ALLOW
ME TO GO DIRECTLY TO THE SAME ATTRIBUTE THAT I SELECT, SO I DON'T HAVE TO
PAGE THE DIALOG BOX TO GET TO THE LAST ON AND THEN EDIT THAT ATTRIBUTE THAT
I WANT TO CHANGE.
MY ANTICIPATED THANKS
LEO REYNOSO FROM NEW YORK
mailto:magama@netzero.com
=============================================================
Hello,
I am having difficulties in exploding a block ref object in R14.0.
Can some body do the trick?
Thanks
Ubaid Ullah Qureshi mailto:uqureshi@e.descon.com.pk
=============================================================
Mr. Ramage,
My name is Joe Schmidt and I work at a structural engineering company in
Omaha, Ne USA. Your tutorials have been a big help in learning the
AutoLisp language. I didn't know anything about AutoLisp when I started and
now I am writing some complex lisp routines, but I have a question that
maybe you can answer. Here is my code:
(defun C:1-5MRD ()
(setq IP (getpoint "\nPlease pick insertion point: "))
(setq dist (getdist IP "\nPlease pick deck distance: "))
(setq ang (getangle IP "\nPlease pick direction of deck: "))
(setq P1 (polar IP ang 0.4375)
P2 (polar P1 ang 0.25)
P3 (polar P2 (/ pi 2) 0.1875)
P4 (polar P3 ang 0.25)
P5 (polar P4 (/ pi 2) 1.125)
P6 (polar P5 (/ pi 2) 0.1875)
P7 (polar p6 ang 0.25)
P8 (polar p7 ang 3.625)
P9 (polar p8 ang 0.25)
P10 (polar p9 (* pi 1.5) 0.1875)
P11 (polar p10 (* pi 1.5) 1.125)
P12 (polar p11 ang 0.25)
P13 (polar p12 (* pi 1.5) 0.1875)
P14 (polar p13 ang 0.25)
P15 (polar p14 ang 0.4375)
)
AfraLisp Newsletter No 06-10-99
http://www.afralisp.com/newsletter/1999/06-10-99.htm (2 of 5) [23/03/2005 05:50:48 p.m.]
(setq colarr (+ (fix (/ dist 6)) 1))
(setq counter 0)
(while (< counter colarr)
(COMMAND "PLINE" IP P1 "a" P3 "l" P5 "A" P7 "L" P8 "A" P10 "L" P12 "A" P14
"L" P15 "")
(SETQ COUNTER (1+ COUNTER))
(setq ip p15)
)
;(setq deck (entlast))
;(if (= ang pi)
; (setq dkdist -6)
; (setq dkdist 6)
;)
;(command "array" deck "" "r" 1 colarr dkdist)
(PRINC)
)
This program will draw 1 1/2" metal roof decking as a polyline in a
direction and distance specified by the user. If you will notice the area
where I have commented out code for a moment, what I have done is drawn one
segment of the decking (which is 6" long) and the program will array the 6"
segment "colarr" number of times until a specific distance is met. I would
like to be able to draw many segments of decking as one complete polyline
instead of many arrayed polylines. If you uncomment the code and take out
the while loop the code should work. My question is How do I set a new
startpoint equal to the lastpoint drawn. Above in my while loop I tried to
set the start point "ip" equal to "p15" the last point drawn. But that
didn't work. If you have any insight as to how to manipulate points like
this, I would sure appreciate your help.
Thanks in advance,
Joe Schmidt
mailto:hoover_jjs@email.msn.com
p.s. Make sure you turn off osnaps when you run the code or it will look
funny. I haven't got around to setting my variables for that yet.
=============================================================
I sent Joe this :
;;Start AutoLisp Code
(defun C:1-5MRD ()
(setq IP (getpoint "\nPlease pick insertion point: "))
(setq dist (getdist IP "\nPlease pick deck distance: "))
(setq ang (getangle IP "\nPlease pick direction of deck: "))
(setvar "OSMODE" 0)
(setq colarr (+ (fix (/ dist 6)) 1))
(repeat colarr
(setq P1 (polar IP ang 0.4375)
P2 (polar P1 ang 0.25)
P3 (polar P2 (/ pi 2) 0.1875)
P4 (polar P3 ang 0.25)
AfraLisp Newsletter No 06-10-99
http://www.afralisp.com/newsletter/1999/06-10-99.htm (3 of 5) [23/03/2005 05:50:48 p.m.]
P5 (polar P4 (/ pi 2) 1.125)
P6 (polar P5 (/ pi 2) 0.1875)
P7 (polar p6 ang 0.25)
P8 (polar p7 ang 3.625)
P9 (polar p8 ang 0.25)
P10 (polar p9 (* pi 1.5) 0.1875)
P11 (polar p10 (* pi 1.5) 1.125)
P12 (polar p11 ang 0.25)
P13 (polar p12 (* pi 1.5) 0.1875)
P14 (polar p13 ang 0.25)
P15 (polar p14 ang 0.4375)
)
(COMMAND "PLINE" IP P1 "a" P3 "l" P5 "A" P7 "L" P8 "A" P10 "L" P12 "A" P14
"L" P15 "")
(setq ip p15)
);repeat
(PRINC)
)
;;;end AutoLisp Code
=============================================================
I'd like to finish of with this :
(setq message
(cons "got here from afralisp")
(cons "been there a bit, subscribe to yr letter")
(cons "now iv'e seen the man behind the code")
( cons "and his missus, slurping a bloody great ale")
(cons "not a bad idea, might just do that,, me.)
)
May your projects prosper
I am,
Mike Bawden
mailto:mbawd@tig.com.au
.. click to test .. release to detonate.
'Till Next Time.....
Regards,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send E-Mail to :
mailto:unsubscribe@afralisp.hypermart.net
In the body of the message type :
Un-subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send E-Mail to :
mailto:subscribe@afralisp.hypermart.net
In the body of the message type :
Subscribe AfraLisp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AfraLisp Newsletter No 06-10-99


http://www.afralisp.com/newsletter/1999/06-10-99.htm (4 of 5) [23/03/2005 05:50:48 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 06-10-99
http://www.afralisp.com/newsletter/1999/06-10-99.htm (5 of 5) [23/03/2005 05:50:48 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Is there anybody out there?
Firstly,
thanks to everybody for taking the time and effort to re-subscribe to this
Newsletter. I must say it's now a lot easier to control and maintain and it
means that I can now spend more time thinking up and writing vast amounts of
this type of high quality garbage. Please let me know if you have any
problems from your side and I hope that the advertisement doesn't turn out
to be too much of a hassle.
Anybody following the Rugby World Cup? South Africa is going to mollicate
the lot of you, especially the Aussies and the All Blacks. For all of you in
the States, Rugby is the real man's game, not that pansy American Football
that you lot play. I mean, why don't your players just wear suits of armor
and get it over with? :-))))))
===================================================================
Here's a few new things that I've added to AfraLisp :
Create A Toolbar DLL :
Are you sick and tired of having all those Toolbar Bitmap Files floating
around?
I think you are probably aware just what a pain it is having to remember to
attach the bitmaps along with the Toolbar menu file every time you either
send it to someone, or install the menu on another workstation. (Smiley
Faces here we come..)
The solution to this, is to store the Bitmaps in an ActiveX DLL file. (The
same as
AutoCAD do with their Toolbar Bitmaps.) This article will take you through
the steps required to construct your own customized Toolbar DLL.
http://afralisp.hypermart.net/vba15.htm
TestDCL.Lsp :
by M.P.Saju. mailto:mpsaju@yahoo.com
Testing DCL files becomes a necessity when developing a good sized lisp
application for easy input and understanding. This routine in lisp was
written for just such a necessity.
Usage is very simple... Just type "Testdcl" in the AutoCAD text screen and
press
"Enter". A file selection dialog box will open up to select the DCL file.
On entering, the DCL under test will open. This application works under
the assumption that there is an active "accept" or "cancel" button.
http://afralisp.hypermart.net/olisp.htm
===================================================================
Letters :
Our office uses SummaSketch III tablets and Calcomp 4x5 DesignStations.
Currently I have a line in the Acad.Lsp file to load our menu:
(command "menu" "mwacad").
AfraLisp Newsletter No 12-10-99
http://www.afralisp.com/newsletter/1999/12-10-99.htm (1 of 5) [23/03/2005 05:50:49 p.m.]
The problem is, the tablets use different configurations in the ***Buttons1
menu area.
Is there a way I can have an "if" statement in the Acad.Lsp file to load the
correct menu based on the workstation/tablet that is being used? We are
on a Windows NT server with Windows 95/98 workstations.
Brian Fifelski mailto:mwa@flash.net
==================================================================
Brian,
Your best solution to this problem is to set up 2 different Profiles
for each tablet and each Menu. You could have 2 different icons on your
desktop that will open AutoCAD for each tablet/menu. You can use something
like this when you start AutoCAD :
"c:\acadr14\acad.exe"/p summa
"c:\acadr14\acad.exe"/p cal
Check out the AutoCAD Help on how to set up and use profiles.
==================================================================
Hi Kenny
Glad to know you like "Testdcl.lsp". By all means add
it to your "AfraLisp". In return could you please help
me with this query.
I am looking for persons who deal with Hydraulic
manifold block design. I developed "Testdcl" while I
was in the process of developing a lisp routine
involving Mechanical desktop commands for the design
and development of Hydraulic manifold blocks. Can you
help?
Regards
Saju Philippose mailto:mpsaju@yahoo.com
==================================================================
Although I am currently using ACAD2000, this questions should pertain to any
version.
I am creating an AutoLisp program that will insert a block and then change
certain block attribute definitions based on criteria inputted at the
insertion time. For example, once I insert this specific block, I want to
change the justification of an attribute based on the inserted rotation
angle. Hence this will be specific to each individual block when inserted.
The only way I have figured out this could be accomplished is by (a)
exploding the block (hence leaving it exploded in my drawing) or (b)
exploding the block, redefining it, and saving it again as a redefined
block. I do not want to use any of these two possibilities because (a) I
need the block to remain unexploded and (b) I do not want to change any
previous occurrences of this block already inserted into the drawing and I
also want to keep the original attribute definitions (the definitions set
previous to insertion) for the next time I insert the block.
Please help in any way. I realize it hard to explain exactly what I am
looking for, so let me know if you do not understand my intentions.
Thanks,
Greg Lee
mailto:glee@ideasi.com
====================================================================
Tip of the Week :
This routine will join 2 broken lines.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Start AutoLisp Coding
;;;Join.Lsp : Joins two broken colinear lines.
AfraLisp Newsletter No 12-10-99
http://www.afralisp.com/newsletter/1999/12-10-99.htm (2 of 5) [23/03/2005 05:50:49 p.m.]
;;;Written by Kenny Ramage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:Join ( / a b ai va vb dst1 dst2 a1 b1 a2 b2 ent1 ent2
end1 end2 dst3 dst4 oldlst newlst)
(defun mid (w z)
(list (/ (+ (car w) (car z)) 2) (/ (+ (cadr w) (cadr z)) 2))
);defun
(setvar "cmdecho" 0)
(setq a (cadr (entsel "\nSelect two lines to be joined: "))
b (cadr (entsel))
ai (mid a b)
va (ssget a)
vb (ssget b)
a1 (cdr (assoc 10 (entget (setq ent1 (ssname va 0)))))
b1 (cdr (assoc 11 (entget (ssname va 0))))
a2 (cdr (assoc 10 (entget (setq ent2 (ssname vb 0)))))
b2 (cdr (assoc 11 (entget (ssname vb 0))))
dst1 (distance ai a1)
dst2 (distance ai b1)
);setq
(if (< dst1 dst2)
(setq end1 b1
end1 a1
);setq
);if
(setq dst3 (distance ai a2)
dst4 (distance ai b2)
);setq
(if (< dst3 dst4)
(setq end2 b2
end2 a2
);setq
);if
(setq oldlst (entget ent1)
newlst (subst (cons 10 end1)(assoc 10 oldlst) oldlst)
newlst (subst (cons 11 end2)(assoc 11 newlst) newlst)
);setq
(entdel ent2)
(entdel ent1)
(entmake (cdr newlst))
(setvar "cmdecho" 1)
(princ)
);defun
(princ)
;;;end AutoLisp Coding
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
==================================================================
AfraLisp Newsletter No 12-10-99
http://www.afralisp.com/newsletter/1999/12-10-99.htm (3 of 5) [23/03/2005 05:50:49 p.m.]
And here's a VB Tip :
Open a new module and enter this under the declarations section of the
module :
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,_
ByVal dwReserved As Long) As Long
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1
Now, insert a new form and enter the following into the Form_Load procedure.
Dim lRetVal As Long
lRetVal = ExitWindowsEx(EWX_REBOOT, 0)
Now run the application and see what happens......
=================================================================
And now here's something rather interesting to finish off this weeks
Newsletter :
Ever wonder why MS applications seem slower with each new release? Read
on...
Apparently the constant rain in Redmond has driven Bill's engineers to
obsessive flights of fancy. Below are instructions on how to access a
little flight simulator that was inexplicably hidden by precipitation
maddened programmers deep inside Excel 97.
In Excel97, open a new blank worksheet.
Press F5. (Go to function.)
Type X97:L97 in the box and click OK.
Now hit the Tab key once. (You should now be in cell M97.)
Now, whilst pressing the 'Ctrl' and 'Shift' keys, click once on the 'Chart
Wizard' icon. (The one at the top with the blue-yellow-red bar chart.)
After a few moments, you should be flying.
Steer with the mouse and accelerate/slow down with the left/right mouse
buttons.
Look for the monolith with the programmer credits.
Exit the program with the Esc key.
'Till Next Week,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send blank E-Mail to :
mailto:afralisp-unsubscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send blank E-Mail to :
mailto:afralisp-subscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AfraLisp Newsletter No 12-10-99


http://www.afralisp.com/newsletter/1999/12-10-99.htm (4 of 5) [23/03/2005 05:50:49 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 12-10-99
http://www.afralisp.com/newsletter/1999/12-10-99.htm (5 of 5) [23/03/2005 05:50:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Greetings and Salutations,
Forewith, (from now on), I shall be
known as "Hairy Chops." Why? (I hear you say). Because, (I quickly reply),
I'm busy growing a beard (3 weeks now). And, the itching is driving me up
the wall!! So if my writing is a little bit shaky, don't worry, it's just me
scrattin away at my cheek bones trying to gain a little relief from the
maddening itch.
I'd like to once again, extend an invitation to each and everybody who
receives this Newletter to contribute to it. Anything goes as long as it is
AutoCAD related or you feel it would be of interest to AutoCAD users.
Snippets of code, interesting AutoCAD Sites, and humour, of course, is
always welcome. Please do not send X-Rated photographs to this Newsletter,
but rather send them directly to me :-))
Right, enough blathering and on with this weeks show.......
======================================================================
What's New on AfraLisp
Looking for something specific on AfraLisp? Then why not make use of the new
Search Engine that I've installed. Just enter a keyword, click on the "Go"
button, and a list of links to pages on AfraLisp containing that word will
appear. All part of the service!!
======================================================================
I don't know if you are aware, but there is an application included with
AutoCAD that makes dealing with the operating system a breeze when working
with AutoLisp. This is DOSLib.Arx, designed and distributed by Robert Mcneel
and Associates. http://www.mcneel.com
DOSLib, or DOS Library, is a library of LISP-callable functions that provide
Windows operating system and DOS command-line functionality to various CAD
applications, including AutoCAD and IntelliCAD.
DOSLib extends their LISP programming languages by providing the following
functionality:
* Drive handling functions to change between drives and check disk
space.
* Path handling functions to manipulate path specifications.
* Directory handling functions to create, rename, remove, select and
change directories.
* File handling functions to copy, delete, move, rename, and select
files. Functions for getting directory listings, searching and finding
multiple instances of files, and changing attributes are provided.
* Print handling function to get and set default printers, and spool
files.
* Initialization file handling functions to manipulate Windows-style
initialization (INI) files, and Windows Registry access functions.
* Process handling functions to run internal DOS commands or other
programs.
* Miscellaneous functions, like changing the system date and time, and
displaying Windows message boxes.
I have written a tutorial that will show you how to use some of the various
functions available within DOSLib. You can find it at :
AfraLisp Newsletter No 18-10-99
http://www.afralisp.com/newsletter/1999/18-10-99.htm (1 of 5) [23/03/2005 05:50:50 p.m.]
http://afralisp.hypermart.net/lisp59.htm
===================================================================
I came across a great little application written by Rollin Laird
mailto:rplaird@earthlink.net
IDECLARE searches given LISP source file(s) for undeclared local variables
and declares any such found. Any new declares made are flagged with a
comment.
Global variables are recognized by having a '#' (number sign) as the first
character. The original LISP input file will be renamed with the file
extension ORG. Wildcard characters '*' and '?' can be used in the LISP input
file name.
The global variable identifying character can be changed by giving the new
identifying character as the second parameter on the command line, after the
file name. A new file extension for the original LISP input to be saved
under can be given as the third command line argument.
You can find this application at:
http://afralisp.hypermart.net/olisp.htm
===================================================================
Letters :
I was wondering if you can help me with the begin command event...I wanted
to
know if I used the following VBA code, could I also have VBA react to a
specific block, as in example two....if a person select the attedit command
to select the rev
block, can I have a VBA form to pop up when they use the command and pick
the
rev block..thanks
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "ATTEDIT" Then
MsgBox "we do not use that to edit.", , "vb"
SendCommand Chr(27) & Chr(27)
SendCommand "circle" & Chr(10)
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "ATTEDIT" And acBlockReference.Item(0).Name = "REV" Then
MsgBox "we do not use that to edit.", , "vb"
SendCommand Chr(27) & Chr(27)
SendCommand "circle" & Chr(10)
End Sub
Kenneth Rhodes mailto:Kenneth.Rhodes@Cummins.com
======================================================================
Ich schreib in German!
Danke Kenny, Deine Homepage ist first class.
Mach weiter so !
Ralf
======================================================================
Kenny,
I have a problem when I insert a block with attributes. In R14 I
used to be able to insert a block containing attributes using Lisp and the
command function. After inserting the block the attribute dialog would open.
Now in 2000 the block is inserted but the dialog box does not open, just the
command prompts for the attribute. Can you help please...
Dave Allen mailto:dallen@tdale.com
Dave,
The following AutoLisp code does not work correctly even though the same
syntax is functional in AutoCAD Release 14:
;;;code begin
(setvar "ATTREQ" 1)
AfraLisp Newsletter No 18-10-99
http://www.afralisp.com/newsletter/1999/18-10-99.htm (2 of 5) [23/03/2005 05:50:50 p.m.]
(setvar "ATTDIA" 1)
(command "-insert" "MyBlock" InsertionPoint Xscale Yscale Zscale Rotation)
;;;code end
This code in R14 inserts a block with attributes, then displays the Enter
Attributes dialog box (where the attributes are entered), and the block is
placed in the drawing.
But, in R2000, the Insert Attribute dialog box will not display when called
from an AutoLisp function unless ATTDIA is set to 1, and the INITDIA
function is called prior to executing the -INSERT command.
To do this, the AutoLisp code needs to be as follows:
;;;code begin
(setvar "ATTREQ" 1)
(setvar "ATTDIA" 1)
(initdia)
(command "-insert" "MyBlock" InsertionPoint Xscale Yscale Zscale Rotation)
;;;code end
Hope this answers your question. (I had the same problem myself and it took
me ages to suss out the answer.)
======================================================================
Tip of the Week :
Often, whilst running AutoLisp routines, your system variables can get well
and truly messed up. To alleviate this problem, you can write yourself a
small AutoLisp routine that does nothing more than re-set the system
variables to your standards. Here's an example :
;;;Start Coding Here
(defun reset ()
(setvar "blipmode" 1)
(setvar "cmdecho" 1)
(setvar "highlight" 1)
(setvar "osmode" 32)
(setvar "pickbox" 5)
(setvar "filedia" 1)
(setvar "apperture" 4)
(prompt "\nSystem Variables Re-set to Default...")
(princ)
);defun
(princ)
;;;End Coding Here.
Now, if your variables ever get messed up, you just run this routine to set
everything back to normal. (I have created a toolbar button to trigger
this.)
======================================================================
And now I bid you a fond farewell with this :
Bill Gates dies in a car accident. He finds himself
being sized up by God....
"Well, Bill, I'm really confused on this call. I'm
not sure whether to send you to Heaven or Hell. After
all, you helped society enormously by putting a
computer in almost every home in America, yet you
also created Windows '95. I'm going to do something
I've never done before. In your case, I'm going to
let you decide where you want to go."
"Well, what's the difference between the two?" Bill
asks.
God says, "I'm willing to let you visit both places
briefly, if it will help your decision."
AfraLisp Newsletter No 18-10-99
http://www.afralisp.com/newsletter/1999/18-10-99.htm (3 of 5) [23/03/2005 05:50:50 p.m.]
"Fine, but where should I go first?"
"I'll leave that up to you."
"Okay, then," says Bill. "Let me try Hell first."
So Bill goes to Hell. It's a beautiful, clean, sandy
beach with clear waters and lots of beautiful women
running around, playing in the water, laughing and
frolicking about. The sun is shining, the temperature
is perfect.
He is very pleased. "This is great!" he tells God.
"If this is Hell, I
REALLY want to see Heaven!"
"Fine," says God, and off they go.
Heaven is a place high in the clouds, with angels
drifting about, playing harps and singing. It's nice,
but not as enticing as Hell. Bill thinks for a quick
minute and decides. "Hmm. I think I'd prefer Hell,"
he tells God.
"Fine," replies God. "As you desire."
So Bill Gates goes to Hell. Two weeks later, God
decides to check on the late billionaire to see how
he is doing in Hell. When he gets there, he finds
Bill shackled to a wall, screaming amidst hot flames
in a dark cave, being burned and tortured by demons.
"How's everything going?" he asks Bill.
Bill responds, his voice filled with anguish and
disappointment, "This is awful! This is nothing like
the Hell I visited two weeks ago! I can't believe
this is happening! What happened to that other place,
with the beaches and the beautiful women playing in
the water?"
"Oh ... that was the SCREENSAVER."
'Till Next Week,
Kenny "Hairy Chops" Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send blank E-Mail to :
mailto:afralisp-unsubscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send blank E-Mail to :
mailto:afralisp-subscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please send all insults to Randall Raath
mailto:rwrath73@worldnet.att.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AfraLisp Newsletter No 18-10-99
http://www.afralisp.com/newsletter/1999/18-10-99.htm (4 of 5) [23/03/2005 05:50:50 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 18-10-99
http://www.afralisp.com/newsletter/1999/18-10-99.htm (5 of 5) [23/03/2005 05:50:50 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Hi,
Aussies watch out!!!! This Saturday brings the end to your World Cup
Rugby hopes. Score: South Africa 42, Aussies 18.........Watch this Space....
=====================================================================
What's New on AfraLisp
Randall Raath has written two great VBA Basic Training Tutorials. You can
find them at :
http://afralisp.hypermart.net/vbatut4.htm and
http://afralisp.hypermart.net/vbatut5.htm
I've also re-written my Batch Purge application for VBA. You can find "Batch
Purge 2000" at :
http://afralisp.hypermart.net/vba.htm
=====================================================================
Letters :
Hi there
My problem:
I want to create an 3D ARRAY with an object along a curved or irregular
PATH.
(Example: A millipede where the legs are arrayed along the body!)
It doesn't seem possible within standard AutoCAD. Do you know any
(lisp)applications with this facility

Morten Seedorff mailto:mos@get2net.dk
====================================================================
My reply :
Morten,
One way that you could achieve the result you are after without
resorting to AutoLisp, is to use the "Measure" command. Not only will this
allow you to create points at specific intervals along an object, but it
will also allow you to insert blocks. You can also specify an alignment for
the blocks.
====================================================================
Hi Kenny,
Glad to have my site posted on your links page, just wanted you to know
that I moved. The AutoCAD Resource Site is now located at:
http://www.llpsite.com/
You're still looking good. Where do you find the time? Have a great week.
Larry Pommer mailto:llpommer@ctlnet.com
=====================================================================
I'm interest in finding the centroid of a closed polyline. Does any AutoLisp
routine exist that do that?
AfraLisp Newsletter No 28-10-99
http://www.afralisp.com/newsletter/1999/28-10-99.htm (1 of 3) [23/03/2005 05:50:51 p.m.]
If you can help me, please answer me to mailto:crabago@altavista.net
Thanks a lot.
Carlos.
=====================================================================
Tip of the Week
Have you ever wanted to break a circle into two sections? Bit difficult
isn't it using the standard AutoCAD break command? Here's a routine that
will do it for you. (This will change the broken portion to Layer 2. Just
change this to suit yourself.)
;;;start code
(defun C:Brcirc ( / cpt1 lpt1 lpt2 cent rad1 ang1
dst1 dst2 cord ang2 wkpt cpt2 cpt3)
(setvar "blipmode" 0)
(setvar "osmode" 512)
(setvar "cmdecho" 0)
(setq cpt1 (getpoint "\nPick Circle to Break/Change: "))
(setvar "osmode" 32)
(setq lpt1 (getpoint "\nPick First Break Point: ")
lpt2 (getpoint lpt1 "\nPick Second Break Point: ")
);setq
(setvar "osmode" 0)
(setq cent (osnap cpt1 "center")
rad1 (distance cpt1 cent)
ang1 (- (angle lpt1 cent)
(angle lpt1 lpt2))
dst1 (distance lpt1 cent)
dst2 (* dst1 (sin ang1))
cord (sqrt(-(* rad1 rad1)
(* dst2 dst2)))
ang2 (- (angle lpt1 lpt2) 1.57)
wkpt (polar cent ang2 dst2)
cpt2 (polar wkpt (angle lpt1 lpt2) cord)
cpt3 (polar wkpt (angle lpt2 lpt1) cord)
);setq
(command "erase" cpt1 ""
"arc" "c" cent cpt2 cpt3
"arc" "c" cent cpt3 cpt2
);command
(setvar "osmode" 512)
(setq cpt1 (getpoint "\nSelection Portion to Change : "))
(setvar "osmode" 0)
(command "Change" cpt1 "" "p" "la" "2" "")
;change your layer name here
(princ)
);close defun
(princ)
;;;end code
;;;*==========================================================
This came to me from Bob Abernethy mailto:info@cadesigner.com :
Clinton visits Saddam Hussein to talk about the weapon-inspections in
Iraq. As he sits down he sees three buttons in the arm-rest of the
chair of Saddam. When Saddam sits down, Clinton immediately asks: 'Why
are there three buttons in your arm-rest?'
'You'll see' replies Saddam.
They start the talks, but after 10 minutes Saddam presses the 1st
button, and 'WHACK' a boxing glove hits Clinton in the face, Clinton
grabs his nose, while Saddam is laughing himself silly. Clinton remains
calm because he doesn't want this to affect the talks.
After another 10 minutes, Saddam presses the 2nd button and another
boxing glove hits Clinton in the stomach. While Clinton is gasping for
air, Saddam falls out of his chair from laughing. Clinton gets annoyed
by now, but still remains outwardly calm.
AfraLisp Newsletter No 28-10-99
http://www.afralisp.com/newsletter/1999/28-10-99.htm (2 of 3) [23/03/2005 05:50:51 p.m.]
They resume the talk, but after 5 minutes Saddam presses the final
button, and from under the table another boxing glove hits Clinton,
right in the groin. Clinton is really fed up by it now and stands up to
leave. 'We'll continue this talk next week in the White House' says the
President. Saddam, choking from laughing, is too proud to say no, so the
appointment stands.
A week later Clinton receives Saddam in the Oval Office, and as Saddam
sits down, he sees three buttons in the arm-rest of Clinton's chair.
As the meeting goes on, Saddam sees that Clinton presses the first
button, and ducks really fast, but nothing seems to happen. This
doesn't stop Clinton from laughing...really loud.
After this, Clinton continues where he left off, until he presses
another button. Saddam reacts really quick, and jumps up. Absolutely
nothing happens, and this time Clinton falls out of his chair laughing.
Saddam doesn't get it - what the hell is happening here?
But he hasn't been harmed yet, so he sits down again to talk further.
After a few minutes Clinton presses the final button. This time,
Saddam stays sitting, but Clinton isn't, he's is rolling on the floor,
doubled up from laughing. Saddam is really annoyed by now, so he
stands up from his chair and shouts: "I've had enough of this, I'm
going back to Baghdad"
(Through tears of laughter from the floor) - "Baghdad?.....what
Baghdad?"
'Till Next Week,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send blank E-Mail to :
mailto:afralisp-unsubscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send blank E-Mail to :
mailto:afralisp-subscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please send all insults to Randall Raath
mailto:rwrath73@worldnet.att.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 28-10-99
http://www.afralisp.com/newsletter/1999/28-10-99.htm (3 of 3) [23/03/2005 05:50:51 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp
http://afralisp.hypermart.net/
mailto:AfraLisp@afralisp.hypermart.net
****************************************
Beam me up Scottie,
I'm not going to mention the rugby and I would
appreciate it if nobody else does. Especially if you're an Aussie!!!!
Now I'm going back to hide under my rock. Over to you............
==================================================================
Letters
Hi Ramage,
I am an afralisp subscriber. Can you help solve one of my problem. Is there
a way to exclude the entities in Pspace from selection set e.g. when I say
(setq ss1 (ssget "X"'((0 . "LINE"))))
it selects all lines in PS/MS and any routine to change them to plines just
stops when it can't access ps or ms entities .
Regards,
Manoj Mishra mailto:manoj@datagraphical.com
==================================================================
Dear Mr.Kenny Ramage
How are you?
My name is Michiaki Ishii. I am now working at construction company
as structural engineer.
A few month ago I have just started to learn autolisp languages and
enjoying very much.
And today I found your homepage and realized this is what I am looking
for.
I was just impressed with your work because your explanation is easy
to understand.
What I am trying to create by lisp is postprocessor after analyis of
structures ,like looking at forces graphically. (Now 50% done.)
I appreciate you can recommend good book about lisp as advanced
level rather than beginner level.
And I am very happy to hear you by e-mail from now, as well.
best regards,

Ishii, Michiaki mailto:Ishii@birdair.com
=================================================================
Hi Kenny,
Thanks for the lisp tutorials. They have really help me to get
started. Why is it that nobody has written a good lisp to draw a spring
in any unit and on any elevation or point of ones choice. I know the
steps(Autocad) but I am new to the lisp environment. Bye...
Dominic Nwokolo MAILTO:nwoks@tstt.net.tt
==================================================================
Dear Kenny
AfraLisp Newsletter No 01-11-99
http://www.afralisp.com/newsletter/1999/01-11-99.htm (1 of 5) [23/03/2005 05:50:52 p.m.]
I'm currently carrying out a project looking at a simply supported
beam. This particular program. Contains a repeat loop that. In this loop
the usere is asked to enter distance from A (point on diagram)
A line is then drawn on the diagram at this distance. This is then
assigned to d1. Now the problem arises with regards to the next
distance. in the loop I want to name this d2 but cannot increment my d1
to take the name d2 for the next point.****** CAN YOU HELP******
Code looks like
(setq num (getreal "\nEnter the number of downward forces"))
(repeat num
(setq d1 (getreal "\nPlease enter the distance of point from A"))
**drawline vertical line at point to a predetermined point******
)
*now on the next loop I need the next value to be assigned to d2 and so
forth around the loop.******
Now all the points that have been added can be worked upon
independantely
Any assistance would be greatly appreciated.
Thanks Jamie
mailto:j.dowdall@uclan.ac.uk
==================================================================
And my reply to Jamie :
Jamie,
I think that you are aproaching the problem the wrong way. Instead
of trying to increment the variable name, why don't you just store all your
values in a list. You know how many you have, and in which order they are
entered, so it's a simple matter to retrieve them and do with them what you
wish. Here's a simple routine below :
;start coding here
(defun c:dlist ()
(setq num (getint "\nEnter the number of downward forces: "))
(repeat num
(setq d1 (getreal "\nPlease enter the distance of point from A: "))
(setq thelist (append thelist (list d1)))
);end repeat
(princ)
);defun
(princ)
;end coding here
All the values are stored, as a list, in the variable "thelist". To retrieve
them you could simply use the nth function. An even better way is to use a
"while" loop. This way you don't have to enter the number of downward
forces. You can enter as few, or as many as you like. Have a look at this :
AfraLisp Newsletter No 01-11-99
http://www.afralisp.com/newsletter/1999/01-11-99.htm (2 of 5) [23/03/2005 05:50:52 p.m.]
;start coding here
(defun c:dlist1 ()
(setq num 0.0)
(while
(setq d1 (getreal "\nPlease enter the distance of point from A: "))
(setq thelist (append thelist (list d1)))
(setq num (+ 1 num))
);end while
(princ)
);defun
(princ)
;end coding here
As soon as you press enter without entering a value, the routine will stop.
The number of entries will be stored in variable "num" and the values,
again, in the variable "thelist".
==================================================================
Loring Begay sent this tip for AutoCAD Release 14:
"Since AutoCAD R14 does not have the time in the status line like
R13, a DIESEL macro can remedy this. However, I use this utility
for today's date and current UCS status. This comes in handy
because most of my work involves extensive 3D modeling. This macro
also works with no ill effects in Mechanical Desktop.
DIESEL macro for MODEMACRO
"Today is:$(edtime, $(getvar,date), dddd\",\" dd month\",\"
yyyy), Darling.
Current UCS: $(getvar,ucsname)"
Output:
Today is: Tuesday, 28 September, 1999, Darling. Current UCS:
LEFT
Output in Mechanical Desktop:
TARGET: DRAWING|Today is: Tuesday, 28 September, 1999, Darling.
Current UCS:
LEFT
In my ACAD.RX file, I have an ARX file created from Visual LISP
which has a load of utility functions and this statement which
activates anytime AutoCAD is started. In the source code file,
I have this statement:
(setvar "modemacro" "Today is:$(edtime, $(getvar,date),
dddd\",\" dd
month\",\" yyyy), Darling. Current UCS: $(getvar,ucsname)")
This is the last statement in the file. This generates the
same output as above."
==================================================================
Some Famous Quotations
Carpe per diem--Seize the money
AfraLisp Newsletter No 01-11-99
http://www.afralisp.com/newsletter/1999/01-11-99.htm (3 of 5) [23/03/2005 05:50:52 p.m.]
Harlez-vous francais?--Can you drive a French motorcycle?
Ex post fucto--Lost in the mail
J'y suis, J'y pestes--I can stay for the weekend
Cognito Eggo sum--I think; therefore, I am a waffle
Cognito Ergo Spud--I yam what I yam ... Popeye
Rigor Morris--The cat is dead
Responsdez s'il vous plaid--Honk if you're Scots
Que sera, serf--Life is feudal
Le roi est mort. Jive le roi--The King is dead. No kidding.
Pro Bozo publico--Support your local clown
Monage a trois--I am three years old
Felix navidad--Our cat has a boat
Haste cuisine--Fast French food
Veni, vidi, vice--I came, I saw, I partied
Veni, VIPi, Vici--I came; I'm a very important person; I conquered
Veni, vidi, VISA(r)--I came, I saw, I charged it
Quip pro quo--A fast retort
Aloha oy!--Love; greetings; farewell; from such a pain you should
never know
Mazel ton!--Lots of luck!
Apres Moe, le deluge--Larry and Curly get wet
Porte-Kochere--Sacremental wine
Ich liebe rich--I'm really crazy about having dough
Fui generis--What's mine, is mine
VISA la France--Don't leave the chateau without it
Ca va sans dirt--And that's not gossip
Merci rien--Thanks for nothing
Amicus puriae--Platonic friend
L'etat, c'est moo--I'm bossy around here
L'etat, c'est Moe--All the world's a stooge
'Till Next Week,
Kenny Ramage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail :
Mailto:AfraLisp@afralisp.hypermart.net
AfraLisp URL :
http://afralisp.hypermart.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe send blank E-Mail to :
mailto:afralisp-unsubscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To subscribe send blank E-Mail to :
mailto:afralisp-subscribe@egroups.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please send all insults to Randall Raath
mailto:rwrath73@worldnet.att.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

AfraLisp Newsletter No 01-11-99


http://www.afralisp.com/newsletter/1999/01-11-99.htm (4 of 5) [23/03/2005 05:50:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Newsletter No 01-11-99
http://www.afralisp.com/newsletter/1999/01-11-99.htm (5 of 5) [23/03/2005 05:50:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp Quick Start
This tutorial is aimed at the AutoCAD users who would like to start learning AutoLisp.
I suggest that you go through this tutorial along with the AutoCAD Programmers Reference Guide. You
can then lookup the relevant AutoLisp commands for a more detailed explanation. Hope this helps you
and Good Luck in your Lisping - Kenny Ramage
PRINCIPLES OF PROGRAMMING
All AutoLisp programs must contain the suffix LSP otherwise AutoCAD will not access them when
loading. (eg. CHTEXT.LSP).
Use a simple text processor such as Notepad to create and edit your lisp files.
FUNCTION (Which is simply the program)
Is a pre-defined set of instructions that describes a set of actions that AutoLisp is to perform, divided
into three sections :
OPERATOR - Getting input. G
ARGUMENT - Manipulating the input. G
COMMAND - Using the manipulated input. G
CHARTING
Draw out or write out in English what you want your program to do.

VARIABLES
These are like empty boxes in which to store data, to be used later. In AutoLisp, variables may be a
collection of letters or numbers as long as they begin with the letters.
Example of legal variables are as follows :
A G
ARC1 G
POINT1 G
PNT1 G
D3 G
An AutoLisp variable may contain more than one value in a single variable. A value can be anything,
such as :
Real number G
String G
Integer G
Pickset G
Therefore a variable can store just about anything.
STRUCTURING
Structure your program in such a way that it is easy to understand, by yourself and everyone else. e.g.
Keep input statements together. Keep your arguments together. Keep your commands together. Track
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (1 of 14) [23/03/2005 05:50:58 p.m.]
your work with the semicolon. When you begin a line with a semicolon, anything you write after will be
ignored by AutoLisp. It is used for documentation and explanation of your program. Write notes about
your program, what you are doing and what the variables are. A semicolon does not have to begin the
line.
(prompt "This line will print"); This is a comment
From where the semicolon begins, the remainder of the line is a comment statement.
PARENTHESES ( )
Parentheses are vital to writing AutoLisp programs. All commands are surrounded by parentheses.
AutoLisp uses parentheses to nest, allowing you to write a command that acts on (evaluates) another
command. In turn, that command can act on another. As you add parentheses, you're nesting
commands become deeper and deeper. Remember to come out of the nest with an equal number of
parentheses.
NOTE: Always close what you open.
THE DEFUN COMMAND
In AutoLisp the name of the program or function must be defined in the first statement, which is done
by using the command
DEFUN.
Defun is the first actual command and is followed by the name of the function (or program). There are
different ways of starting a function for example :
(Defun drawline () G
(Defun drawline (/ pntl pnt2) G
(Defun C:drawline () G
(Defun C:drawline (/ pntl pnt2) G
(Defun drawline (a / pntl pnt2) G
The first way, you are saying that all variables you plan to use in the program are GLOBAL, which are
variables that do not lose their value after the program ends.
The second way, you are saying that the variables you are using are LOCAL variables, which are
variables that have value only for that program and while that program is running.
The third way, as the first BUT the C: tells AutoCAD to treat that function as any other AutoCAD
command.
The fourth way, as the second, but an AutoCAD command.
The last, variable a receives the first value to it from outside the program.
DATA TYPES
Integers - Is a number ranging between -32768 and +32767 without decimal points eg: 1
Reals - Is a number with a decimal point eg: 1.0
Strings - Strings can be up to a maximum length of 100 characters.
Lists - A list is a variable that has more than one element. A point in your drawing is described by the
value of the X co-ordinate and the value of the Y co-ordinate. In AutoLisp, that point can be described by
a single variable, a list of two elements, the first being the X value and the second being the Y value eg :
( 7 10 ) G
( 5 9 7 2 ) G
(1.5 2.3 4.9 ) G
Atoms - If a variable has only one value it is an atom e.g. 6
The Type command - will return the data type of variable.
Input Commands -(Getting info from the user)
getpoint - Needs you to pick a point on the screen. G
getint - Needs a Integer eg: 1 G
getreal - Needs a real number eg: 10.00 G
getcorner - Needs a second point on the screen and draws an elastic window from a previous G
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (2 of 14) [23/03/2005 05:50:58 p.m.]
point.
getstring - Needs a string of text. G
getdist - Needs a value either by picking on the screen or a number from the keyboard. G
getangle - Needs an angle either by pointing on the screen or by typing an angle, which will be
returned in radians.
G
getkword - Needs a keyword from the user. G
getvar - Will get the value of an AutoCAD system variable. G
initget - Establishes various options for use by the next GET XXX function. G
getorient - Is similar to the GETANGLE but is affected by the zero-degree base and the direction. It
will always give you the absolute angle using 0 degree base as EAST.
G
Input Command Examples
1. (getpoint "\n Pick POINT on the screen:")
\n - The n MUST always be lower case, \n takes you to the next line. G
Your prompt must always be between " " (Quotes), and after picking a point will return a value of
that point.
G
2. (getint "\Enter your age :") Type a number and AutoLisp will return that number.
3. (getreal "\nEnter a number:") Type a real number eg 10.51 and AutoLisp will return that number.
4. (getcorner pntl "\n Pick second point:") Will create an elastic window from variable pntl.
5. (getstring 1 "\What is the day today ?:") Type some text and Autolisp will return that text.
6. (getdist "\nHow long is the line ?:") Pick two points or type a length and AutoLisp will return that
length.
7. (getangle "\nWhat is the angle ?:") Pick two points for the angle or type an angle and AutoLisp will
return that angle in radians.
8. (initget 1 "Yes No")
(getkword "\nAre you going? ("Yes or NO):") Initget will control the next getxxx function, getkword will
accept only one word. The initget will accept that one word only to be Yes or No.
9. (getvar "FILLETRAD") Would return the set fillet radius eg : 0. 5
Initget Bits
1 Disallow null input G
2 Disallow zero values G
4 Disallow negative values G
8 DO not check limits, even if LIMECHECK is on. G
16 Return 3D points rather than 2D points. G
32 Use dashed lines when drawing rubber band or box.
(initget (+ 1 2 4))
(getint "\nHow old are you?:") Will only accept an Integer eg : 21
G
11. (getorient "\nWhat is the angle?:") Pick two points for the angle or type an angle and AutoLisp
will return an angle in radians relative to 0 degrees at East.
G
Setq Command (Set Equal)
(Setq) is an assignment command, eg : it assigns the value of one variable or constant to another
variable.
NOTE : (Setq) is the primary assignment command in AutoLisp. The = is not used as an assignment. =
does exist but only as a non assignment statement. It does not have the ability to make one variable
equal to another. (It is used for a comparison of variables, numbers or strings)
(setq a b)
This statement assigns the value of b to the variable a.
NOTE : The first variable after the (setq) is the one that receives the value.
Print Commands
Prompt
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (3 of 14) [23/03/2005 05:50:58 p.m.]
This command is used simply to print a message on the command line. A line feed (\n) is not included
so two consecutive prompt commands will print both messages on the same line. Therefore , any
printing after the prompt must have the (terpri) or \n command.
(terpri)
This is a line feed that causes the next printed text to appear on the next line. It generally follows the
prompt command. eg:
(prompt "Hello, how are you ?")(terpri) or G
(prompt "\nHello, how are you ?") G
Prin1
This function prints the expression on the screen and returns the expression. It can be any expression
and need not only be a string. The expression can also be written to a file and will appear in the file
exactly as it would on the screen.
(prin1 "Hello") would print Hello G
(prin1 a) would print the value of variable a G
(prin1 a f) would print the value of variable a to an open file named in variable f G
Princ
Is the same as prinl except that the control characters ("") are not printed. Can also be used to print a
blank line by using no statement after princ.
Print
Same as prinl except that a new line is printed before the expression and a space is printed after the
expression. eg:
(print "Hello") would return "Hello" "Hello" G
Setvar
This function sets an AutoCAD system variable to a given value and returns that value. The variable
name must be in double quotes. eg:
(setvar "blipmode" 0) returns 0 G
Will switch blipmode off. 1 would switch it on again.
Doing arithmetic
(+ 1 1) returns 2 G
(- 2 1) returns 1 G
(* 2 2) returns 4 G
(/ 2 1) returns 2 G
(1+ 1) returns 2 (Incremented) G
(1- 2) returns 1 (Decremented) G
FOR MORE - REFER AUTOLISP PROGRAMMERS REFERENCE
Polar
This function returns the point at an angle (in radians) and distance from a point.
(polar pntl angl distl) G
Inters
Examines two lines and returns the point where they intersect even if they do not cross one another.
(inters pntl pnt2 pnt3 pnt4) G
AutoCAD commands in AutoLISP
Any AutoCAD command can be used inside your lisp program BUT one must remember that they have
to be used exactly as you would in AutoCAD and your RETURN is a double set of Quotes (""). eg:
(command "line" pnt1 pnt2 "") This will draw a line from pntl to pnt2 and the "" acts as a return to
terminate your line command.
(graphscr) would return you to the graphics screen while the program is running.
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (4 of 14) [23/03/2005 05:50:58 p.m.]
(textscr) would return you to the text screen while the program is running.
Entities from a list
When you used (setq a (getpoint)) you assigned the X and Y coordinate numbers to variable a. That
Variable now is a list that may look like (5 10). If you want to look at the list in variable a, AutoLISP gives
you a convenient way to do that from the command line.
!a Placing the ! in front of the variable will display the value or values of the variable.
(car) X COORDINATE (lst element)
The primary command for taking a list apart, (car) gives you the first element of the list. If the value of a
is a list of: (5 10)
Then (setq b (car a)) would assign to the variable b the value of the first element in a which is 5.
(cdr) SECOND AND REMAINING
This is the secondary command for taking a list apart. (cdr) gives you the second and remaining
elements of the list. If variable a is a list of
(2 5 7 9 11)
Then (setq b (cdr a)) would assign to variable b the second and remaining elements of the list in variable
a
(5 7 9 11).
(cadr) Y COORDINATE (2nd element)
This always produces the second element of a list. Assuming a still has the list (5 10),
Then (setq b (cadr a)) would produce 10.
(caddr) Z COORDINATE (3rd element)
This always produces the third element of a list. Assuming a has a list (3 7 5)
Then (setq c (caddr a)) would produce 5.
This program draws a rectangle by pointing to two points.
(defun c:retan (/ pl p2 p3 p4)
(setq pl (getpoint "\nfirst corner of rectangle: "))
(setq p3 (getcorner "\nsecond corner of rectangle: "))
(setq p2 (list (car pl)(cadr p3)))
(setq p4 (list (car p3)(cadr pl)))
(command "line" pl p2 p3 p4 "c")
(princ)
)
DTR converts degrees to radians.
(defun dtr (a)
(* pi (/ a 180)) )
RTD converts radians to degrees.
(defun rtd (a)
(/ (* a 180) pi) )
Things to strings
strcase (string case)
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (5 of 14) [23/03/2005 05:50:58 p.m.]
Changes a string of text from lower case to upper case, leaving upper case characters as they are. eg:
(strcase "Hello") returns "HELLO"
(strcase a) returns the alphabetic characters in variable a from lower case to upper case.
strcat (string cat)
Returns two or more separate strings as one. eg:
(strcat "H" "ello") returns "Hello"
(strcat a b) returns two strings in variable a & b as one.
strlen (string length)
Returns the length, of the characters of a string. eg:
(strlen "hello") returns 5.
(strlen a) returns the length of a string in variable a.
substr (substitute string)
Returns a part of a string, from a specified position, ending either at the end or another specified
position. eg:
(substr "Hello 2) returns "ello".
(substr "Hello 2 1) returns "e".
(substr "Hello" 3 2) returns "ll".
List Manipulation
The apostrophe ' serves a special function in AutoLISP, for example if a group of items is preceded by
an apostrophe ' it is treated as a list. eg:
'(20 10 5) is treated as a list.
Angle
Returns an angle between two points in radians. To use that angle in AutoCAD you have to convert it
back to decimal degrees. eg:
(setq a (angle pntl pnt2)) sets the angle between pntl and pnt2 to the variable a.
To use a:
(command "text" pntl "40" a t) The text command with a height of 40, rotation angle assigned to variable
a and text to variable t. But a is not the correct rotation angle because it is in radians.
Append
Takes any number of specified lists and joins them together as one list. eg:
(append '(10 20) '(30 40)) returns the list: (10 20 30 40).
(append a b) returns the list in variable a and the list in variable b as one.
Distance
Measures the distance from two known points. eg:
(setq distl (distance pntl pnt2)) returns the distance between pntl and pnt2 and assigns the distance to a
variable called dist1.
Length
Returns the number of elements in a list. eg:
(length '(a b c d)) returns 4.
Member
Looks for a duplicate and returns that and the rest of the list eg:
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (6 of 14) [23/03/2005 05:50:58 p.m.]
(member 'c '(a b c d e)) returns (C D E).
nth
Returns the nth element in a list, where n is the number of the element to return. (Zero is the first
element). eg:
(nth 3 '(a b c d)) returns d.
Assoc (associative)
Often used with (subst) command, this command lets you search for a specific element, then assign
that element to a variable.
Lets assume variable b is the list ((10 5.5 2.7)(40 5)) and you looking for a code 40. You want to pull out
the entire element and assign it to a variable c. eg:
(setq c (assoc 40 b))
This assigns the entire element containing the 40 in the list b to variable c. Now c is
a list that looks like this: (40 5).
Subst (subsitute)
Allows you to substitute one aspect for another. When substituting ALWAYS substitute the new item for
the old in the list. Now lets substitute 20 for the 5 in the variable c.
(setq bl (subst '(40 20) c b))
Now bl is the new list.
'(40 20) is the new element substituted for the old element (40 5) c, found in list b.
If you want to use a variable which represents the value.
(setq bl (subst '(40 h) c b)), It looks like it should work, but it does not. The new element will look like
this: (40 h).
(subst) cannot interpret variables. You need to construct a new variable containing the entire list
element, then use
the new variable in the (subst) command.
Cons (Construct)
Constructs a new list with the new element placed at the begining. Assume variable c contains the
following list: (40 5).
Also, assume variable h contains the real number 20.0 then:
(setq d (cons (car c) h)) Remember (car c) gives you 40. Therefore, (car c) is the new first element,
followed by the value h. Thus it produces a new list d (40 20.0).
Now we substitute:
(setq bl (subst d c b)) That substitutes the new element found in variable d for the old element found in
variable c. (In the list found in variable b) and assigns the new list to bl.
Conversions
Angtos
Takes an angle in radians and converts it into a string, into a specific format.
Angtos Mode Format :
0 Degrees G
1 Degrees/minutes/seconds G
2 Grads G
3 Radians G
4 Surveyor's units G
Assuming variable a has an angle in radians. eg:
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (7 of 14) [23/03/2005 05:50:58 p.m.]
(angtos a 0 0) returns "180"
(angtos a 0 4) returns "180.0000"
(angtos a 1 4) returns "180d0"0""
Fix
This function returns the convention of a real number to an Integer. eg:
(fix 8) returns 8
(fix 8.6) returns 8
Float
This function returns the convention of an Integer to a real number. (One can use either real or an
Integer.) eg:
(float 8) returns 8.0000
(float 8.6) returns 8.6000
Ascii
Returns the convention of the first character of a string into its ASCII character code. (An Integer) eg:
(ascii "a") returns 65
(ascii "BLUE") returns 66
Chr
Returns the convention of an Integer representing an ASCII character code into a single character
string. eg:
(chr 65) returns "A"
(chr 66) returns "B"
Atof
Returns the convention of a string into a real number. eg:
(atof "9.3") returns 9.3000
(atof "2") returns 2.0000
Rtos
Returns the convention of a real number to a string into a
specified format.
Rtos Mode Format
1 Scientific G
2 Decimal G
3 Engineering(feet & decimal inches) G
4 Architectural(feet & fractional inches) G
5 Arbituary fractional units G
The real number can be set according to mode and precision. eg:
(rtos 7.2 1 4) returns "7.200OE+00"
(rtos 7.2 2 2) returns "7.20"
Itoa
Returns the convention of an Integer into a string. eg:
(itoa 25) returns "25"
Atoi
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (8 of 14) [23/03/2005 05:50:58 p.m.]
Returns the convention of a string into an Integer. eg:
(itoi "25") returns 25
Conditionals
(=)
Is not an assignment command, only (setq) is. The (=) command is used only to test if items are equal. It
does not make them equal.
if
(if) is the standard if-then-else statement. In AutoLISP you may only match one if statement with a then
statement. eg:
(if (= a b) (setq b 5 (setq b 6))
If a is equal to b, then b will be assigned the value of 5.
If it is not then b will be assigned the value of 6.
Cond (Conditional)
This function accepts any number of lists as arguments. It evaluates the first item in each list (in order
supplied) until one of these items are a value other than nil.
eg: A user's response string is variable s,
(cond
((= s "Y") 1)
((= s "y") 1)
((= s "N") 0)
((= s "n") 0)
(t nil)
)
This function tests the response and returns 1 if it is "Y" or "y", and 0 if it is "N" or "n", and nil
otherwise.
Repeat
Similar to a loop but repeat will only go through the commands as many times as is told. eg:
(setq a 10)
(setq b 100)
(repeat 4
(setq a (+ a 10))
(setq b (+ b 10))
Returns 140.
While
Is another loop control command available in AutoLISP. A loop is necessary if you want to repeat a
command. However, unless you have a way of controlling it, the program will run forever and hang you
up. eg:
(setq a "w")
Sets up the controlling variable to a value other than nil.
(while a
The loop will continue, begining with the commands that follow, until the variable a is set to nil.
(xxxx)
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (9 of 14) [23/03/2005 05:50:58 p.m.]
(xxxx) Are the commands that are performed in the loop.
(if (= c d) (setq a nil))
Evaluates if c is equal to d, and if so, sets the loop controlling variable a to nil to end the loop.
)
While parenthesis closes loop, and program will continue with the commands after this.
Entities
An entity is the smallest object you can place on your screen. The following are entities: LINE, CIRCLE,
ARC, TEXT, POLYLINES, etc. Entities are stored and referenced in the drawing database. They can be
changed and manipulated using AutoLISP to suit your needs. Each entity has a massive definition in
AutoCAD's database. eg: The data for a single line contains the following info:
Entity name, Entity type, Layer, Color, Beginning X Y coordinate, Ending X Y coordinate, Line type, etc.
You can modify any of the above aspects. An example of an entity list:
( - 1 <Entity name: 60000014) (0 "CIRCLE") (8 . "LAYER1")
(10 . 50.000 100.000) (40 . 60.000)
It is an entity list of a circle on layer LAYER1, center point relative to 0,0 of 50.0,100.0 , and a radius of
60.0
Ssget and Entsel (select entities)
Both give you a way of selecting the entities for the selection set. (entsel) only selects one entity at a
time. You may not use WINDOW or CROSSING to select entities. (ssget) however lets use WINDOW or
CROSSING as well as other selection techniques. You will mostly be using (ssget).
(setq a (ssget)) will prompt you to select objects. You have now created a selection set with a specific
name, <Selection set:l> , assigned to variable a, or use filter option (setq a (ssget "X" '((0 . "TEXT")))) to
search database for certain entities or codes.
Ssname (get entity name)
Lets you secure the name of the entity. The name of the entity is realy a hexadecimal number, therefore
don't expect to see a name like LINE, or CIRCLE etc. The name of your entity might be 60000018.
Lets assume variable a is the selection set and variable i is set to 0. (setq i 0) To set Counter variable.
(setq na (ssname a i)) This assigns na the entity name found in the selection set a at index number i.
Remember that a selection set may contain more than one entity name. You can point to each entity by
using its relative number in the selection set. eg: Entity 1 is Index 0 , Entity 2 is Index 1 , etc.
Entget (get entity list)
This command actually pulls out, or extracts, the entity list. The entity list can be assigned to a variable.
(setq b (entget na)) That assigns to b the entire entity list for that entity name.
Subst (substitute new for old)
Allows you to substitute one aspect for another. Assume variable b is the name of the list and variable c
contains the value of the element: (40 . 60.0000) (setq bl (subst '(40 . 30.0000) c b)) ;bl is now the new
list. '(40 . 30.0000) is the new element substituted for the old element c found in list b.
Sslength
Gives you the length or number of selections made.
Entmod (entity modification)
Gives you the ability to take the newly modified entity list and write it back to the database to update the
drawing. Now that you have a new list in the variable b1, you want to make bl the permanent list in your
drawing database. (entmod bl) You should see the change appear on the screen.
Change Cross Hair Angle
This program permits you to draw lines perpendicular to other lines. The program measures the angle
of the line chosen, and shifts the SNAP ANGLE to the angle of that line. Use ORTHO ON and draw
perpendicular to your chosen line.
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (10 of 14) [23/03/2005 05:50:58 p.m.]
(defun c:perpdon (/ a b pntl pnt2 angl)
(graphscr)
(setq a (entsel))
(setq b (entget (car a)))
(setq pntl (cdr (assoc 10 b)))
(setq pnt2 (cdr (assoc 11 b)))
(setq angl (angle pntl pnt2))
(setvar "snapang" ang1)
(princ)
)
(defun c:perpdoff
(setvar "snapang" 0)
(princ)
)
Erase Screen
Erases everything on the drawing screen. If you are in a ZOOM ALL position, the program erases
everything within the limits of the drawing.
Note: if you accidentally invoke this command, you can recover with OOPS.
(defun c:erasescr (/ l u)
(setq l (getvar "limmin"))
(setq u (getvar "limmax"))
(command "erase" "w" l u "")
(princ)
)
Change Layer
Lets you select objects by any selection method and change their layer. The target layer is chosen by
simply pointing to an object on the desired layer. All objects selected will then change to that target
layer. To test this program, you will need to create a drawing with objects on different layers.
(defun c:chlayer (/ a1 a2 n index b1 b2 d1 d2 b3)
(graphscr)
(prompt "\nselect entities to be changed: ")
(setq a1 (ssget))
(prompt "\npoint to entity on target layer: ")
(setq a2 (entsel))
(setq n (sslength a1))
(setq index 0)
(setq b2 (entget (car a2)))
(setq d2 (assoc 8 b2))
(repeat n
(setq b1 (entget (ssname a1 index)))
(setq d1 (assoc 8 b1))
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (11 of 14) [23/03/2005 05:50:58 p.m.]
(setq b3 (subst d2 d1 b1))
(entmod b3)
(setq index (+ index 1))
)
(princ)
)

Now examine the program line by line.
(defun c:chlayer (/ a1 a2 n index b1 b2 d1 d2 b3)
Defines the function with all local variables.
(graphscr)
Changes to graphics screen.
(prompt "\nSelect entities to be changed: ")
This is a prompt statement.
(setq a1 (ssget))
Allows you to select the objects to be changed. The selection set is assigned to variable al.
(prompt "\npoint to entity on target layer: ")
This is a prompt statement.
(setq a2 (entsel))
This is a special type of selection statement that allows you to select only one entity.
(setq n (sslength a1))
Measures the number of entities in the selection set in variable a1.
(setq index 0)
Sets the variable called index to 0.
(setq b2 (entget (car a2)))
This statement gets the entity list from a2. Thus, a2 is assigned the entity list.
(setq d2 (assoc 8 b2))
This looks for the code 8 in entity list a2, then assigns the sublist to d2.
(repeat n
This begins the loop that pages through the selection set.
(setq bl (entget (ssname a1 index)))
This gets the entity list and assigns it to b1.
(setq d1 (assoc 8 b1))
Gets the sublist code 8 (the layer).
(setq b3 (subst d2 d1 b1))
Substitutes the new d2 layer for the old d1 layer in the entity list a1, and assigns it to the new entity list
b3.
(entmod b3)
Updates the new entity list in the database.
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (12 of 14) [23/03/2005 05:50:58 p.m.]
(setq index (+ index 1))
Increases the index variable by 1, making it ready for the next loop.
The first ) closes the repeat loop. (princ) exits quitly. The second ) closes the function.
Substitute text
This program lets you choose a line of text and substitute another line at exactly the same place.
(defun c:subtext (/ a b d e d1 b1 y)
(prompt "\nSelect text line: ")
(setq a (entsel))
(setq b (entget (car a)))
(setq d (assoc 1 b))
(prompt (cdr d))(terpri)
(setq e (getstring 1))
(setq d1 (cons (car d) e))
(setq b1 (subst d1 d b))
(entmod b1)
(setq y (getstring "\nIs this correct - Y : "))
(if (= (srtcase y) "N") (entmod b))
(princ)
)

TEXT- OWN DISTANCE, OWN TEXT HEIGHT
This program lets you change the distance between multiple text lines. In addition to the standard start
point and height, you are asked to enter the distance between text lines. You may enter as many text
lines as you wish. To stop the program, enter an asterix (*).
(defun tex (/ p1 a b c d e f)
(setq pl (getpoint "\nStarting point: "))
(setq a (getdist p1 "\nEnter height: "))
(setq c (getdist p1 "\nline spacing: "))
(setq d "T")
(while d
(setq e (getstring 1 "Text: "))
(command "text" pl a "0" e)
(setq pl (list (car p1)(- (cadr p1) c)))
(setq f (getstring))
(if (= f "*") (setq d nil))
)
(princ)
)

GLOBAL TEXT HEIGHT CHANGE
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (13 of 14) [23/03/2005 05:50:58 p.m.]
This program allows you to globally change the size of text within a WINDOW or CROSSING without
affecting other entities.
(defun chtext (/ a ts n index b1 b c d b2)
(setq a (ssget))
(setq ts (getreal "\nEnter new text size"))
(setq n (sslength a))
(setq index 0)
(repeat n
(setq b1 (entget (ssname a index)))
(setq index (1+ index))
(setq b (assoc 0 b1))
(if (= "TEXT" (cdr b))
(progn
(setq c (assoc 40 b1))
(setq d (cons (car c) ts))
(setq b2 (subst d c b1))
(entmod b2))))
(princ)
)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp Quick Start
http://www.afralisp.com/lispa/lisp.htm (14 of 14) [23/03/2005 05:50:58 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III. Page IV.
The Basics in a Nutshell - Page I.
So, you've never programmed in AutoLisp before!
You've tried to decipher some AutoLisp routines but, you are still totally confused!!!
Let's see if we can't help you out.
This tutorial will try and teach you the very basics of AutoLisp programming without
overwhelming you with double-gook.
Let's start up with something very simple and that will give you immediate results. Fire up
AutoCad and type this at the command prompt:
(alert "Yebo Gogo")
Now press enter. This should appear on your screen :
Well Done, you've just used AutoLisp to make AutoCad do something.
By the way, most other programming tutorials use "Hello World" as a similar example. But,
because this is an African site, I thought that I would use a very well known Zulu phrase instead.
As you noticed using the (alert) function results in a dialogue box being displayed on your screen.
Let's try something else. Type this at the command prompt and press enter :
(setq a (getpoint))
Then choose a point anywhere on the screen.
A "list" of numbers, looking something like this, should appear in your command window.
(496.0 555.06 0.0)
This list, believe it or not, contains the x, y and z coordinates of the point you picked.
x = 496.04
y = 555.06
z = 0.0
The AutoLisp coding :
(setq a (getpoint))
Means, in plain English :
Get a point from the user and store the x, y and z
values as a list in variable "a".
Did you notice how everything is enclosed within parenthesis?
All AutoLisp functions are surrounded by parenthesis.
As well, AutoLisp allows you to "nest" your functions.
The Basics in a Nutshell Page I
http://www.afralisp.com/lispa/lisp16.htm (1 of 3) [23/03/2005 05:50:59 p.m.]
This lets you write a function that evaluates another function.
Just remember, that you must leave the nest with an equal number of parenthesis. Here's an
example :
(dosomething (dosomethingelse (andanotherthing)))
You could also write the above statement like this to make it more readable :
(dosomething
(dosomethingelse
(andanotherthing)
)
)
Now you can see why "Lisp" is often known as "Lost in Stupid Parenthesis"
You can also add comments to your coding. Anything preceded with a semicolon is not evaluated by
Autolisp and is treat as a comment, much the same way as the REM statement in Basic is used. e.g.
(dosomething
(dosomethingelse
(andanotherthing) ;This is a comment
) ;This is another comment
) ;and another comment
The statement we wrote earlier, told AutoLisp to get a point from the user and store the value in
variable "a".
Now type this at the command line :
!a
The point list should be returned. So, any time that you would like to inspect a variable, just
precede the variable name with "!"
Our getpoint function worked, but it didn't really tell the user what was expected from him by way
of input. Try this now :
(setq a ( getpoint "\nChoose a Point : "))
Did you notice how Autolisp now asks you for input (and what type of input is expected.)
Let's write a programme.
Type in each of these lines, one at a time, pressing "Enter" at the end of each line, then choosing a
point.
(setq a (getpoint "\nEnter First Point : "))
Press "Enter" then select a point.
(setq b (getpoint "\nEnter Second Point : "))
Again, Press "Enter" then select a second point.
(command "Line" a b "")
Press "Enter" again. A line should be drawn between the two points.
The (command) function is used to tell AutoCad what you want it to do.
"Line" Draw a Line
a From the point stored in variable "a"
b To the point stored in variable "b"
"" Enter to close the Line command.
Now this is very nice, but do we have to type in all this coding every time we want to use this
routine?
On the next page we will discuss how to "store" your programmes in a file.
Home. Page II. Page III. Page IV.
The Basics in a Nutshell Page I
http://www.afralisp.com/lispa/lisp16.htm (2 of 3) [23/03/2005 05:50:59 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Basics in a Nutshell Page I
http://www.afralisp.com/lispa/lisp16.htm (3 of 3) [23/03/2005 05:50:59 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III. Page IV.
The Basics in a Nutshell - Page II.
We now need to be able to "store" our AutoLisp routines in a file.
AutoLisp files are simple ASCII text files with the extension "lsp".
Open up Notepad or any other simple text editor and type in the following :
(defun testline ()
;define the function
(setq a (getpoint "\nEnter First Point : "))
;get the first point
(setq b (getpoint "\nEnter Second Point : "))
;get the second point
(command "Line" a b "")
;draw the line
) ;end defun
Now, save this file as "testline.lsp" remembering, to save it as a ASCII Text file and ensuring that it
is saved in a directory in your AutoCAD's search path. Now open AutoCAD and type this :
(load "testline")
This will load the function into memory. (Did you notice that you do not have to stipulate the "lsp"
extension?) Now type this :
(testline)
Your function should now run.
Let's edit this routine so that it acts like a standard AutoCAD command :
(defun c:testline ()
;define the function
(setq a (getpoint "\nEnter First Point : "))
;get the first point
(setq b (getpoint "\nEnter Second Point : "))
;get the second point
(command "Line" a b "")
;draw the line
) ;end defun
The Basics in a Nutshell Page II
http://www.afralisp.com/lispa/lisp161.htm (1 of 4) [23/03/2005 05:51:01 p.m.]
By preceding the function name with c: we do not have to enclose the name with brackets when
running. Re-load the function and run it again.
(load "testline")
testline
Much better, Hey.
We do have one problem though. Did you notice that when we loaded the routine, an annoying
"nil" kept on popping up. We also got the same "nil" returned to us when we ran the routine. To
suppress this "nil" when loading or
running, we can use the (princ) function. Here's what your routine would look like :
(defun c:testline ()
;define the function
(setq a (getpoint "\nEnter First Point : "))
;get the first point
(setq b (getpoint "\nEnter Second Point : "))
;get the second point
(command "Line" a b "")
;draw the line
(princ)
;clean running
) ;end defun
(princ)
;clean loading
For more details on the (defun) function, refer to The AfraLisp Tutorial :
Define Function (defun).
And for a more detailed expanation of loading AutoLisp routines, refer to the AfraLisp tutorial :
Loading AutoLisp Files.

Now it's time to make AutoLisp do some calculations for us.


Let's say we wanted AutoLisp to draw a beam, in elevation, for us.
First of all we would start by getting input from the user regarding certain parameters that we
would need to draw the beam.
Here's what we are trying to draw, along with the values that the user
needs to input.
The Basics in a Nutshell Page II
http://www.afralisp.com/lispa/lisp161.htm (2 of 4) [23/03/2005 05:51:01 p.m.]
The values that we need to retrieve from the user are as follows :
Insertion Point ip
Length of Beam lb
Height of Beam hb
Flange Thickness wt
End Plate Thickness ep
Length of Notch nl
Depth of Notch nd
Let's write a routine to retrieve these values first.
(defun c:testbeam ()
;define the function
;********************************************************
;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam
(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam
(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange
(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate
(setq nl (getdist "\nLength of Notch : "))
;get the length of notch
(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point
(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point
;********************************************************
(princ)
;finish cleanly
) ;end of defun
;**********************************************************
(princ) ;load cleanly
;**********************************************************
Load and run the routine. You will be prompted for all the values listed above. Enter some
numbers and then check the value of all the variables by preceeding the value names with "!" (e.g.
!ip).
O.K. we've got all the values we need from the user.
The Basics in a Nutshell Page II
http://www.afralisp.com/lispa/lisp161.htm (3 of 4) [23/03/2005 05:51:01 p.m.]
But first we need to do some calculations to determine the other points required before we can
draw the beam.
See you on the next page.......
Page I. Home. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Basics in a Nutshell Page II
http://www.afralisp.com/lispa/lisp161.htm (4 of 4) [23/03/2005 05:51:01 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home. Page IV.
The Basics in a Nutshell - Page III.
Well, as you can see, we have quite a few points that we need to calculate.
Fortunately, AutoLisp has a function to help us, the (polar) function.
The (polar) function works like this :
You pass it a point, an angle and a distance and (polar) will return a second point at the specified
angle and distance from the first point.
But, we have one problem. All angles in AutoLisp MUST be given in radians.
Let's quickly write a function to do that. Add this function to your Testbeam.lsp file :
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
) ;end of function
O.K. thats our "degrees to radians" function taken care of.
Now we'll have a look at the (polar) function in action.
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
What we are saying here is :
"Set the variable "p2" to a point that, from the insertion point "ip", at an angle of 180.0 degrees
(converted to radians), is at a distance of the length of the beam divided by 2, minus the length of
the notch."
This will calculate and return the point "p2". Let's do the rest :
(defun c:testbeam ()
The Basics in a Nutshell Page III
http://www.afralisp.com/lispa/lisp162.htm (1 of 5) [23/03/2005 05:51:02 p.m.]
;define the function
;********************************************************
;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam
(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam
(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange
(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate
(setq nl (getdist "\nLength of Notch : "))
;get the length of notch
(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point
(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point
;********************************************************

;Start of Polar Calculations
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3 (polar p2 (dtr 270.0) wt))
(setq p4 (polar p2 (dtr 270.0) nd))
(setq p5 (polar p4 (dtr 180.0) nl))
(setq p6 (polar p5 (dtr 180.0) ep))
(setq p7 (polar p6 (dtr 270.0) (- hb nd)))
(setq p8 (polar p7 (dtr 0.0) ep))
(setq p9 (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations

;**********************************************************
(princ)
;finish cleanly
) ;end of defun
The Basics in a Nutshell Page III
http://www.afralisp.com/lispa/lisp162.htm (2 of 5) [23/03/2005 05:51:02 p.m.]
;**********************************************************
;This function converts Degrees to Radians.
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
) ;end of function

;**********************************************************
(princ) ;load cleanly
;**********************************************************
Right, now that we've calculated all the points required to draw the beam, let us add a (command)
function to do this task for us.
(defun c:testbeam ()
;define the function
;********************************************************
;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam
(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam
(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange
(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate
(setq nl (getdist "\nLength of Notch : "))
;get the length of notch
(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point
(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point
;********************************************************
;Start of Polar Calculations
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3 (polar p2 (dtr 270.0) wt))
(setq p4 (polar p2 (dtr 270.0) nd))
The Basics in a Nutshell Page III
http://www.afralisp.com/lispa/lisp162.htm (3 of 5) [23/03/2005 05:51:02 p.m.]
(setq p5 (polar p4 (dtr 180.0) nl))
(setq p6 (polar p5 (dtr 180.0) ep))
(setq p7 (polar p6 (dtr 270.0) (- hb nd)))
(setq p8 (polar p7 (dtr 0.0) ep))
(setq p9 (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations
;**********************************************************

;Start of Command Function
(command "Line" ip p2 p4 p6 p7 p12 p13 p15 p17 "c"
"Line" p3 p16 ""
"Line" p9 p10 ""
"Line" p5 p8 ""
"Line" p11 p14 ""
) ;End Command
;End of Command Function

;*********************************************************
(princ)
;finish cleanly
) ;end of defun
;**********************************************************
;This function converts Degrees to Radians.
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
) ;end of function
;**********************************************************
(princ) ;load cleanly
;**********************************************************
O.K. Let's load the program and run it.
Now, depending on how your snap is set, the beam might be drawn correctly, or it may not. On my
system it doesn't draw properly.
This is because my snap defaults to intersection and AutoCad keeps on snapping to the wrong
point. I also have lot's of annoying "blips" on my screen. On the next page we'll discuss how to get
around these problems. See you there........
Page I. Page II. Home. Page IV.

The Basics in a Nutshell Page III


http://www.afralisp.com/lispa/lisp162.htm (4 of 5) [23/03/2005 05:51:02 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Basics in a Nutshell Page III
http://www.afralisp.com/lispa/lisp162.htm (5 of 5) [23/03/2005 05:51:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Page III. Home.
The Basics in a Nutshell - Page IV.
Snap settings in AutoCad can cause havoc with an AutoLisp routine.
Therefore, it's a very good idea to switch off the snap at the beginning of any AutoLisp
routine and only switch it on when it is required. Blips on your screen are also very
annoying, so switch them off too. Please, just remember to return the AutoCad settings
that you change, back to their original state before exiting your routine.
Let's edit our routine to include this :
(defun c:testbeam ()
;define the function
;********************************************************

;Save System Variables
(setq oldsnap (getvar "osmode"))
;save snap settings
(setq oldblipmode (getvar "blipmode"))
;save blipmode setting
;********************************************************
;Switch OFF System Variables
(setvar "osmode" 0)
;Switch OFF snap
(setvar "blipmode" 0)
;Switch OFF Blipmode

;********************************************************
;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam
(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam
(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange
(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate
(setq nl (getdist "\nLength of Notch : "))
;get the length of notch
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (1 of 9) [23/03/2005 05:51:04 p.m.]
(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point

(setvar "osmode" 32)
;switch ON snap

(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point

(setvar "osmode" 0)
;switch OFF snap

;********************************************************
;Start of Polar Calculations
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3 (polar p2 (dtr 270.0) wt))
(setq p4 (polar p2 (dtr 270.0) nd))
(setq p5 (polar p4 (dtr 180.0) nl))
(setq p6 (polar p5 (dtr 180.0) ep))
(setq p7 (polar p6 (dtr 270.0) (- hb nd)))
(setq p8 (polar p7 (dtr 0.0) ep))
(setq p9 (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations
;**********************************************************
;Start of Command Function
(command "Line" ip p2 p4 p6 p7 p12 p13 p15 p17 "c"
"Line" p3 p16 ""
"Line" p9 p10 ""
"Line" p5 p8 ""
"Line" p11 p14 ""
) ;End Command
;End of Command Function
;**********************************************************

;Reset System Variable
(setvar "osmode" oldsnap)
;Reset snap
(setvar "blipmode" oldblipmode)
;Reset blipmode

;*********************************************************
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (2 of 9) [23/03/2005 05:51:04 p.m.]
(princ)
;finish cleanly
) ;end of defun
;**********************************************************
;This function converts Degrees to Radians.
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
) ;end of function
;**********************************************************
(princ) ;load cleanly
;**********************************************************
Load and run the program. If you were having problems, they should now have disappeared. (I
hope!!). Did you notice how we switched on the snap just before asking for the insertion point?
This, of course, is to allow the user to snap to an insertion point.
We still have another problem though. What would happen if the user entered an illegal value, such
as zero, or a negative number.
This could cause very strange results.
To guard against this we will use the (initget) function.
Here's how it works :
(initget (+ 1 2 4))
(setq lb (getdist "\nLength of Beam : "))
This function works on the "sum of the bits" system.
1 = Disallows the user from pressing "Enter".
2 = Disallows the user from entering "Zero".
3 = Disallows the user from entering a "Negative Number".
The same function could have been written like this :
(initget 7)
(setq lb (getdist "\nLength of Beam : "))
Let's add this function to our routine :
(defun c:testbeam ()
;define the function
;********************************************************
;Save System Variables
(setq oldsnap (getvar "osmode"))
;save snap settings
(setq oldblipmode (getvar "blipmode"))
;save blipmode setting
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (3 of 9) [23/03/2005 05:51:04 p.m.]
;********************************************************
;Switch OFF System Variables
(setvar "osmode" 0)
;Switch OFF snap
(setvar "blipmode" 0)
;Switch OFF Blipmode
;********************************************************
;Get User Inputs

(initget (+ 1 2 4))
;check user input

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam

(initget (+ 1 2 4))
;check user input

(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam

(initget (+ 1 2 4))
;check user input

(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange

(initget (+ 1 2 4))
;check user input

(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate

(initget (+ 1 2 4))
;check user input

(setq nl (getdist "\nLength of Notch : "))
;get the length of notch

(initget (+ 1 2 4))
;check user input

(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point
(setvar "osmode" 32)
;switch ON snap
(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (4 of 9) [23/03/2005 05:51:04 p.m.]
(setvar "osmode" 0)
;switch OFF snap
;********************************************************
;Start of Polar Calculations
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3 (polar p2 (dtr 270.0) wt))
(setq p4 (polar p2 (dtr 270.0) nd))
(setq p5 (polar p4 (dtr 180.0) nl))
(setq p6 (polar p5 (dtr 180.0) ep))
(setq p7 (polar p6 (dtr 270.0) (- hb nd)))
(setq p8 (polar p7 (dtr 0.0) ep))
(setq p9 (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations
;**********************************************************
;Start of Command Function
(command "Line" ip p2 p4 p6 p7 p12 p13 p15 p17 "c"
"Line" p3 p16 ""
"Line" p9 p10 ""
"Line" p5 p8 ""
"Line" p11 p14 ""
) ;End Command
;End of Command Function
;**********************************************************
;Reset System Variable
(setvar "osmode" oldsnap)
;Reset snap
(setvar "blipmode" oldblipmode)
;Reset blipmode
;*********************************************************
(princ)
;finish cleanly
) ;end of defun
;**********************************************************
;This function converts Degrees to Radians.
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (5 of 9) [23/03/2005 05:51:04 p.m.]
) ;end of function
;**********************************************************
(princ) ;load cleanly
;**********************************************************
Now, everything should be running fine except for one thing.
What happens if we want to draw two beams with exactly the same values? We would have to go
through the whole routine again, entering exactly the same inputs. We could, of course, set up each
variable to default to the last value used, but we would still have to run through the whole routine.
Here's a better way. We'll enclose the complete routine in a (while) loop. Have a look :
(defun c:testbeam ()
;define the function
;********************************************************
;Save System Variables
(setq oldsnap (getvar "osmode"))
;save snap settings
(setq oldblipmode (getvar "blipmode"))
;save blipmode setting
;********************************************************
;Switch OFF System Variables
(setvar "osmode" 0)
;Switch OFF snap
(setvar "blipmode" 0)
;Switch OFF Blipmode
;********************************************************
;Get User Inputs

(initget (+ 1 2 4))
;check user input
(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam
(initget (+ 1 2 4))
;check user input
(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam
(initget (+ 1 2 4))
;check user input
(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange
(initget (+ 1 2 4))
;check user input
(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate
(initget (+ 1 2 4))
;check user input
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (6 of 9) [23/03/2005 05:51:04 p.m.]
(setq nl (getdist "\nLength of Notch : "))
;get the length of notch
(initget (+ 1 2 4))
;check user input
(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch
;End of User Inputs
;*********************************************************
;Get Insertion Point
(setvar "osmode" 32)
;switch ON snap

(while
;start of while loop

(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point
(setvar "osmode" 0)
;switch OFF snap
;********************************************************
;Start of Polar Calculations
(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3 (polar p2 (dtr 270.0) wt))
(setq p4 (polar p2 (dtr 270.0) nd))
(setq p5 (polar p4 (dtr 180.0) nl))
(setq p6 (polar p5 (dtr 180.0) ep))
(setq p7 (polar p6 (dtr 270.0) (- hb nd)))
(setq p8 (polar p7 (dtr 0.0) ep))
(setq p9 (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations
;**********************************************************
;Start of Command Function
(command "Line" ip p2 p4 p6 p7 p12 p13 p15 p17 "c"
"Line" p3 p16 ""
"Line" p9 p10 ""
"Line" p5 p8 ""
"Line" p11 p14 ""
) ;End Command
;End of Command Function
;**********************************************************

(setvar "osmode" 32)
;Switch ON snap
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (7 of 9) [23/03/2005 05:51:04 p.m.]
);end of while loop

;**********************************************************
;Reset System Variable
(setvar "osmode" oldsnap)
;Reset snap
(setvar "blipmode" oldblipmode)
;Reset blipmode
;*********************************************************
(princ)
;finish cleanly
) ;end of defun
;**********************************************************
;This function converts Degrees to Radians.
(defun dtr (x)
;define degrees to radians function
(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI
) ;end of function
;**********************************************************
(princ) ;load cleanly
;**********************************************************
The programme will now repeat itself indefinetly, asking for an insertion point and drawing a
beam, until the user presses enter.
This is how it works. The (while) function will continue to evaluate an expression until the
expression evaluates to nil. As long as the user selects a point, the expression is true. But, when the
user selects "Enter" the expression returns "nil" and the programme moves out of the loop.
(AutoLisp evaluates "Enter" as "nil")
I hope you have understood this tutorial and that it has given you a better understanding of
AutoLisp. You will find a more detailed explanation of many of the functions used here in other
tutorials on this site.
If you would like the source coding for this AutoLisp Tutorial
then Click Here. Cheers for Now......
Page I. Page II. Page III. Home.

The Basics in a Nutshell Page IV


http://www.afralisp.com/lispa/lisp163.htm (8 of 9) [23/03/2005 05:51:04 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Basics in a Nutshell Page IV
http://www.afralisp.com/lispa/lisp163.htm (9 of 9) [23/03/2005 05:51:04 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Define Function - (defun).
We've all seen something like this :
(defun C:DDSTEEL ( / t1 t2 h1 h2 ang)
This, of course, is the first line of an AutoLISP routine.
But, do you know what it all means?
When I started writing AutoLISP code, I was totally confused!!
The more I read, the more in a muddle I got.
Global, Local, Argument, Define, Aghhh......
So, if you are as confused as I was, read on.
Let's start at the very beginning. (A very good place to start, say you!)
The name of a program, or function, must be defined in the first statement, which is done by using
the command :
(defun [Define Function]
Why is there not a closing parenthesis after the (defun command?
There is! In fact the last parenthesis in the program is the one that closes (defun.
Anyway, let's carry on.
After (defun must come the name of the program :
(defun DDSTEEL
You do realise that the name of the AutoLISP file, is not necessarily the name of the program. In
fact, one AutoLISP file can have several programs inside.
Hey, that was easy, I hear you say. Now comes the hard part!!
After you've named your program you have three choices.
First, do nothing by using ( ) :
(defun DDSTEEL ( )
What you are saying here is that every variable that you use in your function is GLOBAL. A
GLOBAL variable is one that doesn't lose it's value when the program ends. For example, if PT3
was defined as 45.2 in your program, it would still have the value of 45.2 when your program ends
and would retain that value until you replace it with another value or, start a new drawing.
Secondly, you can declare your variables as LOCAL.
To do this you precede your variables with / :
(defun DDSTEEL ( / p1 p2 p3)
The following example shows the use of LOCAL symbols :
(defun TEST ( / ANG1 ANG2)
(setq ANG1 "Monday")
(setq ANG2 "Tuesday")
(princ (strcat "\nANG1 has the value " ANG1))
(princ (strcat "\nANG2 has the value " ANG2))
(princ)
Define Function (defun)
http://www.afralisp.com/lispa/lisp5.htm (1 of 3) [23/03/2005 05:51:05 p.m.]
);defun
Now, at the AutoCAD command line, assign the variables ANG1 and ANG2 to values other than
those used by the TEST function :
Command: (setq ANG1 45)
Command: (setq ANG2 90)
Verify their values :
Command: !ANG1 [Should return 45.0]
Command: !ANG2 [Should return 90.0]
Now run our function :
Command: (load "TEST")
Command: (TEST)
The function should return :
ANG1 has the value Monday
ANG2 has the value Tuesday
Now check the current values of ANG1 and ANG2 :
Command: !ANG1
Command: !ANG2
You will find that they still have the values of 45.0. and 90.0 respectively.
A LOCAL variable is one that has a value only for that program while the program is running.
The third option is to list a variable without the /.
This means that a variable is set up to receive a value passed to it from outside the program. eg :
(defun DTR (a)

(* PI (/a 180.0))
)
To use this, we must pass the value of the argument to the function :
(DTR 90.0)
Here is another example :
Let us write a function that calculates the area of a circle.
The formulae for calculating the area of a circle is:
Area = PI x radius squared or, PI x r x r
Our program would look like this :
(defun acirc (r)

(setq a (* (* r r) PI))

(setq a (rtos a))

(princ (strcat "\nArea = " a))
(princ)
)
Now try it :
Command: (load "acirc")
Command: (acirc 24)
Define Function (defun)
http://www.afralisp.com/lispa/lisp5.htm (2 of 3) [23/03/2005 05:51:05 p.m.]
It should return :
Area = 1809.6
You can, of course combine all three options, for example :
(defun DDSTEEL ( a / b c d)
DDSTEEL is the name of the function. Variable a is an argument and receives the first value passed
to it from outside the program.
Variables b, c, and d are all locals and lose their values once the program has ended.
Another option that can be used with (defun is if the name of the function is preceded with C:
(defun C:DDSTEEL ()
Because of the C: you don't have to use parenthesis to call the function.
AutoCAD now thinks of that function as an AutoCAD command.
This is only true if you call the function from the AutoCAD command line.
If you call the function from within another function you must precede it with C:
(C:DDSTEEL)
It's a good idea to leave all variables as global whilst you are writing your
program so that you can check their values during debugging.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Define Function (defun)
http://www.afralisp.com/lispa/lisp5.htm (3 of 3) [23/03/2005 05:51:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Loading AutoLISP Files.
Note!!
One of the most important things to remember about loading AutoLisp Routines is to ensure that
your Lisp files and any support files (i.e DCL Files; DAT Files; etc) are in your AutoCad search
path. (I dedicate a directory to all my Lisp files and relevant support files.
There are numerous ways of loading AutoLisp Files :
Command Line Loading.
The simplest is from the AutoCad command line.
The syntax for loading AutoLisp files is :
(load "filename")
The.lsp extension is not required.
Menu Loading.
The following code samples are one way of loading AutoLisp files from a menu.
Pull Down Menu's :
***POP12
T_Steel [Steel Menu]
T_Beams [Drawing Setup]^C^C^P+
(cond ((null C:DDSTEEL) (prompt "Please Wait...")(load "DDSTEEL"))) DDSTEEL
Toolbars :
***TOOLBARS
**STEEL
TB_DDSTEEL [_Button("Steel", "STEEL.bmp", "STEEL32.bmp")]^C^C^P+
(cond ((null C:ddsteel) (prompt "Please Wait...")(load "ddsteel"))) ddsteel
This method of loading Lisp files first checks to see if the routine is already loaded. If it is, it runs
the routine. If it is not, it first loads the routine, then runs it. Clever Hey...
Acad.Lsp File.
The Acad.Lsp file is a useful way of loading a library of AutoLisp routines.
Each time you start a drawing AutoCad searches the library path for an Acad.Lsp file. If it finds
one, it loads the file into memory.
You could use the normal load function (load "filename") in your Acad.Lsp file but if an error
occurs whilst attempting to load one of your routines, the remainder of the file is ignored and is not
loaded.
Therefore, you must use the on failure argument with the load function :
(load "Lispfile1" "\nLispfile1 not loaded")
(load "Lispfile2" "\nLispfile2 not loaded")
(load "Lispfile3" "\nLispfile3 not loaded")
Loading Autolisp Files
http://www.afralisp.com/lispa/lisp4.htm (1 of 2) [23/03/2005 05:51:06 p.m.]
The .MNL File
The other type of file that AutoCad loads automatically is the .MNL file.
If you have a partial menu file it can also have it's own .MNL file.
Just remember that the .MNL file must have exactly the same name as your partial menu file.
(except for the .MNL extension, of course.)
You can load Lisp files from this file using the load function exactly the same as you did in the
Acad.Lsp file.
Command Autoloader
When you automatically load a command from your Acad.Lsp file (or a .MNL file) the commands
definition consumes your systems resources whether you actually use the command or not. The
Autoload function makes a command available without loading the entire routine into memory.
(Autoload "Utils" '("Utils1" Utils2" "Utils3"))
(Autoload "DDSteel" '("DDSteel"))
This would automatically load the commands Utils1, Utils2 and Utils3 from the Utils.Lsp file and
DDSteel from the DDSteel.Lsp file.
S::Startup Function.
If the user defined function S::Startup is included in the Acad.lsp or a .MNL file,
it is called when you enter a new drawing or open an existing drawing.
e.g. Say that you wanted to override the standard AutoCad LINE and COPY commands with
versions of your own, your Acad.Lsp file would something like this :
(defun C:LINE ()
.....Your Definition.....
)
(defun C:COPY ()
.....Your Definition.....
)
(defun S::Startup ()
(command "Undefine" "LINE")
(command "Undefine" "COPY")
)
Before the drawing is initialised, new definitions for LINE and COPY are defined. After the
drawing is initialised, the S::Startup function is called and the standard definitions of LINE and
COPY are undefined.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Loading Autolisp Files
http://www.afralisp.com/lispa/lisp4.htm (2 of 2) [23/03/2005 05:51:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp Quick Reference Table.
(+ <NUMBER> <NUMBER> ...)
Returns the sum of two or more numbers.
(- <NUMBER> <NUMBER> ...)
Returns the difference of two or more numbers.
(* <NUMBER> <NUMBER> ...)
Returns the product of two or more numbers.
(/ <NUMBER> <NUMBER> ...)
Returns the quotient of two or more numbers.
(= <NUMBER> <NUMBER> ...)
Returns T if the numbers are equal, nil if not.
(/= <NUMB1> <NUMB2>)
Returns T if the numbers are not equal, nil if they are.
(< <NUMB1> <NUMB2>)
Returns T if <NUMB1> is less than <NUMB2>.
(<= <NUMB1> <NUMB2>)
Returns T if <NUMB1> is equal to or less than <NUMB2>.
(> <NUMB1> <NUMB2>)
Returns T if <NUMB1>is greater than <NUMB2>.
(>= <NUMB1> <NUMB2>)
Returns T if <NUMB1> is equal to or greater than <NUMB2>.
(~ <NUMBER>)
Returns the bitwise of <NUMBER>.
(1+ <NUMBER>)
Returns the <NUMBER> increased by one.
(1- <NUMBER>)
Returns the <NUMBER> decreased by one.
(abs <NUMBER>)
Returns the absolute value of <NUMBER>.
(and <EXPR> ...)
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (1 of 9) [23/03/2005 05:51:08 p.m.]
Returns the logical AND of a list of expressions.
Returns nil if expressions are nil.
(angle <PT1> <PT2>)
Returns the angle in radians between two points.
(angtos <ANGLE>[<MODE><PRECIS.>])
Returns the angle as a string. Mode 0=Degrees,1=Deg Min Sec,
2=Grads,3=Radians,4=Surveyor
(append <EXPR> ....)
Returns a number of lists as one list.
(apply <FUNCTION> <LIST>)
Executes function with the arguments given as a list.
(ascii <STRING>)
Returns ascii value of first character of a string.
(assoc <ITEM><ALIST>)
Searches <ALIST> for <ITEM>.
(atan <NUM1> [<NUM2>])
Returns the arctangent of <NUM1> or <NUM1>/<NUM2>.
(atof <STRING>)
Returns the conversion of a string into a real.
(atoi <STRING>)
Returns the conversion of a string into an integer.
(atom <ITEM>)
Returns T if <ITEM> is not a list.
(Boole <FUNC> <NUMB1> <NUMB2)
Returns Boolean bitwise truth comparisons.
<NUMB>'s must be integers.
(boundp <ATOM>)
Returns T if <ATOM> has a value bound to it.
(car <LIST>)
Returns the first element of a list.
(caar <LIST>)
Returns first element of the first element of a list.
(cadar <LIST>)
Returns last element of the first element of a list.
(cadr <LIST>)
Returns the second element of a list.
(caddr <LIST>)
Returns the third element of a list.
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (2 of 9) [23/03/2005 05:51:08 p.m.]
(cdr <LIST>)
Returns all but the first element of a list.
(cdar <LIST>)
Returns second element of the first element of list.
(cddr <LIST>)
Returns all but first element of last element list.
(chr <NUMBER>)
Returns the string represented by an ascii value.
(close <FILENAME>)
Closes a file.
(command <ARGS>...)
Executes an AutoCAD command.
(cond (<TEST1><RESULT1>)...)
Evaluates any number of lists as arguments.
(cons <NEW FIRST ELEMENT><LIST>)
Contructs a new list.
(cos <ANGLE>)
Returns the cosine of an angle.
(defun <SYM><ARG LIST><EXPR>...)
Defines an AutoLISP function.
(distance <PT1> <PT2>)
Returns the distance between two points.
(entnext [<ENAME>])
Returns the first non-deleted entity after <ENAME>.
(entlast)
Returns the last non-deleted entity in the database.
(entsel [<PROMPT>])
Selects a single entity by a point pick.
(entdel <ENAME>)
Deletes the entity <ENAME> or undeletes it if it
has already been deleted.
(entget <ENAME>)
Returns <ENAME> from the database as a list.
(entmod <ENAME>)
Updates <ENAME> in the database. NOT for blocks or polylines
(entupd <ENAME>)
Updates <ENAME> in the database. Use for polylines or blocks.
(eq <EXPR1> <EXPR2>)
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (3 of 9) [23/03/2005 05:51:08 p.m.]
Returns T if expressions are bound to same object.
(equal <EXPR1> <EXPR2>)
Returns T if the expressions are equal.
(eval <EXPR>)
Evalutes an expression.
(exp <NUMBER>)
Returns E to the power <NUMBER>.
(expt <BASE> <NUMBER>)
Returns <BASE> to the power <NUMBER>.
(findfile <FILENAME>)
Searches all paths to find <FILENAME>.
(fix <NUMBER>)
Converts <NUMBER> to an integer.
(float <NUMBER>)
Converts <NUMBER> to a real.
(foreach <NAME><LIST><EXPR>)
Evaluates <EXPR> for each element in the <LIST>
and assigns to <NAME>.
(gcd <NUM1> <NUM2>)
Returns the greatest common denominator.
(getangle [<PT>][<PROMPT>])
Pauses for input of an angle at optional starting point <PT>.
(getcorner [<PT>][<PROMPT>])
Getpoint function - draws triangle as crosshairs move.
(getdist [<PT>][<PROMPT>])
Pauses for input of distance at optional start point.
(getenv [<VARIABLE>])
Returns string value assigned to a system variable.
(getkword [<PROMPT>])
Requests a keyword from the user.
(getorient [<PT>][<PROMPT>])
Returns angle in radians from current orientation.
(getpoint [<PT>][<PROMPT>])
Pauses for input of an angle at optional point <PT>.
(getreal [<PROMPT>])
Pauses for input of a real number.
(getstring [<CR>][<PROMPT>])
Pauses for input of a string.
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (4 of 9) [23/03/2005 05:51:08 p.m.]
(getvar <varname>)
Retrieves the value of an AutoCAD system variable.
(graphscr)
Flips from text screen to graphics screen.
(grclear)
Clears the graphics screen.
(grdraw <from><to><color>[<highlight>])
Draws a vector between two points.
(grtext <box><text><highlight>])
Write to text portion of graphics screen.
(grread <track>)
Allows AutoLISP to read AutoCADs input devices.

(if <testexpr><thenexpr>[<elseexpr>])
Conditionally evaluates expressions.
(inters <pt1><pt2><pt3><pt4>[<onseg>])
Returns the intersection point of two lines.
If <ONSEG> is greater than 0 the intersection
may lie past the endpoints of the lines.
(itoa <number>)
Returns the conversion of an integer to a string.
(lambda <arguments><expr>...)
Defines an "anonymous" function.
(last <list>)
Returns the last element in <LIST>.
(length <list>)
Returns the number of elements in <LIST>.
(list <expr>)
Returns the list of a number of expressions.
(listp <list>)
Returns T if the item is a list.
(load <filename>)
Loads an AutoLISP program in memory.
(log <number>)
Returns natural log of <NUMBER> as a real.
(logand <number><number>...)
Returns the logical bitwise AND of a list of numbers.
(logior <number><number>...)
Returns the logical bitwise OR of a list of numbers.
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (5 of 9) [23/03/2005 05:51:08 p.m.]
(lsh <numb1><numbits>)
Returns the logical bitwise SHIFT operator of <NUM1>
by <NUMBITS>
(mapcar <function><list1>...<listn>)
Executes <FUNCTION> on the elements of <LIST1>
through <LIST2>.
(max <number><number>...)
Returns the maximum of the numbers given.
(member <expr><list>)
Searches <LIST> for first occurence of <EXPR>
and returns the remainder of the list.
(menucmd <string>)
Switch between pages in an AutoCAD menu.
(min <NUMBER><NUMBER>...)
Returns the smallest of the numbers given.
(minusp <ITEM>)
Returns T if the item is negative.
(not <ITEM>)
Returns T if the expression is nil.
(nth <n><LIST>)
Returns the "nth" element of <LIST>.
(null <ITEM>)
Returns T if <ITEM> is bound to nil.
(numberp <ITEM>)
Returns T if <ITEM> is an integer or a real.
(open <FILENAME><MODE>)
Opens a file.
(or <EXPR>...)
Returns the logical OR of a list of expressions.
(osnap <PT><MODE-STRING>)
Returns a point by applying the osnap command.
(polor <PT><ANGLE><DISTANCE>)
Returns point at <ANGLE> and <DISTANCE> from <PT>.
(prin1 <EXPR>[<FILENAME>])
Prints <EXPR> on the screen or to <FILENAME>.
(princ <EXPR>[<FILENAME>])
Same as prin1 except control character are printed
without expansion.
(print <EXPR>[<FILENAME>])
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (6 of 9) [23/03/2005 05:51:08 p.m.]
Same as prin1 except a new line is printed before
<EXPR> and a space is printed after.
(progn <EXPR>...)
Evalutes each expression sequentially.
(prompt <MSG>)
Displays <MSG> on the screen PROMPT area.

(quote <EXPR>)
Returns <EXPR> unevaluated.

(read <STRING>)
Returns the first LIST obtained from <STRING>.
(read-char [<FILENAME>])
Returns a character from the keyboard buffer or from <FILENAME>.
(read-line [<FILENAME>])
Returns a string from the keyboard buffer or from <FILENAME>.
(redraw [<ENAME>][<MODE>])
Redraws either entire drawing, or <ENAME> in <MODE>.
(rem <NUM1> <NUM2> ...)
Returns the remainder of <NUM1>/<NUM2>.
(repeat <NUMBER> <EXPR> ...)
Evaluates each expression <NUMBER> times.
(reverse <LIST>)
Returns a list reversed.
(rtos <NUMBER> [<MODE><PRECIS>])
Returns a real number as a string.

(set <SYM><EXPR>)
Sets the value of a sysmbol name.
(setq <SYM1><EXPR1>...)
Sets the value of <SYM1> to <EXPR1>.
(setvar <VARNAME><VALUE>)
Sets a system variable to <VALUE>.
(sin <ANGLE>)
Returns the sine of an angle.
(sqrt <NUMBER>)
Returns the square root of <NUMBER>.
(ssget [<MODE>][<PT1><PT2>])
Returns a selection set.
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (7 of 9) [23/03/2005 05:51:08 p.m.]
(sslength <SS>)
Returns the number of entities in selection set <SS>.
(ssname <SS><INDEX>)
Returns the name of the <INDEX>th entity in selection set <SS>.
(ssadd [<ENAME>][<SS>])
Adds entities to selections sets.
(ssdel [<ENAME>][<SS>])
Deletes entities from selections sets.
(ssmemb [<ENAME>][<SS>])
Returns <ENAME> if <ENAME> is a member of selections set <SS>.
(strcase <STRING>[<WHICH>)]
Returns <STRING> as upper case if <WHICH> is nill.
If <WHICH> is not nill the returned string will be all lower case.
(strcat <STRING1><STRING2>..)
Concatenates a series of strings.
(strlen <STRING>)
Returns the number of characters in a string.
(subst <NEWITEM><OLDITEM><LIST>)
Substitutes <NEWITEM> for <OLDITEM> in <LIST>.
(substr <STRING><START><LENGTH>)
Returns a substring of <STRING> begining at <START>
of <LENGTH> characters.
(tblnext <NAME> [<rewind>])
Scans symbol table for next entity.
(tblsearch <NAME><SYM>[<setnext>])
Searches entire symbol table for <NAME>.
(terpri)
Prints a new line on the screen.
(textscr)
Flips from graphics screen to text screen.
(trace <FUNCTIONS>...)
Debugging aid that returns the last function name.
(trans <PT><FROM><TO>[<DISP>])
Translates a point <PT> from one coordinate system to another.
(type <ITEM>)
Returns the type of <ITEM>.
(untrace <FUNCTIONS>...)
Clears the trace floag for <FUNCTIONS>.
(ver)
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (8 of 9) [23/03/2005 05:51:08 p.m.]
Returns AutoLISP version number.
(vports)
Returns a list of currently active viewports.
(while <TESTEXPR><EXPR>)
Evaluates <TESTEXPR> and if not nill executes <EXPR>.
(write-char <NUM> [<FILENAME>])
Writes the character represented by the ASCII value of
<NUM> to the screen or to <FILENAME>.
(write-line <STRING> [<FILENAME>])
Writes <STRING> to the screen or to <FILENAME>.
(vmon)
Enables AutoLISP virtual function pager.
(zerop <ITEM>)
Returns T if <ITEM> evaluates to zero.
(*error* <STRING>)
User-definable error function.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Quick Reference Table
http://www.afralisp.com/lispa/lisp11.htm (9 of 9) [23/03/2005 05:51:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD 2000, 2000i & 2002 System Variables
DISCLAIMER: This document is a compilation of information from dozens of sources. For all intents
and purposes, consider all of the enclosed information to be copyrighted by the individual authors.
They retain full copyright protection. This document is presented as is although every effort has been
made to insure accuracy.
Compiled from various sources by :
R. B. Andy Anderson
2744 Botts Landing Road, #1103
Deland, Florida 32720-8953
andyanderson@bigfoot.com
Download PDF format (380 kb) G
Download Word format (56 kb) G

AutoCAD System Variables


http://www.afralisp.com/lisp/acadvar.htm (1 of 2) [23/03/2005 05:51:09 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD System Variables
http://www.afralisp.com/lisp/acadvar.htm (2 of 2) [23/03/2005 05:51:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Environment Variables Listing.
Compiled and kindly donated by Stig Madsen.
Remember that environment variables are dependent on .. well, the environment, so each may or may
not apply to a certain setup.
Some are almost described, some are definitely not. The first are OS dependent, the rest are AutoCAD
dependent.
System related
(getenv "Path") ;string System search paths
(getenv "COMSPEC") ;string Cmd.exe path
(getenv "UserName");string User logon name
(getenv "Temp") ;string Temp path
(getenv "TMP") ;string Temp path
(getenv "ComputerName");string Computer name
(getenv "Windir") ;string Windows path
(getenv "OS") ;string Operating system
(getenv "UserProfile");string Current user profile path
(getenv "Pathext") ;string Exec extensions
(getenv "SystemDrive");string System drive
(getenv "SystemRoot");string System root path
(getenv "MaxArray");integer
General
(getenv "ACAD") ;string Support search paths
(getenv "ANSIHatch");string Pattern file for ANSI setup 1)
(getenv "ANSILinetype");string Linetype file for ANSI setup 1)
(getenv "ISOHatch");string Pattern file for ISO setup 1)
(getenv "ISOLinetype");string Linetype file for ISO setup 1)
(getenv "StartUpType");string Current default for StartUp dialog
(getenv "acet-MenuLoad");string Loading of Express Tools menu
(getenv "Measureinit");string MEASUREINIT
(getenv "InsertUnitsDefSource");integer INSUNITSDEFSOURCE
(getenv "InsertUnitsDefTarget");integer INSUNITSDEFTARGET
(getenv "acet-Enable");string
(getenv "LastTemplate");string Last DWT used
Environment Variables Listing
http://www.afralisp.com/lisp/enviro.htm (1 of 5) [23/03/2005 05:51:15 p.m.]
(getenv "AcetRText:type");string Current default for RTEXT "Diesel"
(getenv "Pickstyle");integer
(getenv "Coords") ;integer
(getenv "ShowProxyDialog");integer
(getenv "Osmode") ;integer
(getenv "EdgeMode");integer
(getenv "PAPERUPDATE");integer
(getenv "ACADPLCMD");string Plotter command string
(getenv "ImageHighlight");integer
(getenv "Attdia") ;integer
(getenv "Attreq") ;integer
(getenv "Delobj") ;integer
(getenv "Dragmode");integer
(getenv "UseMRUConfig");integer
(getenv "PLSPOOLALERT");integer
(getenv "PLOTLEGACY");integer
(getenv "PSTYLEPOLICY");integer
(getenv "OLEQUALITY");integer
(getenv "Anyport") ;integer
(getenv "Validation Policy");integer
(getenv "Validation Strategy");integer
(getenv "CommandDialogs");integer CMDDIA
(getenv "TempDirectory");string Temp dir
(getenv "PlotSpoolerDirectory");string Spooler dir
(getenv "DefaultLoginName");string Default login
(getenv "MenuFile");string Default menu path
(getenv "NetLocation");string Default URL
(getenv "ACADDRV") ;string Driver path
(getenv "ACADHELP");string Help path
(getenv "PrinterConfigDir");string Plotter path
(getenv "PrinterStyleSheetDir");string Plot styles path
(getenv "PrinterDescDir");string Plotter driver path
(getenv "NewStyleSheet");string Default .stb/.ctb file
(getenv "DefaultFormatForSave");integer Default saveas
(getenv "DefaultConfig");string Default pc3
(getenv "LastModifiedConfig");string Last pc3
Environment Variables Listing
http://www.afralisp.com/lisp/enviro.htm (2 of 5) [23/03/2005 05:51:15 p.m.]
(getenv "MRUConfig");string pc3?
(getenv "ACADLOGFILE");string Logfile
(getenv "MaxDwg") ;integer
(getenv "AVEMAPS") ;string Texture files path
(getenv "TemplatePath");string Templates path
(getenv "DatabaseWorkSpacePath");string Data Links path
(getenv "DefaultPlotStyle");string e.g. "ByLayer"
(getenv "DefaultLayerZeroPlotStyle");string e.g."Normal"
(getenv "LineWeightUnits");integer
(getenv "LWDEFAULT");integer Default lineweight
(getenv "CustomColors");integer
(getenv "Blipmode");integer
(getenv "ToolTips");string
1) used by MEASUREINIT and MEASUREMENT sysvars
Editor Configuration
(getenv "SDF_AttributeExtractTemplateFile");string ??
(getenv "AutoSnapPolarAng");string POLARANG
(getenv "AutoSnapPolarDistance");string POLARDIST
(getenv "AutoSnapPolarAddAng");string POLARADDANG
(getenv "AutoSnapControl");integer AUTOSNAP
(getenv "AutoSnapTrackPath");integer TRACKPATH
(getenv "PickBox") ;integer PICKBOX
(getenv "AutoSnapSize");integer
(getenv "PickFirst");integer PICKFIRST
(getenv "PickAuto");integer PICKAUTO
(getenv "MenuOptionFlags");integer MENUCTL
(getenv "FontMappingFile");string
(getenv "LogFilePath");string
(getenv "PSOUT_PrologFileName");string
(getenv "MainDictionary");string
(getenv "CustomDictionary");string
(getenv "MTextEditor");string
(getenv "XrefLoadPath");string
(getenv "SaveFilePath");string
(getenv "AcadLspAsDoc");string
Environment Variables Listing
http://www.afralisp.com/lisp/enviro.htm (3 of 5) [23/03/2005 05:51:15 p.m.]
Drawing Window
(getenv "Background");integer Background color
(getenv "Layout background");integer PS Background color
(getenv "XhairPickboxEtc");integer Crosshair color
(getenv "LayoutXhairPickboxEtc");integer PS Crosshair color
(getenv "Autotracking vector");integer Autotracking vector color
(getenv "MonoVectors");integer
(getenv "FontFace");string Screen Menu
(getenv "FontHeight");integer
(getenv "FontWeight");integer
(getenv "FontItalic");integer
(getenv "FontPitchAndFamily");integer
(getenv "CursorSize");integer
(getenv "HideWarningDialogs");integer:00000008 <- hit
(getenv "SDIMode") ;integer:00000000 <- hit
Command Line Windows
(getenv "CmdLine.ForeColor");integer
(getenv "CmdLine.BackColor");integer
(getenv "TextWindow.ForeColor");integert
(getenv "TextWindow.BackColor");integer
(getenv "CmdLine.FontFace");string
(getenv "CmdLine.FontHeight");integer
(getenv "CmdLine.FontWeight");integer
(getenv "CmdLine.FontItalic");integer
(getenv "CmdLine.FontPitchAndFamily");integer
(getenv "TextWindow.FontFace");string
(getenv "TextWindow.FontHeight");integer
(getenv "TextWindow.FontWeight");integer
(getenv "TextWindow.FontItalic");integer
(getenv "TextWindow.FontPitchAndFamily");integer

Environment Variables Listing


http://www.afralisp.com/lisp/enviro.htm (4 of 5) [23/03/2005 05:51:15 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Environment Variables Listing
http://www.afralisp.com/lisp/enviro.htm (5 of 5) [23/03/2005 05:51:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Migrating 2000's Express Tools To 2002
If you are upgrading from AutoCAD 2000 to AutoCAD 2002 and also have Express Tools installed, you
should choose to install without uninstalling the older software version first. This option will ensure that
Express Tools migrate into AutoCAD 2002 without difficulty.
Users who choose to completely uninstall AutoCAD 2000 prior to installing AutoCAD 2002, will need to
first backup the Express Tools library as the library is not included with AutoCAD 2002.
Step by Step Guide
1 Prior to uninstalling AutoCAD 2000, please make a backup copy of the following Express Tools-related
files found in the following directories:
Express\*.* G
Support\acettest.fas G
Help\acetmain.hlp G
Help\acetmain.cnt G
Help\acetfaq.hlp G
2 Install AutoCAD 2002.
3 Restart your PC.
3 Create a subdirectory called Express under the directory you installed AutoCAD 2002. For example if
you installed AutoCAD on the C:\ drive in the directory C:\Program Files\AutoCAD 2002, create the
directory C:\Program Files\AutoCAD 2002\Express.
4 Copy all of the Express Tools files from Express\*.* backed up in Step 1 into this new directory you
created in Step 3.
5 Copy acettest.fas to the AutoCAD 2002 Support Files subdirectory. Following the example above, if
you have installed AutoCAD on the C:\ drive in the C:\Program Files\AutoCAD 2002 directory, the
Support files directory would be C:\Program Files\AutoCAD 2002\Support.
6 Copy acetmain.hlp, acetmain.cnt, acetfaq.hlp to the AutoCAD 2002 Help subdirectory. Again, following
the example directories above, the help directory would be C:\Program Files\AutoCAD 2002\Help.
7 At the command line, enter the EXPRESSMENU command by typing EXPRESSMENU at the command
line.
The Express Tools menu will now load automatically in AutoCAD 2002 and

Migrating 2000'sExpress Tools to 2002


http://www.afralisp.com/lisp/migrating_2000.htm (1 of 2) [23/03/2005 05:51:15 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Migrating 2000'sExpress Tools to 2002
http://www.afralisp.com/lisp/migrating_2000.htm (2 of 2) [23/03/2005 05:51:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Enhanced Express Tools 2002 Menu
In AutoCAD 2002, Express Tools are not part of
the standard AutoCAD installation but can be
purchased as a plug in from AutoDesk.
Nevertheless, for some reason certain of the
Express Tools functions are only accessible
through the command line and are not part of the
Express Tools pull down menu.
To rectify this, I have modified the AutoCAD
Express Tools Menu to include the Command
Line functions.
Please note that this modification does not effect the
functionality of the Express Tools default menu. It
only adds to it.
Before you do anything though, you need to
download the Enhanced Express Tools 2002
Menu by clicking here.
Now, the installation of the Enhanced Express
Tools 2002 menu is a simple matter of replacing
the default Express Tools menu - acetmain.mnu -
with the modified menu file contained in the
download zip file.
Instructions :
Unzip the acetmain.mnu file contained in the zip file into the AutoCAD Express directory
containing the default Express Tools menu. This can normally be found within a directory
path that looks something like this :
C:/Program Files/Autocad 2002/Express
If you open AutoCAD and look under "Tools" - "Options" - "Files" - "Support File Search
Path", you will also find the Express directory listed there :
Enhanced Express Tools 2002 Menu
http://www.afralisp.com/lisp/express2002.htm (1 of 2) [23/03/2005 05:51:18 p.m.]
Note!!
Unzipping to this folder, will overwrite the default menu
file contained therein, so you may want to make a copy
of the existing menu file before replacing it.
As we now want to force the Express Tools menu to
recompile, you now need to delete the following two
files from the same directory as the menu file :
acetmain.mns and
acetmain.mnc
Now restart AutoCAD.
The Express Tools Menu will recompile and you will
find that all the Command Line functions have been
added to the Express Tools pull down menu.
Hint of the Day!!
Express Tools 2002 can be downloaded from here :
http://www.contractcaddgroup.com/download/ExpressBonusTools.zip

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Enhanced Express Tools 2002 Menu
http://www.afralisp.com/lisp/express2002.htm (2 of 2) [23/03/2005 05:51:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Enhanced Express Tools 2004 Menu
In AutoCAD 2004, Express Tools are again part of
the standard AutoCAD installation.
For some reason though, certain of the Express
Tools functions are only accessible through the
command line and are not part of the Express
Tools pull down menu.
To rectify this, I have modified the AutoCAD
Express Tools Menu to include the Command Line
functions.
Please note that this modification does not effect the
functionality of the Express Tools default menu. It only
adds to it.
Before you do anything though, you need to
download the Enhanced Express Tools 2004 Menu
by clicking here.
Now, the installation of the Enhanced Express
Tools 2004 menu is a simple matter of replacing
the default Express Tools menu - acetmain.mnu -
with the modified menu file contained in the
download zip file.
Instructions :
Unzip the acetmain.mnu file contained in the zip
file into the AutoCAD Support directory containing
the default Express Tools menu. This can
normally be found within a directory path that
looks something like this :
c:/documents and settings/username/application data/autodesk/autocad 2004/R16.0/enu/support/
The username folder will, of course, change to suit your set up.
If you open AutoCAD and look under "Tools" - "Options" - "Files" - "Support File Search
Path", you will also find the AutoCAD support directory listed there :
Note!!
Enhanced Express Tools 2004 Menu
http://www.afralisp.com/lisp/express.htm (1 of 2) [23/03/2005 05:51:22 p.m.]
Unzipping to this folder, will overwrite the default menu file contained therein, so you may want
to make a copy of the existing menu file before replacing it.
As we now want to force the Express Tools menu to recompile, you now need to delete
the following two files from the same directory as the menu file :
acetmain.mns and
acetmain.mnc
Now restart AutoCAD.
The Express Tools Menu will recompile and you will find that all the Command Line
functions have been added to the Express Tools pull down menu.
Hint of the Day!!
Express Tools 2002 can be downloaded from here :
http://www.contractcaddgroup.com/download/ExpressBonusTools.zip

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Enhanced Express Tools 2004 Menu
http://www.afralisp.com/lisp/express.htm (2 of 2) [23/03/2005 05:51:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Default Drawing Folder
To change the default drawing folder :
Set the REMEMBERFOLDERS system variable to 0. (see below.)

On the Windows desktop, right-click the AutoCAD icon.


Then choose Properties.
Choose the Shortcut tab.

In the Start In box, enter the path of the folder that should be the default when you open or save drawing
files.

Choose OK.
REMEMBERFOLDERS
Type: Integer
Saved in: Registry
Initial value: 1
Controls the default path for the Look In or Save In option in standard file selection dialog boxes.
Default Drawing Folder
http://www.afralisp.com/lisp/shortcut.htm (1 of 2) [23/03/2005 05:51:28 p.m.]
0 This setting restores the legacy behavior of AutoCAD 2000 and previous releases. When you
start AutoCAD by double-clicking an AutoCAD icon, if a Start In path is specified for the icon, that
path is used as the default for all standard file selection dialog boxes.
G
1 The last used paths in each particular standard file selection dialog box are remembered across
and within sessions. The Start In folder specified for the AutoCAD icon is not used.
G

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Default Drawing Folder
http://www.afralisp.com/lisp/shortcut.htm (2 of 2) [23/03/2005 05:51:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Visual Lisp and Menu's.
This tutorial was very kindly written by Stig Madsen. and is published, here on AfraLisp,
with permission.
Before starting on this tutorial, I presume that you are familiar with AutoCAD menu's and
that you have a bit of experience in modifying menu's or creating your own partial
menu's. It will also make things a lot easier for you if you have a basic understanding of
AutoCAD's macro language.
If not, and you don't understand a word that I am talking about, I suggest you pop along
to this tutorial, Creating Menu's, which should explain the basics to you.
Note : You can find the VBA version of this tutorial by clicking here.
O.K. enough chirping from me, over to Stig....
This code will do the following:
Create an empty menu file, vbamenu.mns, if it doesn't already exist
Create a new menugroup called "VbaMenu" if it doesn't already exist
Create a new pulldown menu in the menugroup "VbaMenu"
Populate the pulldown menu with items of our own choice
Load and install the menugroup into AutoCAD
Save the menufile as "VbaMenu.mns" and compile it to "VbaMenu.mnc"
Following code has a nested DEFUN in it. This technique is used to avoid
passing around variables to different routines. Everything in the nested
subroutine CreateMenu gets executed if the pulldown menu we are
looking for doesn't exist. Of course, it could be placed within a lengthy PROGN statement at the end
of the test, but this way the code does a much more obvious branching.
Notice that our new menufile isn't actually loaded before we make sure that it isn't already loaded.
Because AutoCAD deals with standard Windows issues when setting up menus, strange things can
happen if we force a multiple load of the same menu.
(defun C:VBATOOLBARMENU (/ fn acadobj thisdoc menus flag currMenuGroup newMenu
newMenuItem openMacro
)
;; CreateMenu is a nested DEFUN that is executed if our "VbaMenu"
;; pulldown menu doesn't exist. A test for the presence of this
;; pulldown menu is done in the main code
(defun createMenu ()
;; Add a new popUpMenu to currMenuGroup, i.e. to "VbaMenu"
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (1 of 8) [23/03/2005 05:51:32 p.m.]
(setq newMenu (vla-add (vla-get-menus currMenuGroup) "V&BA Menu"))
;;------------------------------------------------------------------
;; create the first pulldown item, vbaload
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaload" (chr 32)))
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"VBA &Load"
openMacro
)
)
(vla-put-helpString newMenuItem "Load a VBA Application")
;;------------------------------------------------------------------
;; create the second pulldown item, vbaide
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaide" (chr 32)))
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"VBA &Editor"
openMacro
)
)
(vla-put-helpString newMenuItem "Switch to the VBA Editor")
;;------------------------------------------------------------------
;; create the third pulldown item, vbarun
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbarun" (chr 32)))
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"VBA &Macro"
openMacro
)
)
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (2 of 8) [23/03/2005 05:51:32 p.m.]
(vla-put-helpString newMenuItem "Run a VBA Macro")
;;------------------------------------------------------------------
;; create the fourth pulldown item, vbaman
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaman" (chr 32)))
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"&VBA Manager"
openMacro
)
)
(vla-put-helpString newMenuItem "Display the VBA Manager")
;;------------------------------------------------------------------
;; insert a separator after the fourth menu item
(vla-AddSeparator newMenu 5)
;;------------------------------------------------------------------
;; create a simple menu macro
(setq
openMacro (strcat (chr 3) (chr 3) (chr 95) "zoom" (chr 32) "w" (chr 32))
)
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"&Zoom"
openMacro
)
)
(vla-put-helpString newMenuItem "Zoom Window")
;;------------------------------------------------------------------
;; create a menu item that loads and runs an AutoLISP routine
(setq openMacro (strcat (chr 3)
(chr 3)
(chr 95)
"(if (not c:ddvpoint) (load \"ddvpoint\")"
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (3 of 8) [23/03/2005 05:51:32 p.m.]
(chr 32)
"ddvpoint"
)
)
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"View &Point"
openMacro
)
)
(vla-put-helpString newMenuItem "View Point")
;;------------------------------------------------------------------
;; create a menu item that calls an Image menu
(setq openMacro (strcat (chr 3)
(chr 3)
(chr 95)
"$I=image_3dobjects $I=*"
)
)
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"&3D Objects"
openMacro
)
)
(vla-put-helpString newMenuItem "3D objects")
;;------------------------------------------------------------------
;; create a menu item with a hyperlink
(setq openMacro (strcat (chr 3)
(chr 3)
(chr 95)
"browser"
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (4 of 8) [23/03/2005 05:51:32 p.m.]
(chr 32)
"www.afralisp.com"
(chr 32)
)
)
(setq newMenuItem
(vla-addMenuItem
newMenu
(1+ (vla-get-count newMenu))
"&AfraLisp.com"
openMacro
)
)
(vla-put-helpString newMenuItem "Go visit this awesome place, or else!")
;;------------------------------------------------------------------
;; insert the pulldown menu into the menu bar, third from the end
(vla-insertInMenuBar
newMenu
(- (vla-get-count (vla-get-menuBar acadobj)) 2)
)
;; re-compile the VBAMENU menu - VBAMENU.MNC
(vla-save currMenuGroup acMenuFileCompiled)
;; save it as a MNS file
(vla-save currMenuGroup acMenuFileSource)
)

;; First, check to see if our menu file "VbaMenu.mns" already


;; exists. If it doesn't then simply make an empty file that
;; we can later write our menu definition to
(setq flag nil)
(if (not (findfile "VbaMenu.mns"))
(progn
(setq fn (open "VbaMenu.mns" "w"))
(close fn)
)
)
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (5 of 8) [23/03/2005 05:51:32 p.m.]
;; Get hold of the application object - we will use it to
;; retrieve the menuGroups collection, which is a child object
;; of the application
(setq acadobj (vlax-get-acad-object))
;; Get the active document - also a child of the application
(setq thisdoc (vla-get-activeDocument acadobj))
;; Get all menugroups loaded into AutoCAD
(setq menus (vla-get-menuGroups acadobj))
;; Now we could use VLA-ITEM to test if "VbaMenu" exists among
;; all loaded menugroups with (vla-item menus "VbaMenu").
;; Instead, as a friendly service, we want all loaded menus to
;; be printed to the screen and at the same time we might as well
;; use it to set a flag if "VbaMenu" is among the loaded menus
(princ "\nLoaded menus: ")
(vlax-for n menus
(if (= (vla-get-name n) "VbaMenu")
(setq flag T)
)
(terpri)
(princ (vla-get-name n))
)
;; If VbaMenu wasn't among the loaded menus then load it
(if (null flag)
(vla-load menus "VbaMenu.mns")
)
(setq currMenuGroup (vla-item menus "VbaMenu"))
;; If no popUpMenus exist in VbaMenu then go create one -
;; otherwise exit with grace. In this example we merely check
;; if the number of popup menus in "VbaMenu" is greater than 0.
;; A safer way to test for its presence would be to set up a
;; test for its name, "V&BA Menu":
;; (vla-item (vla-get-menus currMenuGroup) "V&BA Menu")
(if (<= (vla-get-count (vla-get-menus currMenuGroup)) 0)
(createMenu)
(princ "\nThe menu is already loaded")
)
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (6 of 8) [23/03/2005 05:51:32 p.m.]
(princ)
)
Now navigate your way to VbaMenu.mns and open it. You should see something like this :
//
// AutoCAD menu file - D:\drawings\VbaMenu.mns
//
***MENUGROUP=VbaMenu
***POP2
ID_mnuVBA Menu [V&BA Menu]
ID_VBA Load [VBA &Load]^C^C_vbaload
ID_VBA Editor [VBA &Editor]^C^C_vbaide
ID_VBA Macro [VBA &Macro]^C^C_vbarun
ID_VBA Manager [&VBA Manager]^C^C_vbaman
[--]
ID_Zoom [&Zoom]^C^C_zoom w
ID_View Point [View &Point]^C^C_(if (not c:ddvpoint) (load "ddvpoint") ddvpoint
ID_3D Objects [&3D Objects]^C^C_$I=image_3dobjects $I=*
ID_AfraLisp.com [&AfraLisp.com]^C^C_browser www.afralisp.com
***TOOLBARS
***HELPSTRINGS
ID_VIEW POINT [View Point]
ID_AFRALISP.COM [Go visit this awesome place, or else!]
ID_VBA MANAGER [Display the VBA Manager]
ID_VBA LOAD [Load a VBA Application]
ID_ZOOM [Zoom Window]
ID_VBA MACRO [Run a VBA Macro]
ID_3D OBJECTS [3D objects]
ID_VBA EDITOR [Switch to the VBA Editor]
//
// End of AutoCAD menu file - D:\drawings\Vbamenu.mns
//
You should also find VbaMenu.mnc and VbaMenu.mnr in the same folder. Even though the
VbaMenu.mns didn't exist when we started, Visual Lisp has created it as well as all the coding
necessary and compiled the other menu support files required for the menu to run.
On the next page, we'll have a look at creating Toolbar menu's.

Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (7 of 8) [23/03/2005 05:51:32 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Menu's.
http://www.afralisp.com/vl/vlmenu1.htm (8 of 8) [23/03/2005 05:51:32 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Visual Lisp and Menu's.
Using Stigs coding as a template, I've written the follow routine that creates a Toolbar menu. Please
ensure that the toolbar bitmap files are within your AutoCAD support path before loading and running
this application.
Oh, by the way, you can find the VBA version of this application here.
(defun C:VBATOOLBARMENU (/ fn acadobj thisdoc menus flag currMenuGroup
newToolbar newToolbarButton openMacro
SmallBitmapName LargeBitmapName)
(vl-load-com)
;;; CreateToolbar is called if the Toolbar in question doesn't exist
(defun createToolbar ()
(setq newToolbar (vla-add (vla-get-toolbars currMenuGroup) "VBA Menu"))
;;------------------------------------------------------------------
;; create the first Toolbar Button, VbaLoad
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaload" (chr 32)))
(setq newToolbarButton (vla-addToolbarButton
newToolbar
(1+ (vla-get-count newToolbar))
"VBA Load" "VBA Load" openMacro
)
)
(setq SmallBitmapName "VbaLoad.bmp")
(setq LargeBitmapName "VbaLoad.bmp")
(vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
(vla-put-helpString newToolbarButton "Load a VBA Application")
;;------------------------------------------------------------------
;; create the second Toolbar Button, Vbaide
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaide" (chr 32)))
(setq newToolbarButton (vla-addToolbarButton
newToolbar
(1+ (vla-get-count newToolbar))
"VBA Editor" "VBA Editor" openMacro
)
)
(setq SmallBitmapName "Vbaide.bmp")
(setq LargeBitmapName "Vbaide.bmp")
(vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
(vla-put-helpString newToolbarButton "Switch to the VBA Editor")
;;------------------------------------------------------------------
;; create the third Toolbar Button, Vbarun
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbarun" (chr 32)))
(setq newToolbarButton (vla-addToolbarButton
newToolbar
(1+ (vla-get-count newToolbar))
Visual Lisp and Menu's II
http://www.afralisp.com/vl/vlmenu2.htm (1 of 3) [23/03/2005 05:51:33 p.m.]
"VBA Macro" "VBA Macro" openMacro
)
)
(setq SmallBitmapName "Vbamacro.bmp")
(setq LargeBitmapName "Vbamacro.bmp")
(vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
(vla-put-helpString newToolbarButton "Run a VBA Macro")
;;------------------------------------------------------------------
;; create the fourth Toolbar Button, Vbaman
(setq openMacro (strcat (chr 3) (chr 3) (chr 95) "vbaman" (chr 32)))
(setq newToolbarButton (vla-addToolbarButton
newToolbar
(1+ (vla-get-count newToolbar))
"VBA Manager" "VBA Manager" openMacro
)
)
(setq SmallBitmapName "Vbaman.bmp")
(setq LargeBitmapName "Vbaman.bmp")
(vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
(vla-put-helpString newToolbarButton "Display the VBA Manager")
;;------------------------------------------------------------------
;; re-compile the VBATOOLBARMENU menu - VBATOOLBARMENU.MNC
(vla-save currMenuGroup acMenuFileCompiled)
;; save it as a MNS file
(vla-save currMenuGroup acMenuFileSource)
)
(setq flag nil)
(if (not (findfile "VbaToolbarMenu.mns"))
(progn
(setq fn (open "VbaToolbarMenu.mns" "w"))
(close fn)
)
)
;; get hold of the application object
;; we'll use it to reference the menuGroups collection
(setq acadobj (vlax-get-acad-object))
;; .. and get the active document
(setq thisdoc (vla-get-activeDocument acadobj))
;; get all menu groups loaded into AutoCAD
(setq menus (vla-get-menuGroups acadobj))
(princ "\nLoaded menus: ")
(vlax-for n menus
(if (= (vla-get-name n) "VbaToolbarMenu")
(setq flag T)
)
(terpri)
(princ (vla-get-name n))
)
;; if VbaToolbarMenu wasn't among the loaded menus then load it
(if (null flag)
(vla-load menus "VbaToolbarMenu.mns")
)
(setq currMenuGroup (vla-item menus "VbaToolbarMenu"))
;; if no Toolbars exist in VbaToolbarMenu then go create one
;; otherwise exit with grace
(if (<= (vla-get-count (vla-get-menus currMenuGroup)) 0)
(createToolbar)
Visual Lisp and Menu's II
http://www.afralisp.com/vl/vlmenu2.htm (2 of 3) [23/03/2005 05:51:33 p.m.]
(princ "\nThe Vba Toolbar Menu is already loaded")
)
(princ)
)
(princ)

Your "VbaToolbarMenu.mns", should look like this :
//
// AutoCAD menu file - D:\drawings\VbaToolbarMenu.mns
//
***MENUGROUP=VbaToolbarMenu
***TOOLBARS
**VBA_MENU
ID_VBA_Menu_0 [_Toolbar("VBA Menu", _Floating, _Show, 168, 152, 1)]
ID_VBA_Load_0 [_Button("VBA Load", "VbaLoad.bmp", "VbaLoad.bmp")]^C^C_vbaload
ID_VBA_Editor_0 [_Button("VBA Editor", "Vbaide.bmp", "Vbaide.bmp")]^C^C_vbaide
ID_VBA_Macro_0 [_Button("VBA Macro", "Vbamacro.bmp", "Vbamacro.bmp")]^C^C_vbarun
ID_VBA_Manager_0 [_Button("VBA Manager", "Vbaman.bmp", "Vbaman.bmp")]^C^C_vbaman
***HELPSTRINGS
ID_VBA_MANAGER_0 [Disply the VBA Manager]
ID_VBA_LOAD_0 [Load a VBA Application]
ID_VBA_MACRO_0 [Run a VBA Macro]
ID_VBA_EDITOR_0 [Switch to the VBA Editor]
//
// End of AutoCAD menu file - D:\drawings\VbaToolbarMenu.mns
//
Your Toolbar should look like this :
If you would like the source coding for both of these menu's, smile nicely at the screen and click here.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Menu's II
http://www.afralisp.com/vl/vlmenu2.htm (3 of 3) [23/03/2005 05:51:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom HATCH patterns and Menu access
Table of Contents
Overview G
AutoCAD Release 12
Option 1: Custom hatch image tile menu and the HATCH command H
Option 2: Add patterns to existing acad.pat and work without icons H
G
AutoCAD Release 13
Option 1: Custom hatch image tile menu and the HATCH command H
Option 2: Add patterns to existing acad.pat and work without icons H
G
AutoCAD Release 14
Option 1: Custom hatch image tile menu and the HATCH command H
Option 2: Add patterns to existing acad.pat and work without icons H
G
Overview
The ACAD slide-library is pre-compiled when shipped, which means that in order to add a custom pattern to it, the library has to be
recompiled. This option is not practical for most users. Users who define custom hatch patterns may encounter difficulties when trying to
access their patterns through the normal command sequence or through dialog boxes. This document discusses two other options for
adding and accessing custom hatch patterns in AutoCAD Releases 12, 13, and 14.
AutoCAD Release 12
This section explains two options for adding and selecting custom hatch patterns in AutoCAD R12.
Option 1: Custom hatch image tile menu and the HATCH command
To create a custom hatch pattern in R12, refer to the User's Guide, Chapter 18: "Linetypes and Hatch Patterns" in the section Creating
Hatch Patterns. You can make the following changes to the menu (.mnu) file:
1. Add the custom section immediately below the Hatch command in the Draw pop menu: [--]
[/HHatch...]^C^C_bhatch
[/MMyHatch...]^C^C$I=icon_myhatch $I=*
[--]
2. In the ***icon section of the same .mnu file, add the image tile menu:
***icon
**icon_myhatch
[MyHatch]
[cmj(myzag,MyZag)]^c^c_hatch myzag
If you have more than one slide image and want them to appear, list them at the end of this section.
3. Create a pattern (like the one shown below) and save it in a file named myzag.pat. Save the file in the \SUPPORT subdirectory.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
90, .15,0, .15,.15, .15,-.15
4. Create a 3 x 2 unit polygon and boundary hatch it using the custom pattern by entering the name of your pattern in the field next
to the Pattern button in the dialog box.
5. Do a Zoom Extents and make a slide of this hatched polygon using the MSLIDE command. Repeat steps 4 and 5 for each pattern
and slide.
6. Make a slide library with all of the slides in it using the following commands: (This example shows a slide and slide library in the
\SUPPORT subdirectory.)
dir *.sld/b > cmj.txt
slidelib cmj < cmj.txt
7. Use the MENU command to load and compile the new .mnu file. Select the MyHatch option from the Draw pull-down menu. This
should bring up an image tile menu with slides in it. Selection can be made with either the image or the name in the list to the left
of the images.
This option uses the HATCH command and the selected pattern.
Option 2: Add patterns to existing acad.patand work without icons
1. Add your custom hatch pattern definitions (like the one below) to the end of the existing acad.pat file.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
Custom HATCH patterns and Menu access
http://www.afralisp.com/lispa/hatch.htm (1 of 4) [23/03/2005 05:51:35 p.m.]
90, .15,0, .15,.15, .15,-.15
2. Save the acad.pat file after adding your custom hatch pattern definitions.
You will get a text reference (with a blank box) in the image tile menu so you do not have to remember the hatch pattern names -
only what they look like.
This option works with the BHATCH command.
AutoCAD Release 13
This section explains two options for adding and selecting custom hatch patterns in AutoCAD R13.
Note: The menu syntax used in R13 is slightly different than it is in R12.
Option 1: Custom hatch image tile menu and the HATCH command
To create a custom hatch pattern in R13, refer to the Customization Guide, chapter 2: "Linetypes and Hatch Patterns" in the
section Creating Hatch Patterns. Make the following changes in the menu file (mnu):
1. Add the custom section below the Hatch title in the Draw pop menu in acadfull.mnu. Notice the -> and <- marks; these
indicate a nested menu. The new listing must follow the last line of the nested menu in order to appear after the Hatch
option. By inserting one line earlier in the code, MyHatch would appear in the sub-menu of the Hatch selection between
Bhatch and Psfill.
[->&Hatch]
ID_Bhatch [&Hatch...]^C^C_bhatch
ID_Psfill [<-PostScript &Fill]^C^C_psfill
[&MyHatch...]^C^C$I=image_myhatch $I=*
[--]
2. In the *** image section of the same .mnu file, add the image tile menu. This section is now labeled "image" instead of
"icon" (as it was in R12).
***image
**image_myhatch
[MyHatch]
[cmj(myzag,MyZag)]^C^C_hatch myzag
3. Create a pattern (like the one show below) and save it in a file named myzag.pat. in the \SUPPORT subdirectory. The
pattern syntax is identical to R12 and .pat files used in R12 also work in R13.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
90, .15,0, .15,.15, .15,-.15
4. Create a 3 x 2 unit polygon and boundary hatch it with the custom pattern by entering the name of the custom pattern in
the field next to the Pattern button (while you are in the Boundary Hatch dialog box).
5. Do a Zoom Extents and make a slide of this hatched polygon using the MSLIDE command. Repeat steps 4 and 5 for
each custom pattern and slide.
6. Make a slide library using the following commands: (This example shows the slide and slide library are placed in the
\SUPPORT subdirectory.) Note that slides and slide libraries created in R12 are still usable in R13.
dir *.sld/b > cmj.txt
slidelib cmj < cmj.txt
7. Load the new menu file (.mnu) using either the MENU or the MENULOAD commands. Select the MyHatch option from
the Draw pull-down menu to display an image tile menu with the slide(s) in it. Selection can be made with either the image
tile or the pattern name in the list to the left.
This option uses the HATCH command and the selected pattern.
Option 2: Add patterns to existing acad.pat and work without icons
1. Add the custom pattern definitions to the end of the existing acad.pat file.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
90, .15,0, .15,.15, .15,-.15
2. Save the acad.pat file after adding your custom hatch pattern definitions.
You will get a text reference within a blank image in the Pattern list in the Boundary Hatch dialog box. As a result, you do not have
to remember the hatch pattern names - only what they look like.
This option works with the BHATCH command.
Custom HATCH patterns and Menu access
http://www.afralisp.com/lispa/hatch.htm (2 of 4) [23/03/2005 05:51:35 p.m.]
AutoCAD Release 14
This section explains two options for adding and selecting custom hatch patterns in AutoCAD R14.
Note: The only change from R13 is the location of the HATCH command in the Draw pop menu definition. Slides
and slide libraries created in R12 or R13 can still be used in R14. The same custom .pat files you used in R12 and
R13 will also work in R14.
Option 1: Custom hatch image tile menu and the HATCH command
To create a custom hatch pattern in R14, refer to the online Customization Guide, chapter 2: "Linetypes and Hatch Patterns" in the
section titled Creating Hatch Patterns. Make the following changes in the menu (mnu) file:
1. Add the custom section immediately below the Hatch title in the Draw pop menu. The same code used in R13 is
functional here; only the surrounding code looks different.
[--]
ID_Bhatch [&Hatch...]^C^C_bhatch
[&MyHatch...]^C^C$I=image_myhatch $I=*
ID_Boundary [&Boundary...]^C^C_boundary
ID_Region [Regio&n]^C^C_region
[--]
2. In the *** image section of the same .mnu file, add the image tile menu. Once again, there is no change from the R13
code used here.
***image
**image_myhatch
[MyHatch]
[cmj(myzag,MyZag)]^C^C_hatch myzag
3. Create a pattern and save it in a file called myzag.pat in the \SUPPORT subdirectory.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
90, .15,0, .15,.15, .15,-.15
4. Create a 3 x 2 unit polygon and boundary hatch it using the custom pattern. (Enter the name of your pattern in the field
next to the Pattern button when you are in the Boundary Hatch dialog box.)
5. Do a Zoom Extents and make a slide of this hatched polygon using the MSLIDE command. Repeat steps 4 and 5 for
each custom pattern and slide.
6. Make a slide library with all the slides in it using the following commands: (This example shows a slide and slide library
in the \SUPPORT subdirectory.)
dir *.sld/b > cmj.txt
slidelib cmj < cmj.txt
7. Load the new .mnu using either the MENU or MENULOAD commands. Select the MyHatch option from the Draw
pull-down menu to display an image tile menu that contains the slide(s). You can select the slides by either using the
image tile or the pattern name in the list at the left.
This option uses the HATCH command and the selected hatch pattern.
Option 2: Add patterns to existing acad.patand work without icons
1. Add the custom pattern definitions to the end of the existing acad.pat file.
*MYZAG, Staircase effect
0, 0,0, .15,.15, .15,-.15
90, .15,0, .15,.15, .15,-.15
You will get a text reference within a blank image in the Pattern list in the Boundary Hatch dialog box. You do not have to
remember the hatch pattern names - only what they look like.
This option works with the BHATCH command.
Back To Top

Custom HATCH patterns and Menu access


http://www.afralisp.com/lispa/hatch.htm (3 of 4) [23/03/2005 05:51:35 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom HATCH patterns and Menu access
http://www.afralisp.com/lispa/hatch.htm (4 of 4) [23/03/2005 05:51:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Creating Hatch Patterns
You want to what!!! Create a hatch pattern? Crikey, you're brave.
Honestly, though, simple hatch patterns are quite easy to create. It's the complicated ones that take
time, effort, a good understanding of how to create hatches and linetypes, some knowledge of
geometry and quite a bit of imagination.
Before proceeding with this tutorial, I would strongly recommend that you read my tutorial on
creating custom linetypes. Linetypes are used extensively throughout hatch patterns and a good
understanding is a requisite. You can find my tutorial on custom linetypes at :
htpp://www.afralisp.com/lisp/ltype.htm
Let's take a look at a simple hatch pattern first. The same principal applies to even the most
complicated hatch pattern so, as my Mum often says, "Pay attention!!"
A hatch pattern definition is stored in a simple ASCII text file with an extension of PAT. You can
append a hatch pattern to an existing file if you wish, or you can store it in it's own file. If you store
it in it's own file, the file name must match the name of the hatch pattern. We are going to create
our own hatch definition or pattern file.
O.K. Open Notepad and add this line :
*Dashdot, Dashes and dots
This is the name of our hatch pattern followed by a description of the pattern, separated by a
comma. (,)
Now add this on the next line :
0, 0,0, 0,0.5, 0.5,-0.25,0,-0.25,0,-0.25
This line describes a single drawing pass over the hatch pattern. In this example we are only using a
single pass so we will only get one line. Save your file as "Dashdot.pat". If you loaded this hatch
pattern and added it to your drawing, it would look like this :
The syntax of each drawing line is as follows :
Angle, X,Y Origin, Offset-x,Offset-y, Pen Command Pattern
Let's look a bit closer at each field :
0, 0,0, 0,0.5, 0.5,-0.25,0,-0.25,0,-0.25
The first field, Angle, which in our case is "0", determines the angle at which the line is to be
drawn. In our case it will be drawn horizontally. Don't confuse this with the angle of the hatch
pattern which is controlled by the AutoCAD Hatch command. Look at a hatch pattern as a
successive series of lines that are drawn from left to right, then from down to up.
Creating Hatch Patterns
http://www.afralisp.com/lisp/hatch.htm (1 of 3) [23/03/2005 05:51:37 p.m.]
0, 0,0, 0,0.5, 0.5,-0.25,0,-0.25,0,-0.25
The second field is the X,Y Origin. This controls the starting point of the line segment. This is not
an AutoCAD co-ordinate, but rather a relative distance from the current Snap base point of the
drawing. All hatch patterns have a point of origin. Since this point of origin is the same throughout,
you're assured that the patterns will line up.
0, 0,0, 0,0.5, 0.5,-0.25,0,-0.25,0,-0.25
The third field is the X-Offset and Y-offset values. 0 is the X-Offset and 0.5 is the Y-Offset. The
hatch pattern will begin at an arbitrary origin and proceed to draw a group from left to right, then
advance upward in the Y direction.
0,0.5 means that each successive line in the pattern will move to the right 0 units and up by 0.5
units. This results in the 0.5 spacing between the lines. The offset is relative to the initial angle given
in the line, so that angle forms the X axis for the offset.
The Y value Offset is quite easy to understand - it gives you the spacing between the lines. But why
would you want to offset the X value, and what effect does that have? Think of a brick wall. Each
successive line of bricks is offset to the right a little to create a pattern. So, 0.5,1 would space the
bricks upward by 1 unit, and every other line would be offset by 0.5 to the right of the origin,
creating a "stepladder" effect.
0, 0,0, 0,0.5, 0.5,-0.25,0,-0.25,0,-0.25
The fourth and final group is the linetype definition or the dash dot pattern. In words, this pattern
is saying:
"Draw a line 0.5 units long, lift the pen for 0.25 units, draw a dot, lift the pen for 0.25 units, draw
another dot, lift the pen for 0.25 units, draw a third dot, lift the pen for 0.25 units and then repeat
the process".
The dashdot pattern was drawn using only one definition line, let's try one with two. Open a new
file with Notepad and add this :
*VASTRAP, Vastrap Checkered Plate
0, 0,0.09375, 0.25,0.25, 0.25,-0.25
90, 0.125,0.21875, 0.25,0.25, 0.25,-0.25
Close the file and save it as "Vastrap.pat". This hatch will produce a pattern like this :
Even though I defined the pattern with 0 and 90 degree lines, you can rotate the pattern to get the
desired effect. I made the pattern at 0 and 90 degrees to avoid having to calculate the angles.
(Chicken hey!)
As I said at the beginning, simple hatch patterns are quite easy to create, but the complicated one's?
Well, that's another story.
Would you like a couple of hundred hatch patterns to play around with and analyze? Some simple,
some "very" complicated! You would? Then just place your mouse here and click.

Creating Hatch Patterns


http://www.afralisp.com/lisp/hatch.htm (2 of 3) [23/03/2005 05:51:37 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Creating Hatch Patterns
http://www.afralisp.com/lisp/hatch.htm (3 of 3) [23/03/2005 05:51:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Linetypes
There are two different ways of creating linetypes within AutoCAD. You can write your own
linetype definition file, or you can use AutoCAD's built in function to create it for you. In this
tutorial we'll look at both methods. Let's start with the AutoCAD built in function first.
Before we start though, let's have a look at what a linetype is.
A linetype is a series of positive and negative numbers that tell a plotter how long to lower or raise a
pen. Positive numbers lower the pen, and negative numbers raise it. The normal length of a dash is
.5; a dot is 0.
e.g. 0,-.25 would produce a series of dots. The first 0 produces the dot; the -.25 raises the pen .25 of
a unit. The series then repeats itself.
A dash-dot would be .5,-.25,0,-.25.
A dashed line would be .5,-.25.
Easy hey! Now let's have a look at creating out own custom linetype. Let's say we want a linetype to
be dash, dot, dot, dot.
The format would be .5,-.25,0,-.25,0,-.25,0,-.25. and we'll call the linetype "dashdot3".
Fire up AutoCAD and enter the following at the command line :
Command: -linetype
Current line type: "ByLayer"
Custom Linetypes
http://www.afralisp.com/lisp/ltype.htm (1 of 4) [23/03/2005 05:51:43 p.m.]
Enter an option [?/Create/Load/Set]: c
Enter name of linetype to create: dashdot3
After pressing "Enter", the following dialog will appear :
Enter "Afralisp" as the file name and select "Save".
Creating new file
Descriptive text: _ . . . _ . . . _ . . . _
Enter linetype pattern (on next line):
A,.5, -.25, 0, -.25, 0, -.25, 0, -.25
New linetype definition saved to file.
Enter an option [?/Create/Load/Set]:
Select "Enter" to complete the process.
We could have appended the linetype definition to an existing file, but in this case we've created a
new file.
If you want to change an existing linetype definition, just create a new linetype, giving it the same
name as the old one. AutoCAD will ask you if you want to overwrite the existing linetype; answer
yes. You can then enter the new definition and description.
Note : Complex linetypes cannot be created using the "Linetype" command at the command line.
To load and set your new linetype, enter "Linetype" at the command line. The "Linetype
Manager" dialogue will appear :
Custom Linetypes
http://www.afralisp.com/lisp/ltype.htm (2 of 4) [23/03/2005 05:51:43 p.m.]
Select "Load". The Load dialog will appear :
Select "File" and then "AfraLisp.lin"
Next select "dashdot3" linetype and then "OK"
In the "Linetype Manager" dialogue, select "dashdot3" again and then "Current" followed by
"OK".
Your "dashdot3" linetype should now be loaded and set. Draw a line. It should look like this :
To create your own linetype definition is very simple. First locate your newly created "Afralisp.lin"
file, and open it using Notepad. It should look like this :
;
Custom Linetypes
http://www.afralisp.com/lisp/ltype.htm (3 of 4) [23/03/2005 05:51:43 p.m.]
;AfraLisp Linetype definitions
;Written November 2001
;
*dashdot3,_ . . . _ . . . _ . . . _
A,0.5,-0.25,0,-0.25,0,-0.25,0,-0.25
Yours will not have the first two lines as I added them later. Just precede any comments you wish to
add with ";".
As you can see, your linetype definition consists of 2 lines.
The first line consists of "*" followed by the linetype name followed by the description separated by
a comma ",".
The description is optional and can be a sequence of dots, spaces and dashes or a comment such as
"A Dashed Line followed by 3 Dots". If you omit the description, do not put a comma after the
linetype name. If you include a description, it should be no more than 47 characters long. (Why?
Who knows!!)
The second line starts with the "alignment" field which you specify by entering "A". AutoCAD
only supports one type of alignment field at this time so you will always enter "A".
Next comes a comma "," followed by your linetype definition.
Pretty easy hey. On the next page we'll have a look at complex linetypes.
To Page No II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Linetypes
http://www.afralisp.com/lisp/ltype.htm (4 of 4) [23/03/2005 05:51:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Custom Complex Linetypes
The syntax for complex linetypes is similar to that of simple linetypes in that it is a
comma-delimited list of pattern descriptions. The difference is, is that complex linetypes can
include shape and text objects as pattern descriptors, as well as the normal dash-dot descriptors of
simple linetypes.
In this tutorial we are going to look at creating a complex linetype using a text object as a
descriptor.
The syntax for text object descriptors in a linetype definition is as follows :
["string" , stylename] or
["string" , stylename , transform]
That's great Kenny, but I haven't a clue what this all means!!!
O.K. Don't worry, we'll go through it step by step.
Open up your AfraLisp.lin file that you created earlier and add the following :
;
;AfraLisp Custom Linetypes
;Written November 2001
;
*dashdot3,_ . . . _ . . . _ , , , _
A,0.5,-0.25,0,-0.25,0,-0.25,0,-0.25
;
*AFRALISP,---- AL ---- AL ---- AL ---- AL
A,1.0,-0.25,["AL",STANDARD,S=1,R=0,X=0,Y=-0.25],-1.25
If you loaded and set this linetype, it would look like this :
If we put this into words, we would be saying, "Draw a line 1 unit long, lift the pen for 0.25 of a
unit, then add "AL" as text using "STANDARD" font style, now lift the pen for 1.25 units, and
then repeat the process".
Let's have a wee look at the "AFRALISP" linetype :
*AFRALISP,---- AL ---- AL ---- AL ---- AL
The first line, of course is the linetype name followed by the description.
A,1.0,-0.25,["AL",STANDARD,S=1,R=0,X=0,Y=-0.25],-1.25
The second line contains the linetype definition. Lets, zoom into this.
"A" is the alignment which is defaulted.
"1.0" and "-0.25" are pen commands as is "-1.25" at the end of the definition.
["AL",STANDARD,S=1,R=0,X=0,Y=-0.25] is the one that interests us.
The syntax of these fields are as follows :
string ("AL")
Custom Linetypes II
http://www.afralisp.com/lisp/ltype1.htm (1 of 3) [23/03/2005 05:51:44 p.m.]
The text to be used in the complex linetype.
style (STANDARD)
The name of the text style to be elaborated. The specified text style must be included. If it is
omitted, use the currently defined style.
scale (1)
S=value. The scale of the style is used as a scale factor by which the style's height is multiplied. If
the style's height is 0, the S=value alone is used as the scale.
Because the final height of the text is defined by both the S=value and the height assigned to the text
style, you will achieve more predictable results by setting the text style height to 0. Additionally, it is
recommended that you create separate text styles for text in complex linetypes to avoid conflicts
with other text in your drawing.
rotate (0)
R=value or A=value. R= signifies relative or tangential rotation with respect to the lines
elaboration. A= signifies absolute rotation of the text with respect to the origin; all text has the same
rotation regardless of its relative position to the line. The value can be appended with a d for
degrees (if omitted, degree is the default), r for radians, or g for grads. If rotation is omitted, 0
relative rotation is used.
Rotation is centered between the baseline and the nominal cap heights box.
xoffset (0)
X=value. This field specifies the shift of the text in the X axis of the linetype computed from the end
of the linetype definition vertex. If xoffset is omitted or is 0, the text is elaborated by using the
lower-left corner of the text as the offset. Include this field if you want a continuous line with text.
This value is not scaled by the scale factor that is defined by S=.
yoffset (-0.25)
Y=value. This field specifies the shift of the text in the Y axis of the linetype computed from the end
of the linetype definition vertex. If yoffset is omitted or is 0, the text is elaborated by using the
lower-left corner of the text as the offset. This value is not scaled by the scale factor that is defined
by S=.
Well that's about it for complex linetypes. But before I go, here's a few more custom linetypes that
you can play around and practice with :
;
;
;AfraLisp Custom Linetypes
;Written November 2001
;
;
*dashdot3,_ . . . _ . . . _ , , , _
A,0.5,-0.25,0,-0.25,0,-0.25,0,-0.25
;
*AFRALISP,---- AL ---- AL ---- AL ---- AL
A,1.0,-0.25,["AL",STANDARD,S=1,R=0,X=0,Y=-0.25],-1.25
;
*DIESEL,---- DIESEL ---- DIESEL ---- DIESEL ---- DIESEL ---- DIESEL
A,50,-2,["DIESEL",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-6.5
;
*BEER,---- BEER ---- BEER ---- BEER ---- BEER ---- BEER
A,50,-2,["BEER",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-6.5
;
*DRINKING_WATER,---- DRINKING H20 ---- DRINKING H20 ---- DRINKING H20
Custom Linetypes II
http://www.afralisp.com/lisp/ltype1.htm (2 of 3) [23/03/2005 05:51:44 p.m.]
A,50,-2,["DRINKING H20",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-14
;
*ELECTRICAL,---- ELECT ---- ELECT ---- ELECT ---- ELECT ---- ELECT
A,50,-2,["ELECT",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-5.5
;
*HIGH_TENSION,---- HT ---- HT ---- HT ---- HT ---- HT ---- HT ----
A,50,-2,["HT",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-2
;
*OIL,---- OIL ---- OIL ---- OIL ---- OIL ---- OIL ---- OIL ----
A,50,-2,["OIL",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-3
;
*OPTIC,---- OPTIC ---- OPTIC ---- OPTIC ---- OPTIC ---- OPTIC ----
A,50,-2,["OPTIC",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-5.5
;
*PHONE,---- PHONE ---- PHONE ---- PHONE ---- PHONE ---- PHONE ----
A,50,-2,["PHONE",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-6
;
*PLANT_WATER,---- PLANT H20 ---- PLANT H20 ---- PLANT H20
A,50,-2,["PLANT H20",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-11
;
*SECURITY_FENCE,---- X ---- X ---- X ---- X ---- X ---- X ----
A,50,-2,["X",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-1
;
*SEWER,---- SEWAGE ---- SEWAGE ---- SEWAGE ---- SEWAGE ----
A,50,-2,["SEWAGE",STANDARD,S=1.25,R=0.0,X=-1,Y=-.5],-7
O.K. Now I'll put you all out of your misery!!
Under the Express Tools pull down menu you will find the following :
"Make Linetype" and "Make Shape". (Sorry A2K only).
Now don't say I'm not nice to you!!

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Custom Linetypes II
http://www.afralisp.com/lisp/ltype1.htm (3 of 3) [23/03/2005 05:51:44 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Controlling Complex Linetypes
Since AutoCAD R13, text can be part of the repeating pattern in a line. Lines with repeating
text are called complex linetypes. The definition of linetypes are stored in an ascii text file
with a .LIN file extension. The acad.lin file contains default linetypes and this file can be
edited to include complex linetypes. Linetype definitions can also be defined in a separate
.LIN file with a unique name, such as ltyeshp.lin in the R13\Com\Support directory. You
can use a text editor such as Windows Notepad or DOS Edit to create and modify
complex linetypes.
The repeating segments for complex lines are defined in the same manner as the simple
linetype. In a complex linetype, brackets are used to enclose the description of text to be
repeated along the line. The position and size of the text in relation to the repeating line
segments is determined with 4 controlling parameters named "transforms".
A transform will scale, rotate and offset in the X or Y direction the text in the complex
linetype. The following example will add text that repeats along the line when included in a
linetype definition.
["MC",NEWSTYLE,S=1,R=90,X= -0.25,Y= -0.5]
The key to creating a successful complex linetype definition is understanding how to
center the text in the blank elements of the line. Each element defining the repeating text
is separated by commas. The characters contained in quotes are the characters that will
be displayed along the line. The next element is the text style used for the repeating text.
S=? controls the size, R=? controls the rotation and X=? and Y=? adjust the placement of
the repeating text in relation to the rest of the line.
How to set the height of the repeating text
There are four possible combinations of settings that can affect the height of the text in a
complex linetype. When a text style is defined in AutoCAD it can either be defined with a
height of zero or a particular number. If the style used in the complex linetype has a
height of zero, then the number in the S=? transform will define the repeating text height
when the line is placed in the drawing.
If the text style used in the complex linetype has a height other than zero, then the
number in the S=? transform will be the multiplier for the text style height.
If the S=? transform is not included in the linetype definition, the text height is determined
by the height defined in the text style. If the text style is defined with a height of zero and
the S=? transform is not included in the linetype definition, the height of the repeating text
will default to 1 (one).
How to center the text in a complex linetype
The X=? and Y=? transforms are used to center align the repeating text. The X value
required can be determined from the width of the repeating space where the text is to
appear and the width of the repeating text. The repeating space is created by the
negative number preceding the text definition.
One way to determine the width for the repeating text is to place the text in a drawing and
use the distance command to measure the width. The DTEXT command can be used to
create the text. Use the same height for the text that you intend to use in the linetype.
After the space width and the character width have been determined, subtract the width of
the text from the blank space where the text is going to be placed, and divide by two.
Then subtract this number from the space to determine to distance to shift the text to the
left in the space. Make sure to use a minus sign (-) to make the number negative.
The formula is:
SP-((SP - W)/2)
given:
SP = repeating space and W = width of the letters (text string)
To center the repeating text in the vertical orientation, divide the S=? transform by 2 and
Controlling Complex Linetypes
http://www.afralisp.com/lisp/ltype2.htm (1 of 4) [23/03/2005 05:51:46 p.m.]
use this value. Add a minus sign to move the text down. (Example Y= -0.25) See the
previous section on how to set the height of repeating text if the S=? transform is not the
only control for the text height. The number for the Y=? transform must be the negative of
half the repeating text height. (It must be a negative number to shift the text down from
the line segments.)
Settings in the drawing that affect complex linetypes
The style used for repeating text in a complex linetype must be defined as a text style in
the drawing. Therefore, if you change a text style already used by complex linetypes in a
drawing, the changes will also affect the display of repeating text in the next complex
linetype you create in that drawing. The affected settings include Width factor, Obliquing
angle, Backwards, Upside down, and Vertical.
For example, if you add text to a drawing that uses the same style as text in a complex
linetype, and you change the text style to have an oblique angle, the text will also be
oblique in the next complex linetype that is created in the drawing. For this reason, it may
be prudent to create unique styles for the text to be used in linetypes. Complex lines will
use those style settings until another style is used.
Note: You may need to perform a regen in order to see the changes display.
LTSCALE or CELTSCALE commands change the repeating text and the lengths of the
repeating patterns to a new size. The LTSCALE variable scales the repeating text and
line segments in every line in a drawing. This variable scales all complex linetypes
proportionally in the drawing. The CELTSCALE is not a global variable and only scales
lines created after it is set. The CELTSCALE variable also scales complex lines
proportionally.
Exercise - Centering text in a complex linetype
Create a new text style
1. Start a new drawing in AutoCAD.
2. Issue the style command.
3. Enter TEST for the style name.
4. Select txt.shx on the select font file dialog box.
5. Press Enter repeatedly to accept the default settings for the text style. (Make
sure the height is set to zero.)

Determine the width of the repeating text


1. Use the DTEXT command and create the text OO, (capital o) set the height to
0.5.
2. Use the DIST command to measure the width of the text. It should be around
0.83. This width is used to determine the value needed to center the text in the
complex line.
Define the linetype
1. Open up a text editor like Windows Notepad and enter the following 2 lines.
*MYLINE,----OO----
A,1,-2,["OO",TEST,S=0.5,R=0,X= -1.42,Y= -0.25],1
2. Save this file with the arbitrary name of lt-test.lin
Load the linetype in AutoCAD
1. Issue the linetype command
2. Select the load option.
3. Enter MYLINE font the linetype to load.
4. Select the lt-test.lin in the Select Linetype File dialog box.
Use the linetype
1. Bring up the layer control dialog box.
2. Select layer zero
3. Choose Set LTYPE.
4. Select MYLINE.
5. Press OK.
6. Make sure linetype is set to MYLINE and layer zero is current, and press OK.
7. Draw lines and notice that the text is now centered in the repeating space.
Discussion of the exercise
1. Open the lt-test.lin in a text editor (such as Notepad).
2. The following should be in the file:
*MYLINE,----OO----
A,1,-2,["OO",test1,S=0.5,R=0,X= -1.42,Y= -0.25],1
Controlling Complex Linetypes
http://www.afralisp.com/lisp/ltype2.htm (2 of 4) [23/03/2005 05:51:46 p.m.]
The X value is used to move the text parallel to the repeating line segments. In this
linetype the letters OO need to be centered in a space of 2. The width of the text at height
of 0.5 is 0.83. The number 1.42 was derived by the following formula:
2-((2-0.83)/2)=1.42
The number is negative to move the repeating text back towards the start of the line into
the blank space.
The Y value is used to move the text perpendicular to the repeating line segments. In this
linetype the -0.25 is used to center the letters OO. This number is derived by dividing the
S=0.5 value by two. The number is negative to move it down in relationship to the
repeating line segments.
Helpful tips
If a text style that will be used in the linetype is not defined, the error "Bad
definition of (linetype name) at line (line#) of file filename.lin" will
appear when you attempt to load the linetype.
Use a text editor to create the complex linetype. If you try to create a complex
linetype from the AutoCAD command line, you will get the error: "INVALID
number or bad continuation". The linetype definition will not be saved.

Text objects in complex linetypes are displayed completely and never trimmed.
The Description of the linetype (first line) has a 47 character limit.

There is a 12 Dash - length specifications limit per linetype, and a limit of 80


characters for a line.

The first line segment cannot be negative.

Put half of the repeating segment after the text definition. Adding a line segment
after the repeating text will ensure that a line segment will not cross the last text
object in the line when it is placed in a drawing. AutoCAD adjusts the line
segments to force the line to start and end with a dash.

The scale command adjusts the length of the complex linetype and not the size
of the repeating text or repeating line segments.
The complex linetype can only have one color in standard AutoCAD. It can be
set to color by layer or to any color using entity creation mode.
The text in a complex line is not a separate entity. The complex line cannot be
exploded.
Compiled shape files (.SHX files) can be used in complex linetypes. These .SHX
files must be created in AutoCAD. The location of the .SHX file must be set in
the support path under Preferences/ File System. Use the instructions in the
AutoCAD Customization Guide under Linetype Definition Files. An AutoCAD
drawing that contains such a linetype must be accompanied by the compiled
shape file or .SHX file where the shape is defined, as well as the .LIN file where
the linetype is defined.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Controlling Complex Linetypes
http://www.afralisp.com/lisp/ltype2.htm (3 of 4) [23/03/2005 05:51:46 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Controlling Complex Linetypes
http://www.afralisp.com/lisp/ltype2.htm (4 of 4) [23/03/2005 05:51:46 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Menu Loader
Loading partial men files can be a real pain. Having to first add all the menu directories to the
AutoCAD Support Path and then installing the menu files becomes a real hassle, especially if you've
got a number of workstations to take care of.
Here's a little application that takes a lot of the pain out of multiple standard menu installation.
I have used a small partial menu "Vbamenu.mnu" that contains one pulldown menu and one
toolbar as an example.
First, you need to have your support file directory structure set up and ready :
c:/vbamenu
c:/vbamen/lisp
c:/vbamenu/vba
In this example you can see that I've set up my main directory, "c:/vbamenu" with two
sub-directories, "lisp" and "vba."
My menu and lisp files, "vbamenu," "vba.dll," and "vbamenu.lsp" are stored in "vbamenu,"
whilst I would store any additional support files in the other two sub-directories.
In essence, these are the directories that I would need to add to my AutoCAD support path.
Next, fire up AutoCAD and open a blank drawing.
Now type this at the command line :
(load "c:\\vbamenu\\vbamenu)
Then press "Enter"
A message should appear on the command line asking you to type "vbamenu" to run.
Do just that and stand back.
Voila, you should have a new pull down menu and a new toolbar.
Check out your support path. Three new directories should have been added :
Menu Loader
http://www.afralisp.com/lispa/menuload.htm (1 of 6) [23/03/2005 05:51:49 p.m.]
Heres the coding :
;inform the user how to run the application
(prompt "\nVBA Menu Installer Loaded...Type VBAMENU to run......")
;define the function
(defun C:VBAMENU ( / flag1 loaded temp)
;add the first support path
(addSupportPath "C:\\VBAMENU" 6)
;add the second
(addSupportPath "C:\\VBAMENU\\LISP" 7)
;add the third
(addSupportPath "C:\\VBAMENU\\VBA" 8)
;set the flag
(setq flag1 T)
;check if the menu is not already loaded
(setq loaded (menugroup "VBAMENU"))
;if it is not loaded
(if (= loaded nil)
;do the following
(progn

;find the menu file
(setq temp (findfile "VBAMENU.MNU"))
;if you find the menu
(if temp
;do the following
(progn
;switch off dialogues
(setvar "FILEDIA" 0)
Menu Loader
http://www.afralisp.com/lispa/menuload.htm (2 of 6) [23/03/2005 05:51:49 p.m.]
;load the menu
(command "menuload" "VBAMENU")
;switch on dialogues
(setvar "FILEDIA" 1)
;install the pulldown
(menucmd "P11=+VBAMENU.POP1")
;inform the user
(prompt "\nLoading VBA Menu....\n")
);progn
;menu not find, so do the following
(progn
;inform the user
(alert "Cannot Locate VBA Menu.
\nCall System Administrator.")
;clear the flag
(setq flag1 nil)
);progn
);if
);progn
);if
;if the flag is set
(if flag1
;inform the user
(prompt "\nVBA Menu Loaded....\n")
);if
(princ)
);defun
;subroutine to add support path
(defun addSupportPath (dir pos / tmp c lst)
(setq tmp ""
c -1
)
(if
(not
(member (strcase dir)
(setq lst
(mapcar 'strcase
(parse (getenv "ACAD") ";")
Menu Loader
http://www.afralisp.com/lispa/menuload.htm (3 of 6) [23/03/2005 05:51:49 p.m.]
)
);setq
);member
);not
(progn
(if (not pos)
(setq tmp (strcat (getenv "ACAD") ";" dir))
(mapcar '(lambda (x)
(setq tmp (if (= (setq c (1+ c)) pos)
(strcat tmp ";" dir ";" x)
(strcat tmp ";" x)
)
)
)
lst
)
)
(setenv "ACAD" tmp)
)
)
(princ)
)
;parsing routine
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
(while pos
(setq lst (cons (substr str 1 pos) lst)
str (substr str (+ pos 2))
pos (vl-string-search delim str)
)
)
(if (> (strlen str) 0)
(setq lst (cons str lst))
)
(reverse lst)
)
(princ);clean load
A big thank you to ActiveX.com for allowing me to borrow a wee bit of their coding.
To make sure that your menu is loaded every time AutoCAD starts, place this coding in your
Acad.Lsp file :
(defun-q VBAMENUSTARTUP ()
(setq flag1 T)
(setq loaded (menugroup "VBAMENU"))
(if (= loaded nil)
(progn
(setq temp (findfile "VBAMENU.MNU"))
(if temp
Menu Loader
http://www.afralisp.com/lispa/menuload.htm (4 of 6) [23/03/2005 05:51:49 p.m.]
(progn
(setvar "FILEDIA" 0)
(command "menuload" "VBAMENU")
(setvar "FILEDIA" 1)
(menucmd "P11=+VBAMENU.POP1")
(prompt "\nLoading VBA Menu....\n")
);progn
(progn
(alert "Cannot Locate VBA Menu.
\nCall System Administrator.")

(setq flag1 nil)
);progn
);if
);progn
);if
(if flag1
(prompt "\nVBA Menu Loaded....\n")
);if
(princ)
);defun-q
(setq S::STARTUP (append S::STARTUP VBAMENUSTARTUP))
To download source coding - VbaMenu1.Zip (6kB) - click here

Menu Loader
http://www.afralisp.com/lispa/menuload.htm (5 of 6) [23/03/2005 05:51:49 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Menu Loader
http://www.afralisp.com/lispa/menuload.htm (6 of 6) [23/03/2005 05:51:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Preserving CustomToolbars
When you create, or edit, your toolbars for AutoCAD the changes, or new toolbars, are written into your
ACAD.MNS file (assuming your menu file is ACAD.MNU). As soon as you recompile your ACAD.MNU,
AutoCAD will write over these changes when it creates a new MNC, MNR and MNS file for the associated
ACAD.MNU. To preserve your new, or customized, toolbars follow these easy steps:
Using any text editor (Notepad or Write will work) open up the
ACAD.MNS, or whatever menu's associated MNS file you are
using.
G
Use the SEARCH or FIND utility to go to the TOOLBARS section of
the ACAD.MNS. The Toolbars section starts with the following
couple lines:
***TOOLBARS
**STANDARD_TOOLBAR
**TB_STANDARD_TOOLBAR
G
Go to the toolbar(s) which you've either added or customized,
highlight it, then copy it to your clipboard. Usually any *new*
toolbars created will be at the end of the TOOLBARS section. For
example, if you've created a new toolbar named, MOSTUSED,
then go to the TOOLBARS section and search for MOSTUSED and
copy this portion to the clipboard.
G
Open up the ACAD.MNU file in your text editor. G
Find the TOOLBARS section of the ACAD.MNU file using the
SEARCH/FIND utility. The TOOLBARS section starts with the
following lines:
//
// Begin AutoCAD ToolBars
//
***TOOLBARS
**STANDARD_TOOLBAR
G
Now PASTE the contents of the clipboard into the TOOLBARS
section of the ACAD.MNU. By putting your customized, or new,
toolbars in the ACAD.MNU you will preserve them forever, even
when you recompile the ACAD.MNU.
G
If you've editted, or changed, the HELPSTRINGS section you will
need to cut and paste these changes from the HELPSTRINGS
section of the ACAD.MNS to the HELPSTRINGS section of the
ACAD.MNU.
G
Now that you've successfully cut and paste your customized
toolbars into the ACAD.MNU save the file, and exit.
G
Whenever you need to recompile the ACAD.MNU now in AutoCAD,
the changes you've made will carry along without being overwritten
or lost.
G

Preserving Custom Toolbars


http://www.afralisp.com/lisp/ptools.htm (1 of 2) [23/03/2005 05:51:50 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Preserving Custom Toolbars
http://www.afralisp.com/lisp/ptools.htm (2 of 2) [23/03/2005 05:51:50 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Set and Setq
In AutoLisp, the process of establishing a value for a symbol is called assignment. The common way to do assignment is
to use SETQ. An assignment causes the value of its second argument to become the value of its first argument, which
has to be a symbol. A symbol is a lexical variable, declared implicitly.
SET is somewhat like SETQ except that SET does evaluate its first argument. Therefore the first argument must evaluate
to the name of a dynamic variable (one whose value is to be created dynamically). The only other difference is that SET
takes only two arguments.
Consider the following assignments :
(setq a `var) sets symbol A to VAR. Symbol VAR is not defined.

(set a 2) Evaluates A and sets the result of this evaluation to 2.

(princ var) Returns 2. Symbol VAR is now defined and set to 2.
A common use of the SET assignment is to define symbols at runtime, and is sometimes more efficient than list
construction when the number of items is not known in advance. As an illustration of this, the following lisp routine
example takes a variable number of points, sorts them by their Y coordinate and draws a line using the sorted points.
(defun c:test ( / j lpt symb)

(setq j 1)
(while (set (read (strcat "point_" (itoa j)))
(getpoint "\nPoint : ")
)
(setq j (1+ j))
)
;; Last point is nil.
(setq j (1- j))
;; Sort the points. See function "sortpoints" below.
(sortpoints j)
;; Initialize the list of points to be passed to (command "_line")
(setq lpt (list ""))
;; Construct the list and set each of our
Set and Setq
http://www.afralisp.com/lisp/set.htm (1 of 3) [23/03/2005 05:51:52 p.m.]
;; "on the fly" symbols to nil
(while (> j 0)
(setq
symb (read (strcat "point_" (itoa j)))
lpt (cons (eval symb) lpt)
)
(set symb nil)
(setq j (1- j))
)
;; draw the line
(command "_line")
(mapcar 'command lpt)
(princ)
)


;; This function sorts the points by their Y coordinate
(defun sortpoints (j / i cur_y prev_y cur_symb prev_symb point)
(setq i 2)
(while (<= i j)
(setq
cur_symb (read (strcat "point_" (itoa i)))
prev_symb (read (strcat "point_" (itoa (1- i))))
cur_y (cadr (eval cur_symb))
prev_y (cadr (eval prev_symb))
)
(if (> cur_y prev_y)
(progn
(setq point (eval prev_symb))
(set prev_symb (eval cur_symb))
(set cur_symb point)
(if (/= i 2) (setq i (1- i)))
)
(setq i (1+ i))
)
)
)

Set and Setq


http://www.afralisp.com/lisp/set.htm (2 of 3) [23/03/2005 05:51:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Set and Setq
http://www.afralisp.com/lisp/set.htm (3 of 3) [23/03/2005 05:51:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Program Looping.
AutoLisp uses 2 kinds of loops, namely (repeat) and (while).
Let's have a look at the (repeat) function first :
(repeat).
The (repeat) function is a simple looping structure. It executes any number
of statements a specific number of times. Like the (progn) function, all of
it's expressions get evaluated, but they get evaluated once each loop.
Here's a simple example :
(defun c:loop ()
(setq pt (getpoint "\nCentre of Rotation : "))
(setq n (getint "\nEnter Number of Steps : "))
(repeat n
(command "Rotate" "L" "" pt "20")
)
(princ)
)
Now draw a circle anywhere on the screen and then run the routine.
The circle should move around.
Note that the variable that controls the number of loops must be an integer.

(while).
The (while) function loops like (repeat) except that (while) has a
conditional test. (while) will continue looping through a series of
statements until the condition is nil. Here's an example :
(defun c:loop1 ()
(while
(setq pt (getpoint "\nChoose a point : "))
(command "point" pt)
)
(princ)
)
In this example, you can continue to pick points until you press Enter.
(AutoLisp treats Enter as nil). When you press enter the loop will terminate.
Here's another example :
(defun c:loop2 ()
(setq ptlist nil)
(while
(setq pt (getpoint "\nEnter Point or RETURN when done: "))
Program Looping
http://www.afralisp.com/lispa/lisp10.htm (1 of 2) [23/03/2005 05:51:53 p.m.]
(setq ptlist (append ptlist (list pt)))
)
(princ)
)
This example keeps on asking for a point and adding the point to a list of
points, called ptlist. It uses the (append) function to merge the new point
list to ptlist. As soon as you hit Enter the loop stops.
Run the routine, choose a few points and check the value of ptlist.
It should contain a long list of points.

The (while) function can also be used for programme iteration.


This means that a loop is continued until the results of one or more expressions, calculated within the
loop, determine whether the loop is terminated. A common use of iteration is to increment a counter.
Have look at this example :
(defun c:loop3 ()
(setq count 0)
(while (< count 10)
(princ count)
(setq count (1+ count))
)
(princ)
)
You should get :
012345678910
If you know the number of times you want to loop, use (repeat), a much
simpler command than (while).
Hint : Have you ever wondered how to make an AutoLisp routine Auto-Repeat?
Enclose the whole function or sub-function in a (while) loop.
This way, the function will keep on repeating until Enter or Cancel is hit.
Enough for now, my brain hurts......
In fact, I think I'm going "Loopy-Loo"
Cheers....

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Program Looping
http://www.afralisp.com/lispa/lisp10.htm (2 of 2) [23/03/2005 05:51:53 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Conditionals.
(If) is probably the most important and widely use condition statement.
Unlike other languages though, you can match only one (if) statement with a then
statement. The syntax is as follows :
(if xyz
(then do this)
(else do this)
)
Let's look at a simple example :
(defun c:testif ()
(setq a (getreal "\nEnter a Number : ")
b (getreal "\nEnter Second Number : ")
);setq
(if (= a b)
(prompt "\nBoth Numbers are equal")
(prompt "\nBoth numbers are not equal")
);if
(princ)
);defun
(princ)

If you need to evaluate more than one then, or else statement, you must use the (progn) function.
Here's another example :
(defun c:testprogn ()
(setq a (getreal "\nEnter a Number : ")
b (getreal "\nEnter Second Number : ")
);setq
(if (= a b)
(progn
(prompt "\nBoth Numbers are equal")
(prompt "\nHere is Another statement")
(prompt "\nAnd Another One")
);progn
(prompt "\nBoth numbers are not equal")
);if
(princ)
);defun
(princ)
You can use as many statements as you like within the (progn) function.
You can also use (if) along with logical operators. They are functions that determine how two or
more items are compared. The available logical operators are :
Conditionals
http://www.afralisp.com/lispa/lisp13.htm (1 of 4) [23/03/2005 05:51:54 p.m.]
AND OR NOT
AND returns true if all arguments are true.
OR returns true if any of the arguments are true.
NOT returns true if it's argument is false and returns false if it's argument is true. Let's look at
some examples :
(defun c:testand ()
(setq a (getreal "\nEnter a Number : "))
(if
(and
(>= a 5.0)
(<= a 10.0)
);and
(prompt "\nNumber is between 5 and 10")
(prompt "\nNumber is less than 5 or greater than 10")
);if
(princ)
);defun
(princ)

(defun c:testor ()
(setq a (getstring "\nAre you Male? Y/N : "))
(if
(or
(= a "y")
(= a "Y")
);or
(prompt "\nHello Sir")
(prompt "\nHello Madam")
);if
(princ)
);defun
(princ)

A Relation Operator is a function that evaluates the relationship between two or more items.
Relationship Operators available are :
< less than
> greater than
<= less than or equal to
>= greater than or equal to
= equal to
/= not equal to
eq are two expressions identical
equal are two expressions equal
Let's look a bit closer at the (eq) and the (equal) functions.
The (eq) function determines whether two expressions are bound to the same object.
(setq a '(x y z))
(setq b '(x y z))
(setq c b)
(eq a c) would return nil, a and c are not the same list.
Conditionals
http://www.afralisp.com/lispa/lisp13.htm (2 of 4) [23/03/2005 05:51:54 p.m.]
(eq c b) would return true, b and c are exactly the same list.
The (equal) function determines whether two expressions evaluate to the same thing. You can use
the optional numeric argument, fuzz, to specify the maximum amount by which both expressions
can differ and still be considered equal.
(setq a '(x y z))
(setq b '(x y z))
(setq c b)
(setq m 1.123456))
(setq n 1.123457))
(equal a c) would return true.
(equal c b) would return true.
(equal m n) would return nil.
(equal m n 0.000001) would return true.

What about a Multiple (if) function. The (cond) function works very much like (if), except (cond)
can evaluate any number of test conditions.
Once (cond) finds the first condition that is true, it processes the statements associated with that
condition. (It only processes the first true condition). Here's an example :
(defun c:testcond ()
(setq a
(strcase (getstring "\nSize of Bolt (M10,M12,M16): ")
);strcase
);setq
(cond
((= a "M10") (prompt "\nYou have choosen M10"))
((= a "M12") (prompt "\nYou have choosen M12"))
((= a "M16") (prompt "\nYou have choosen M16"))
(T (prompt "\nUnknown Bolt Size"))
);cond
(princ)
);defun
(princ)
The (cond) function takes any number of lists as it's arguments.
Each argument must be a list containing a test followed by any number of expressions to be
evaluated.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Conditionals
http://www.afralisp.com/lispa/lisp13.htm (3 of 4) [23/03/2005 05:51:54 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Conditionals
http://www.afralisp.com/lispa/lisp13.htm (4 of 4) [23/03/2005 05:51:54 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
COND vs IF
Written by David Hoekstra
Published on AfraLisp with kind permission.
"IF I had a nickel for every COND statement that I ever wrote in lisp, I'd be rich!"
I see lots of lisp routines that use only the IF function for conditional statements. I think this has a lot to do
with the fact that most new AutoLISP programmers start out with IF, and never proceed on to COND. I have
talked to several lisp programmers who state that they never learnt how to use COND, and seemed to think it
was useless.
COND is a thing of beauty, and let me tell you why.
The basic syntax of COND is:
(cond ((predicate1) (then do something 1)) ;if this predicate is true,
;do something1
((predicate2) (then do something 2)) ;if this predicate is true,
;do something2,
;each predicate and action
;following the
;first one is optional
(t (else do this)) ;else, if none of the
;predicates returns
;T, do this
)
Compare that to the syntax of IF:
(if (only one predicate) ;must return T, even if it is a double negative
(then do something) ;if the predicate is true, then do this
;prescribed something
(else do this) ;this is optional, if there is an else, then
;this is what happens
;if the predicate is not true
)
With IF, there is only one predicate (or grouped predicate), one then (or grouped then), and one optional else
(or grouped else) statement. When these are all you need, then IF works quite nicely, i.e., logically. Where I
find IF to be distasteful is when it is used with grouped then or else statements; and also if you need more
than one predicate, it requires several IF statements in combination.
Because IF can only accept one statement for the then and else clause, you must use the PROGN to group
several statements as one statement:
(if (> angle 90)
(progn ;then clause
(setq ed (subst (cons 8 "somelayer") (assoc 8 ed) ed))
(entmod ed)
(entupd en)
) ;_ progn
(princ "\nNothing changed.") ;optional else clause
) ;_ if
The "then" clause needs to run several statements if the predicate is true (> angle 90), if the symbol "angle" is
greater than 90. Because IF only accepts one statement for a then clause, you must artificially wrap the three
statements into a grouped statement by use of PROGN. Now let's compare this to the same operation, but
COND vs IF
http://www.afralisp.com/lisp/conif.htm (1 of 3) [23/03/2005 05:51:55 p.m.]
written with COND instead:
(cond ((< angle 90)
(setq ed (subst (cons 8 "somelayer") (assoc 8 ed) ed))
(entmod ed)
(entupd en)
) ;_ end of the first then condition
(t
(princ "\nNothing changed.")
) ;_ end of optional else condition
) ;_ end of cond statement
Here there is no artificial wrapping of several statements into one group. This COND statement will not fail if
you forget to add a PROGN wrapper! In the case above, I consider COND to be a more logical implementation,
and therefore "the right thing to do." Remember, programmers live and die by the logic in their code. This is
certainly one reason to consider using COND instead of IF, but let me give another one: multiple predicates in
one COND statement!
(cond ((and (>= angle 0) (<= angle 90)
(setq ed (subst (cons 8 "somelayer") (assoc 8 ed) ed))
(entmod ed)
(entupd en)
) ;_ end of the first then condition
((and (> angle 90) (<= angle 180)
(statement 1)
(statement 2)
(statement 3)
(statement 4)
) ;_ end of the second then condition
((and (> angle 180) (<= angle 270)
(statement a)
(statement b)
(statement c)
(statement d)
) ;_ end of the third then condition
((and (> angle 270) (< angle 360)
(statement x)
(statement y)
(statement z)
(statement 0)
) ;_ end of the third then condition
) ;_ end of cond statement
In this one COND statement, there are four separate conditions that could be met, the equivalent IF statement
would require four separate IF statements. Furthermore, because the predicates are evaluated sequentially,
you can use that to your advantage. In some cases you may not have to exactly define every detail for each
predicate:
(setq angdir 354)
(cond ((< angdir 90)
(princ "\ncond1")
)
((< angdir 180)
(princ "\ncond2")
)
((< angdir 270)
(princ "\ncond3")
)
((< angdir 360)
(princ "\ncond4")
)
) ;_ cond
And finally, another reason to use COND as much as possible. Have you ever written a lisp routine that is
entirely dependent on a condition being met right at the start? Consider putting the majority of the code
inside a COND statement. Then if that condition is not met, the routine will quietly exit without the need to run
the EXIT or QUIT function, which can force an error call. I might want to perform several things in a drawing,
but the whole process is dependent on having a particular drawing format block inserted:
COND vs IF
http://www.afralisp.com/lisp/conif.htm (2 of 3) [23/03/2005 05:51:55 p.m.]
(defun C:TEST (/)
(setq ss (ssget "X" '((0 . "insert")(2 . "e1_title"))))
(cond (ss ;if there is a selection set, then proceed
(statement 1)
(statement 2)
... ad infinitum
(statement 455)
)
(t ;else exit the routine without forcing an error call
(princ "\nNo E1_TITLE format found, cannot continue, exiting!")
)
) ;_ cond
(princ)
) ;_ C:TEST
To be sure, IF statements have their place. There is no reason to write a COND statement when a simple IF
statement makes more logical sense:
(if (null tfstd)
(load "tfstd" "\nTFSTD.LSP was not found in any of the paths.")
)
(tfstd)
The above example would not be very logical if it were forced into a COND statement. As we can see there are
times when only an IF statement will do the trick nicely, and other times when only COND will. The problem is
when AutoLISP programmers attempt deal with every conditional logic by the IF function. Of course, I could
cite other examples of the same sorts of functional fallacies, but suffice to say, the best method to avoid such
traps is to experiment, experiment, experiment, and read other people's code with an eye to learning
something new.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
COND vs IF
http://www.afralisp.com/lisp/conif.htm (3 of 3) [23/03/2005 05:51:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Error Trapping.
This was another area that caused me quite a bit of confusion when I was first learning AutoLISP. All
AutoLISP routines should contain Error Trapping. There is nothing worse than running a routine and
finding out that once it has run, or been cancelled, your system variables, etc. have all changed and
nothing works the same any more.
I am going to look at two types of Error Trapping here. Firstly, an Error Trapping routine build into a function, and
secondly, a Global Error Trapping function. But first, some background on the AutoCAD *error* function.
AutoLISP provides a method for dealing with user (or program errors).
It is one of the only AutoLISP functions that is user-definable.
This is the *error* function.
(*error* string)
It is executed as a function whenever an AutoLISP error condition exists.
If there is an error, AutoCAD passes one argument to *error*, which is a string containing a description of the error.
The following function does the same thing that the AutoLISP standard error handler does. Print error and the
description.
(defun *error* (errmsg)
(princ "error: ")
(princ errmsg)
(princ)
)
Before designing an Error Trapping function there is a couple of things to keep in mind.
First, the Error-Trap function must be called *error*. It also must have an argument passing variable. Our variable is
called errmsg.
You can call this variable anything you like. Now, you can put anything you like in the body of this function. For
example :
(defun *error* (errmsg)
(princ "\nAn error has occurred in the programme. ")
(terpri)
(prompt errmsg)
Error Trapping
http://www.afralisp.com/lispa/lisp6.htm (1 of 5) [23/03/2005 05:51:56 p.m.]
(princ)
)
To test this error trap, create a lisp file with the preceding code and load the file. Begin running any program or
command that you like. In the middle of the program hit ESC or Ctrl C. (AutoCAD thinks that this is an error.)
Control should be passed to the Error Trap.
It is important to note, and courteous, that you should never change a users settings, including an existing Error Trap,
without first saving it as a variable and then replacing it at the end of the program.
Remember, as well, to place the replacement of this Error Trap in your Error Trap routine as your program could also
crash.
Here is an example of Error Trap build into an AutoLISP routine :
(defun c:drawline () ;define function
(setq temperr *error*) ;store *error*
(setq *error* trap1) ;re-assign *error*
(setq oldecho (getvar "cmdecho")) ;store variables
(setq oldlayer (getvar "clayer"))
(setq oldsnap (getvar "osmode"))
(setvar "cmdecho" 0) ;set variables
(setvar "osmode" 32)
(command "undo" "m") ;undo mark
(setq pt1 (getpoint "\nPick First Point: ")) ;get points
(setq pt2 (getpoint pt1 "\nPick Second Point: "))
(command "LAYER" "M" "2" "") ;change layer
(command "Line" pt1 pt2 "") ;draw line
(setq pt3 (getpoint pt2 "\nPick Third Point: "));get 3rd point
(setvar "osmode" 0) ;switch off snap
(command "Line" pt2 pt3 "") ;draw line
(setvar "clayer" oldlayer) ;reset variables
(setvar "osmode" oldsnap)
(setvar "cmdecho" oldecho)
(setq *error* temperr) ;restore *error*
(princ)
)
(defun trap1 (errmsg) ;define function
(command "u" "b") ;undo back
(setvar "osmode" oldsnap) ;restore variables
(setvar "clayer" oldlayer)
(setvar "cmdecho" oldecho)
(setq *error* temperr) ;restore *error*
(prompt "\nResetting System Variables ") ;inform user
Error Trapping
http://www.afralisp.com/lispa/lisp6.htm (2 of 5) [23/03/2005 05:51:56 p.m.]
(princ)
)
This routine simply asks for 3 points then draws a line, on layer 2, between them. As you can see, the existing (*error*)
error trap is saved to the variable temperr. *error* is then re-assigned to the error trap, called trap1.
Any system variables such as object snaps and command echo, are saved as well as the current layer. An UNDO
MARK is then put in place.
When an error occurs, the error trap first performs an UNDO BACK before resetting the drawing back to it's original
settings.
Try choosing the first two points and then hitting ESC or Ctrl C.
Did you see what happened? The first line that was drawn was erased and your settings have been returned to their
initial state.
The following is an example of an Error Trap using a Global Function :
Our drawline routine with some differences!!
(defun c:drawline () ;define function
(initerr) ;intit error
(setvar "cmdecho" 0) ;reset variables
(setvar "osmode" 32)
(command "undo" "m") ;set mark
(setq pt1 (getpoint "\nPick First Point: ")) ;get points
(setq pt2 (getpoint pt1 "\nPick Second Point: "))
(command "LAYER" "M" "2" "") ;change layer
(command "Line" pt1 pt2 "") ;draw line
(setq pt3 (getpoint pt2 "\nPick Third Point: "));get 3rd point
(setvar "osmode" 0) ;reset snap
(command "Line" pt2 pt3 "") ;draw line
(reset) ;reset variables
(princ)
)
(princ)
Now our Global Error Trap named Error.Lsp
(defun error() ;load function
(prompt "\nGlobal Error Trap Loaded") ;inform user
(princ)
);defun
;;;*==========================================================
(defun initerr () ;init error
(setq oldlayer (getvar "clayer")) ;save settings
(setq oldsnap (getvar "osmode"))
Error Trapping
http://www.afralisp.com/lispa/lisp6.htm (3 of 5) [23/03/2005 05:51:56 p.m.]
(setq oldpick (getvar "pickbox"))
(setq temperr *error*) ;save *error*
(setq *error* trap) ;reassign *error*
(princ)
);defun
;;;*===========================================================
(defun trap (errmsg) ;define trap
(command nil nil nil)
(if (not (member errmsg '("console break" "Function Cancelled"))
)
(princ (strcat "\nError: " errmsg)) ;print message
)
(command "undo" "b") ;undo back
(setvar "clayer" oldlayer) ;reset settings
(setvar "blipmode" 1)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ "\nError Resetting Enviroment ") ;inform user
(terpri)
(setq *error* temperr) ;restore *error*
(princ)
);defun
;;;*===========================================================
(defun reset () ;define reset
(setq *error* temperr) ;restore *error*
(setvar "clayer" oldlayer) ;reset settings
(setvar "blipmode" 1)
(setvar "menuecho" 0)
(setvar "highlight" 1)
(setvar "osmode" oldsnap)
(setvar "pickbox" oldpick)
(princ)
);defun
;;;*======================================================
(princ)
To run and test this you must load Error.Lsp before you load Drawline.Lsp.
As you can see, by using a Global Error routine you can save yourself the bother of writing individual error traps for
each of your programs.
Error.Lsp could easily be loaded from your Acad.Lsp and would then be available whenever one of your routines
wishes to call upon it.
Error Trapping
http://www.afralisp.com/lispa/lisp6.htm (4 of 5) [23/03/2005 05:51:56 p.m.]
Happy Error Trapping!!!!

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Error Trapping
http://www.afralisp.com/lispa/lisp6.htm (5 of 5) [23/03/2005 05:51:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Calculating Points - Polar
The Polar function is defined in the AutoCAD Customization
manual as follows :
POLAR : Returns the UCS 3D point at a specified angle and
distance from a point.
(polar pt ang dist)
This, I believe, is one of the most useful functions in the AutoCAD stable.
In a nutshell, you feed it a point, tell it the angle and distance from that point that you want to be, and it will
return the second point.
Can you imagine having to do that using car, cadr, etc.
First you would have to break the list down into each separate component, do all the calculations on each
individual item, and then re-construct the list.
What a pain!!
Following is an example of how to use POLAR to construct a simple square
or rectangle from values input by the user :
(defun DTR (a) ;degrees to radians function
(* PI (/ a 180.0))
);defun
;=========================================
(defun C:BOX1 (/ IP P1 P2 P3 LENGTH HEIGHT ;define function and declare
OLDSNAP OLDBLIP OLDLIGHT) ;variables as local
(setq OLDSNAP (getvar "OSMODE") ;store system variables
OLDBLIP (getvar "BLIPMODE")
OLDLIGHT (getvar "HIGHLIGHT")
);setq
;=========================================
(setvar "CMDECHO" 0) ;change system variables
(setvar "BLIPMODE" 0)
(setq IP (getpoint "\nInsertion Point: ")) ;get insertion point
(setvar "OSMODE" 0) ;switch off snap
(setq LENGTH (getreal "\nEnter Length: ") ;get length of box
HEIGHT (getreal "\nEnter Height: ") ;get height of box
);setq
;=========================================
(setq P1 (polar IP (DTR 0.0) LENGTH) ;calculate first corner
P2 (polar P1 (DTR 90.0) HEIGHT) ;calculate second corner
P3 (polar P2 (DTR 180.0) LENGTH) ;calculate third corner
);setq
;=========================================
(command "PLINE" IP "W" "" ""
P1 P2 P3 "C"
);command ;draw the box
;=========================================
(prompt "\nRotation Angle: ") ;prompt the user for rotation
(command "ROTATE" "LAST" "" IP pause) ;rotate the box
;=========================================
(setvar "OSMODE" OLDSNAP) ;reset system variables
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ) ;exit quietly
Calculating Points - Polar
http://www.afralisp.com/lispa/lisp2.htm (1 of 2) [23/03/2005 05:51:57 p.m.]
);defun
To save you typing here's the source code : Box1 Lisp (1 Kb)
As you can see, we first need to write a function to convert radians to degrees. This is because when we deal
with angles in AutoLISP they must be in Radians.
Hint : This could be a Global function loaded from your Acad Lisp file.
Now to our main routine.
The first thing that we do is define the function and declare all the variables as local. (Only used within this
program.)
Then we save certain system variables, before changing them, so that we can reset them later.
Next we ask the user for Insertion Point, Length and Height of the box.
We then use the POLAR function to calculate the remaining 3 corners of the box. (PT1, PT2 and PT3).
Then, just to be kind, we allow the user to rotate the box.
(That's why we drew the box using a Pline.)
Lastly, we reset all the system variables that we changed back to their original state.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Calculating Points - Polar
http://www.afralisp.com/lispa/lisp2.htm (2 of 2) [23/03/2005 05:51:57 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Locating Files.
AutoLISP has two functions available to help us locate files.
They are the (findfile) function and the (getfiled) function.
(findfile).
The (findfile) function will only search the current AutoCAD search path if a drive/directory
prefix is not supplied.
If the file is found, the full directory path is returned.
If no file is found, (findfile) returns nil.
The syntax of this function is as follows :
(findfile "filename")
Say you were looking for the file ACADR14.LSP.
(findfile "ACADR14.LSP)
Would return :
"C:\\ACADR14\\SUPPORT\\ACADR14.LSP"
Note :
AutoLisp allows you to use / or \\ for directory descriptors.
(getfiled).
The (getfiled) function will prompt the user for a file name using the standard AutoCAD file
dialogue box. It will then return the file name either with the full path name or with the path
name stripped.
The syntax of the (getfiled) function is as follows :
(getfiled "Title" "Directory Path and/or File name" "File Extension" Flag)
The "Title" argument is simply the name that will appear in the Title Bar of the dialogue box.
The "Directory Path and/or File Name" argument is the default directory path that the dialogue box
will use. If a file name is included this name will appear in the File Name edit box. This can be null.
The "File Extension" function is the default file name extension. If it is null, it defaults to * (all file
types). If the file type "dwg" is part of the "File Extension", an image preview is displayed.
There are four possible flags and they make use of the "sum of the flags" concept.
To combine any of the flags, just add them together. The flags are :
Flag 1. If you set this flag, the function will prompt for the name of a
NEW file to create.
Flag 4. This flag will disable the "Type it" button. The user must then
pick from the listed files rather than type a file name.
If this flag is not set and the user selects the "Type it" button,
the dialogue box disappears and (getfiled) returns a value of 1.
Locating Files
http://www.afralisp.com/lispa/lisp14.htm (1 of 3) [23/03/2005 05:51:59 p.m.]
Flag 3. This flag allows the user to enter a file extension.
If the flag is not set, only the extension used in the extension
edit box will be used.
The extension is also added to the file name if the user does not
enter it in the File Name edit box.
Flag 8. If this flag is set and flag 1 is not set, (getfiled) searches in
accordance to the AutoCAD library search path. It also strips the
path and only returns the file name.
If it is not set, it returns the entire path name.

Let's look at an example. We want to open a directory on c:/ called "Slides" containing a list of file that
we would like to view. Our routine would look like this :
(defun c:slv ( / sl)
(setq sl (getfiled "Pick a slide to view"
"C:/SLIDES/"
"sld"
10
);getfiled
);setq
(command "vslide" sl)
(princ)
);defun
(princ)
Your dialogue box should look like this :
Take note of a couple of things.
See how it defaults to the C:/SLIDES directory;
The "Type it" button has been disabled; (Flag 2 was set.)
The full path name of the file was returned. (Flag 8 was set)
This is because C:/SLIDES is not in my AutoCAD search path.

As you can see, this is quite a useful function in that it can restrict your user to only certain directories
and file types whilst still leaving them some flexiblity in their choice.

Locating Files
http://www.afralisp.com/lispa/lisp14.htm (2 of 3) [23/03/2005 05:51:59 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Locating Files
http://www.afralisp.com/lispa/lisp14.htm (3 of 3) [23/03/2005 05:51:59 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
File Handling.
AutoLisp can only deal with one type of external file, namely an ASCII text file.
As well as this, AutoLisp can only read a file in sequential order. (It does not have
random access.)
Despite these drawbacks, AutoLisp has certain basic tools that allow you to read and
write one character at a time, or a full line at a time.
You can also append data to an existing file.
Working with external files is very simple.
First you "Open" the file.
Then you process the file by "Reading", "Writing" or "Appending" to it.
You then "Close" the file.
When you "Open" a file, Autolisp returns a file handle. This file handle is a name supplied by the
operating system that let's you inform AutoLisp which file you want to work with.
Let's look at some examples.
(setq file (open "Testfile.txt" "w"))
AutoLisp should return something like this :
File: #28a27d2
This is the file handle returned by the operating system and stored in variable "file".
Try this now :
(write-line "This is some test data." file)
This "writes" a line of data to the file with handle "file".
(write-line "This is some more test data." file)
Let's write some characters to the same file :
(write-char 79 file)
This would write the ASCII character "O" to the file.
(write-char 75 file)
This would write the letter "K"
Now let's close the file :
(close file)
To read a file is just as simple :
(setq file (open "testfile.txt" "r"))
Open "Testfile.txt" to "Read".
(read-line file)
Read the first line.
Lisp should return :
"This is some test data "
File Handling
http://www.afralisp.com/lispa/lisp15.htm (1 of 5) [23/03/2005 05:52:00 p.m.]
Read the next line :
(read-line file)
Lisp should return :
"This is some more test data."
Let's read a character :
(read-char file)
Lisp will return :
79
It has returned the ASCII number.
(chr (read-char file))
Read the character AND convert it.
Lisp should return :
"K"
(read-line file)
Lisp should return "nil" as we have reached the end of the file.
Before moving on, you should always make sure that you close
your files.
(close file)

Append is very similar to writing to a file except the file must already
exist if you want to append to it.
There are three other functions that write to an external file.
They are (princ), (prin1) and (print).
Let's have a look at them :
(setq file (open "afile.txt" "w"))
(princ "This is the (princ) function" file)
(prin1 "This is the (prin1) function" file)
(print "This is the (print) function" file)
(close file)
Open the file "afile.txt". You should have the following :
This is the (princ) function"This is the (prin1) function"
"This is the (print) function"
All 3 functions display the result at the prompt line and send the
output to a file. Here are the differences :
(princ) displays strings without quotation marks.
(prin1) displays strings with quotation marks.
(print) displays strings with quotation marks and places a blank line
before the expression and a space afterwards.
Now we will look at a practical example :
The following is a Drawing Log Routine that logs the date, time, &
Drawing Name of each Drawing Session. It writes a report
to an ASCII Text file (Log.Txt).
(defun C:LOGIN ( / a c d file fp)
(setq file (findfile "LOG.TXT"))
(if (not file)
File Handling
http://www.afralisp.com/lispa/lisp15.htm (2 of 5) [23/03/2005 05:52:00 p.m.]
(open "LOG.TXT" "w")
);if
(setq a (TODAY)
TIME1 (TIME)
c (getvar "DWGNAME")
d (strcat "Drg Start " a " - " TIME1 " - " c)
);setq
(if (/= c "Drawing.dwg")
(progn
(setq file (findfile "LOG.TXT")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(close fp)
(princ (strcat "\nLogged in at : " TIME1))
);progn
);if
(princ)
);defun
;;;*-------------------------------------------------
(defun C:LOGOUT ( / a c d file fp)
(setq a (TODAY)
TIME2 (TIME)
c (getvar "DWGNAME")
d (strcat "Drg Exit " a " - " TIME2 " - " c)
);setq
(if (/= c "Drawing.dwg")
(progn
(setq file (findfile "LOG.TXT")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(close fp)
(princ (strcat "\nLogged out at : " TIME2))
(etime)
);progn
);if
(princ)
);defun
;;;*-------------------------------------------------
(defun ETIME ( / hr1 m1 s1 tot1 hr2 m2 s2 tot2 total ht mt file fp)
(setq hr1 (* 60 (* 60 (atof (substr time1 1 2))))
m1 (* 60 (atof (substr time1 4 2)))
s1 (atof (substr time1 7 2))
tot1 (+ hr1 m1 s1)
hr2 (* 3600 (atof (substr time2 1 2)))
m2 (* 60 (atof (substr time2 4 2)))
s2 (atof (substr time2 7 2))
tot2 (+ hr2 m2 s2)
total (- tot2 tot1)
hr1 (/ total 3600)
ht (fix hr1)
hr1 (- hr1 ht)
mt (* hr1 60)
ht (rtos ht)
mt (rtos mt)
File Handling
http://www.afralisp.com/lispa/lisp15.htm (3 of 5) [23/03/2005 05:52:00 p.m.]
);setq
(setq d (strcat "Editing Time This Session :
" ht " Hours and " mt " minutes"))
(setq file (findfile "LOG.TXT")
fp (open file "a")
);setq
(princ d fp)
(princ "\n" fp)
(princ "==========================
====================================" fp)
(princ "\n" fp)
(close fp)
(princ)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Date
(defun TODAY ( / d yr mo day)
(setq d (rtos (getvar "CDATE") 2 6)
yr (substr d 3 2)
mo (substr d 5 2)
day (substr d 7 2)
);setq
(strcat day "/" mo "/" yr)
);defun
;;;*-------------------------------------------
;;;*Calculates the Current Time
(defun TIME ( / d hr m s)
(setq d (rtos (getvar "CDATE") 2 6)
hr (substr d 10 2)
m (substr d 12 2)
s (substr d 14 2)
);setq
(strcat hr ":" m ":" s)
);defun
(princ)
Load the file and type "Login" to run it. Leave it for a minute or so and then type "Logout" to exit
the routine.
Have a look at the file Log.txt. It should look something like this :
Drg Start 07/12/98 - 15:36:31 - F4443.dwg
Drg Exit 07/12/98 - 15:36:34 - F4443.dwg
Editing Time This Session : 0 Hours and 0.05 minutes
==============================================================
Every time you log on and off the Starting Time, Ending Time and Total Editing Time will be
appended to this file.
If you wish you can load Login.Lsp from your AcadDoc.Lsp file, and edit the Acad.mnu to call the
Logout.Lsp routine before Exiting, Quiting or Starting a new drawing.
To download the source coding for this routine, just place you mouse
pointer here and click. (Gently please, I've got a hangover.)
For more information on this topic, refer to the External Data Tutorial.

File Handling
http://www.afralisp.com/lispa/lisp15.htm (4 of 5) [23/03/2005 05:52:00 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
File Handling
http://www.afralisp.com/lispa/lisp15.htm (5 of 5) [23/03/2005 05:52:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
External Data
Do you have a library full of blocks taking up vast amounts of disk space?
Do you find it difficult to locate a specific block because you've got so many or cannot
remember what you called it?
By using external data you can parametrically draw these objects. If you look at my
Structural Steel Programme DDSTEEL you will notice that every section is drawn using
data retrieved from an external data file.
The following tutorial will show you how to retrieve external data, format it into
something that Autolisp can use, then place the data into individual variables.
First of all you need to create the external data file.
Create a text file called Test.dat and type in the following data :
*6
152.0,10.0,124.0
*7
178.0,12.0,135.0
*8
203.0,14.0,146.0
*9
229.0,16.0,158.0
This type of data file is known as a comma deliminating text file.
The data represents values that we would use to draw a specific object.
The first line (*6) represents the name of the object
and the second line (152.0,10.0,124.0) are the values that we are
attempting to retrieve.
Next, create a Lisp file called Test.Lsp and type in the following :
(defun C:Test (/ item data dline maxs
count chrct numb size)
(setq size
(getstring "\nEnter Size <6, 7, 8 or 9>: "))
;enter size req'd
(setq dlist nil
size (strcat "*" size)
;add asterix to size
file (findfile "test.dat")
;find data file
fp (open file "r")
;open file to read
item (read-line fp)
;first line is label for file
);setq
(while item
;process each line of file
(if (= item size)
;compare values
(setq data (read-line fp)
;read a line
item nil
External Data
http://www.afralisp.com/lispa/lisp1.htm (1 of 3) [23/03/2005 05:52:02 p.m.]
;stop searching for item
);setq
(setq item (read-line fp))
;keep searching for item
);if
);while
(if data
;if the size has been found
(progn
(setq maxs (strlen data)
;establish length of input
count 1
;initiliaze count
chrct 1
;initiliaze char position
);setq
(while (< count maxs)
;process string one chr at a time
(if (/= "," (substr data count 1))
;look for the commas
(setq chrct (1+ chrct))
;increment to next position
(setq numb (atof
(substr data
(1+ (- count chrct)) chrct))
;convert to real
dlist (append dlist (list numb))
;add it to the list
chrct 1
;resets field ct
);setq
);if
(setq count (1+ count))
;increment the counter
);while
(setq numb (atof
(substr data
(1+ (- count chrct))))
;convert to real
dlist (append dlist (list numb))
;add it to the list
);setq
);progn
);if data
(close fp)
;close data file
(mapcar 'set '(a b c) dlist)
;allocate to variables
);defun
The programme basically does the following :

Gets the name of the object who's data we want to retrieve.(eg 6) G


Adds a * to the front of it. (eg *6) G
Searches for the Data file (Test.Dat) and opens it to read. G
Reads each line of the file until it finds one matching our objects name. G
Reads the next line and stores the data. G
External Data
http://www.afralisp.com/lispa/lisp1.htm (2 of 3) [23/03/2005 05:52:02 p.m.]

Unfortunately, the data we have looks something like this :


(152.0,10.0,124.0)
Oh No, Commas...Don't worry the next section of the program deals with them. It parses the data
and removes all commas so that we end up with a LIST looking like this :
(152.0 10.0 124.0)
Now by using the mapcar function we can allocate each item in the list to its own variable.
(mapcar 'set '(a b c) dlist)
I have deliberately not declared these variables as locals so that you can view them within
AutoCAD.
Type !dlist to view the data list.
Type !a to see the first item in the list.
Type !b to see the second item in the list.
Type !c to see the third item in the list.
You can now use this data to draw your object.
As you can see, this is a much more efficient way of drawing objects that are the same shape but
have differing dimensions.
To save you having to type here is the source code for the whole
of this routine. Now don't you think I'm good to you?
Test Zip (7 Kb)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
External Data
http://www.afralisp.com/lispa/lisp1.htm (3 of 3) [23/03/2005 05:52:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
List Manipulation - Page I.
As you are probably well aware, LISP stands for "List Processing".
(Not "Lost in Stupid Parenthesis")
A list is a group of elements consisting of any data type and is stored as a single
variable. A list can contain any number of Reals, Integers, Strings, Variables and even
other Lists.
Let's have a look at a list. Type this :
(setq pt1 (getpoint "\nChoose a Point : "))
AutoLisp should return something like this :
(127.34 35.23 0.0)
Fine, you say, I've got a list but what do I do with it?
AutoLisp has many functions available to manipulate lists.
Let's have a look at them.
Car
The primary command for taking a list apart is the "Car" function.
This function returns the first element of a list. (The x coordinate.)
For example :
(setq a (car pt1))
Would return :
(127.34)
Cdr
This function returns the second element plus the remaining elements of a list. For example :
(setq b (cdr pt1))
Would return :
(35.23 0.0)
But what if we only wanted the second element? We could write :
(setq b (car (cdr pt1)))
But there is a better way. AutoLisp has provided the "Cadr" function which is basically an
abbreviation of a nested command.
Cadr
This returns the second element of a list. (The y coordinate.)
(setq b (cadr pt1))
This would return :
(35.23)
Likewise, there is another abbreviated function to return the third element.
List Manipulation Page I
http://www.afralisp.com/lispa/lisp17.htm (1 of 2) [23/03/2005 05:52:03 p.m.]
Caddr
This returns the third element of a list. (The z coordinate.)
(setq c (caddr pt1))
Would return :
(0.0)
AutoLisp has other functions that will retrieve values from lists of more than three elements. (Caar,
cadar, etc). You can, though, us another function to access any element of a list. This is the "nth"
function.
nth
The syntax for the nth function is as follows :
(nth num list)
"num" is the number of the element to return. Just remember that zero is the first element. For
example given the list :
(setq d '("M10" "M20" "M30" 10.25))
(setq e (nth 0 d))
Would return :
("M10")
And likewise :
(setq f (nth 3 d))
Would return :
(10.25)
On the next page we will look at a practical example of using these functions.
Home. Page II. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
List Manipulation Page I
http://www.afralisp.com/lispa/lisp17.htm (2 of 2) [23/03/2005 05:52:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III.
List Manipulation - Page II.
We've now managed to extract elements from a list, but what do you do
if you want to create a new list. Let's say you have two elements :
(setq a 200.0)
(setq b 400.0)
You want to combine them to create a new list. To do this you would use the "List" function. For
example :
(setq c (list a b))
Would return :
(200.0 400.0)
You could also write the function like this :
(setq c '(a b))
Here's an example of List Manipulation. We are going to use the (car), (cadr) and (list) function to
draw a rectangle.
(defun c:rec ( / pt1 pt2 pt3 pt4)
(setq pt1 (getpoint "\nSelect First Corner: "))
;get the first point
(setq pt3 (getcorner pt1 "\nSelect Second Corner: "))
;get the third point
(setq pt2 (list (car pt1) (cadr pt3)))
;construct the second point
(setq pt4 (list (car pt3) (cadr pt1)))
;construct the fourth point
(command "Line" pt1 pt2 pt3 pt4 "c")
;draw the rectangle
(princ)
);defun
;**********************************************************
Let's look closer at the line :
(setq pt2 (list (car pt1) (cadr pt3)))
This function retrieves the first element (x coordinate) from the list pt1, the second element (y
coordinate) from the list pt3, creates a list from these elements and stores the list in the variable pt2.
The following diagram should help you to better understand this.
List Manipulation Page II
http://www.afralisp.com/lispa/lisp171.htm (1 of 3) [23/03/2005 05:52:04 p.m.]

AutoLisp provides other functions to manipulate lists. Let's have a look at some of them.
Append
This takes any number of lists and runs them together as one list :
(append '(12.0 15.5) '("M20" "M30))
Would return :

(12.0 15.5 "M20" "M30")
Last
Will return the last element of a list :
(last '("M20" "M24" "M30"))
Would return :
("M30")
Length
This returns an integer indicating the number of elements in a list :
(length '("M20" "M24" "M30"))
Should return :
(3)
Member
This function searches a list for a specific element. If found it returns the element plus the
remainder of the list :
(member 'c '(a b c d e f))
would return :
(c d e f)
Reverse
Returns a list with it's elements reversed :
(reverse '(a b c d e f))
Will Return :
List Manipulation Page II
http://www.afralisp.com/lispa/lisp171.htm (2 of 3) [23/03/2005 05:52:04 p.m.]
(f e d c b a)
Subst
Searches a list for an old element and returns a copy of the list with the new item substituted in
place of every occurrence of the old item :
Syntax : (subst newitem olditem lst)
(setq lst '(a b c d e c)))
(subst 'f 'c lst)
Would return
(a b f d e f)
On the next page we will have a look at a more advanced List Manipulation Example.
Page I. Home. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
List Manipulation Page II
http://www.afralisp.com/lispa/lisp171.htm (3 of 3) [23/03/2005 05:52:04 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home.
List Manipulation - Page III.
It is good practice (and manners) when writing Lisp routines to restore the system
environment to the state that your program found it in on completion
of your application. Most AutoLisp routines start and end like this :
(defun c:example ()
(setq oldhigh (getvar "Highlight")
oldsnap (getvar "Osmode")
oldblip (getvar "BlipMode")
oldecho (getvar "Cmdecho")
);setq
(setvar "Highlight" 0)
(setvar "Osmode" 517)
(setvar "Blipmode" 0)
(setvar "Cmdecho" 0)
Programme statements.............
.................................
(setvar "Highlight" oldhigh)
(setvar "Osmode" oldsnap)
(setvar "Blipmode "oldblip)
(setvar "Cmdecho" oldecho)
(princ)
);defun
;******************************************************
I must have written statements like this a thousand times in my Lisp routines.
The following example is designed to act as a global routine that first stores, then changes specific
system variables. On completion of the routine, the function is then called again and all system
variables are returned to their previous settings.
(defun varget ()
(setq lis '("HIGHLIGHT" "BLIPMODE" "CMDECHO"
"BLIPMODE" "OSMODE"))
;store names of system variables
(setq var (mapcar 'getvar lis))
;get the value of the system variables and
;store them as a list
(setq var1 '(0 0 0 0 517))
;store the new values of the system variables
(setq no 0)
List Manipulation Page III
http://www.afralisp.com/lispa/lisp172.htm (1 of 3) [23/03/2005 05:52:05 p.m.]
;set counter to zero
(repeat (length lis)
;get the number of variables in the list
;to use as the counter control number
(setvar (nth no lis) (nth no var1))
;set the variables to their new values
(setq no (1+ no))
;move up one in the list
);repeat
(princ);finish quietly
);defun
;***************************************************************
(defun varset ()
(setq no 0)
;set counter to zero
(repeat (length lis)
;get the number of variables in the list
(setvar (nth no lis) (nth no var))
;reset the variables to their original values
(setq no (1+ no))
;move up one in the list
);repeat
(princ);finish quietly
);defun
;***************************************************************
(princ);load quietly
Our Autolisp routine could now look like this :
(defun c:example ()
(varget)
;store system variables and then reset them
Programme statements.............
.................................
(varset)
;restore system variables
(princ)
);defun
List Manipulation Page III
http://www.afralisp.com/lispa/lisp172.htm (2 of 3) [23/03/2005 05:52:05 p.m.]
;******************************************************
As you can see, we have reduced the size of our routine by a lot and saved ourselves quite a bit of
typing. These two routines could both be loaded from our Acad.Lsp file so that they would be
available to all of your routines.
If you would like the source coding for this AutoLisp Tutorial then Click Here. Ta Ta for Now......
Page I. Page II. Home.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
List Manipulation Page III
http://www.afralisp.com/lispa/lisp172.htm (3 of 3) [23/03/2005 05:52:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
Into the Database - Page I
Hold onto your hat because we're going to dive straight in here.
Fire up AutoCad and draw a line anywhere on the screen.
Now type this then press Enter:
(setq a (entlast))
Lisp should return something like this:
&ltEntity name: 2680880>
This is the Entity Name of the Line that you have just drawn.
Now type "Erase" then !a and press Enter twice.
The line should disappear. Type "OOPS" to bring it back.
You have just modified the AutoCAD Database.
Now type this :
(setq b (entget a))
This will retrieve the Entity Data. It should look something like this :
((-1 . &ltEntity name: 2680880>) (0 . "LINE") (5 . "270")
(100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine")
(10 400.378 621.82 0.0) (11 740.737 439.601 0.0)
(210 0.0 0.0 1.0))
Now type this line:
(setq c (cdr (assoc 10 b)))
Lisp should return:
(400.378 621.82 0.0)
Before you type the next few lines, make sure that your snap is turned off.
Command: circle
3P/2P/TTR/&ltCenter point>: !c
Diameter/&ltRadius> &lt10.0>: 20
A circle should be drawn at the end of the line.
This exercise was just to show you the ability of AutoLisp to go behind your drawing, into the
database, and manage graphic and non-graphic information. This tutorial will show you how
entities are stored and referenced in the database.
It will show you how AutoLisp reveals data about entities and how they can be modified and
manipulated. Say au revoir to your wife and kid's and let's visit the AutoCad Database. (Star Trek
theme music now starts......)
Home. Page II. Page III.

Into the Database Page I


http://www.afralisp.com/lispa/lisp18.htm (1 of 2) [23/03/2005 05:52:07 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Into the Database Page I
http://www.afralisp.com/lispa/lisp18.htm (2 of 2) [23/03/2005 05:52:07 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III.
Into the Database - Page II
When you first start to delve into the AutoCAD database it is, I admit, quite daunting. But,
although entity access and manipulation is fairly complex, it can be divided into
component parts that make it much easier to understand.
Let's have a look at an AutoLisp routine that can be used, as a sort of template
which you can apply to numerous, similar applications. Have a close look at this coding :
(defun C:CHLAYER ( / a1 a2 n index b1 b2 b3 d1 d2)

(prompt "\nSelect Entities to be Changed : ")
(setq a1 (ssget))
(prompt "\nPoint to Entity on Target Layer : ")
(setq a2 (entsel))
(setq n (sslength a1))
(setq index 0)
(setq b2 (entget (car a2)))
(setq d2 (assoc 8 b2))
(repeat n
(setq b1 (entget (ssname a1 index)))
(setq d1 (assoc 8 b1))
(setq b3 (subst d2 d1 b1))
(entmod b3)
(setq index (1+ index))
);repeat
(princ)
);defun
(princ)
This routine allows you to select any number of objects and change them to a different layer. The
target layer is choosen by simply pointing to an object on the desired layer. (To test this routine,
you will need to create a drawing with objects on different layers.) Let's have a look line by line :
(defun C:CHLAYER ( / a1 a2 n index b1 b2 b3 d1 d2)
Defines the function and declares all variables as local.
(prompt "\nSelect Entities to be Changed : ")
Prompts the user.
(setq a1 (ssget))
Allows the user to select the objects to be changed. The selection set is assigned to variable 'a1'.
(prompt "\nPoint to Entity on Target Layer : ")
Prompts the user to select the Target Layer.
(setq a2 (entsel))
This is a special type of selection statement that only allows you to
select one entity.
(setq n (sslength a1))
Into the Database Page II
http://www.afralisp.com/lispa/lisp181.htm (1 of 3) [23/03/2005 05:52:08 p.m.]
Counts the number of entities in the selection set 'a1' and stores this number in variable 'n'.
(setq index 0)
Sets the loop control variable 'index' to zero.
(setq b2 (entget (car a2)))
This statement retrieves the entity list from 'a2' and assigns it to 'b2'.
(setq d2 (assoc 8 b2))
This looks for the code 8 in the entity list 'a2', and then assigns the sub list to 'd2'.
(repeat n
This begins the loop that pages through the selection set.
(setq b1 (entget (ssname a1 index)))
This gets the entity list and assigns it to 'b1'.
(setq d1 (assoc 8 b1))
Gets the sublist code 8. (The Layer)
(setq b3 (subst d2 d1 b1))
Substitutes the new 'd2' layer for the old 'd1' layer in the entity list 'a1', and assigns it to the new
entity list 'b3'.
(entmod b3)
Updates the new entity list in the database.
(setq index (1+ index))
Increases the 'index' variable by 1, priming it for the next loop.
);repeat
Closes the repeat loop.
(princ)
Finish cleanly.
);defun
Closes the function.
(princ)
Clean Loading.
Listed below is another routine that allows you to globally change the height of text without
affecting other entities. As you will see, the only difference is, is that we have added a conditional
filter to the routine.
(defun C:CHGTEXT ( / a ts n index b1 b2 b c d)

(setq a (ssget))
(setq ts (getreal "\nEnter New Text Height : "))
(setq n (sslength a))
(setq index 0)
(repeat n
(setq b1 (entget (ssname a index)))
(setq index (index+ 1))
(setq b (assoc 0 b1))
(if (= "TEXT" (cdr b))
(progn
(setq c (assoc 40 b1))
(setq d (cons (car c) ts))
(setq b2 (subst d c b1))
Into the Database Page II
http://www.afralisp.com/lispa/lisp181.htm (2 of 3) [23/03/2005 05:52:08 p.m.]
(entmod b2)
);progn
);if
);repeat
(princ)
);defun
(princ)

Well I bet your brain hurts after that lot!!!


On the text page we'll have a quick look at Tables.
Page I. Home. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Into the Database Page II
http://www.afralisp.com/lispa/lisp181.htm (3 of 3) [23/03/2005 05:52:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home.
Into the Database - Page III
The AutoCad Database does not only consist of entities but also includes several other
sections, such as the Tables Section.
Tables store information about entities that are maintained globally within the drawing.
For example, when you insert a block into a drawing, how does AutoCAD know what the
block looks like? The definition of a block is stored in the Block Table. What happens, for
example, if you need to create a layer? You have to know if the layer already exist
because if you try to create a layer that already exists your program will crash. Therefore,
you would search the Layers Table first to see if the layer exists.
There are nine (9) Tables that you can access :
Layer Table "LAYER"
Linetype Table "LTYPE"
Named View Table "VIEW"
Text Style Table "STYLE"
Block Table "BLOCK"
Named UCS Table "UCS"
Named Application ID Table "APPID"
Named Dimension Style Table "DIMSTYLE"
Vport Configuration Table "VPORT"
A Table is split into 2 parts: The 'names' of the entries in the Table and the 'details' of each entry.
For example, in the Layers Table, the name of the entries would be the names of the layers that
exist. The details of an individual layer would be colour, linetype, on, off, frozen, thawed, locked,
unlocked or current.
To access a Table we would use the (tblsearch) function. Let's have a look at
an example :
Assume that you want to know whether a layer called STEEL exists in your drawing. First create
the layer STEEL then type the following :
(setq t (tblsearch "LAYER" "STEEL"))
The entity list of the layer STEEL should be returned :
((0 . "LAYER") (2 . "STEEL") (70 . 64) (62 . 7) (6 . "CONTINOUS"))
The first part of the entity list is '0', indicating Associative 0.
In this case it's an entry in the "LAYER" Table.
Associative 2 indicates the name of the layer. STEEL in our case.
Associative 70 is the state of the entity. 1 is Frozen, 2 is Frozen on new paper space view ports and 4
is locked. These numbers are added to 64. In this case the layer is neither frozen nor locked.
Associative 62 is the colour of the layer. Ours is white which is colour number 7. If the colour
number is a negative number then the layer is off.
Associative 6 is the linetype of the layer, in this case, "CONTINUOUS".
If the (tblsearch) had not found the layer then it would have returned 'nil' and you would know that
the layer did not exist.
Sometimes you don't know the name of a layer or a block but you need a list of them. This is when
Into the Database Page III
http://www.afralisp.com/lispa/lisp182.htm (1 of 5) [23/03/2005 05:52:09 p.m.]
the (tblnext) function comes into play.
Let's assume that 4 layers exist in your drawing. The layer names are MECH, STEEL, PIPE and
TXT. Enter the following :
(tblnext "Layer")
AutoLISP should return something like this :
((0 . "LAYER") (2 . "PIPE") (70 . 0) (62 . 7) (6 . "CONTINUOUS"))
Repeat the same command four additional times. You will get a new entity
list for each of the layers.
The last time you type the command AutoLISP will return 'nil' because there are no more
additional layers.
Let's have a look at this in action. We are going to design a dialogue box that displays a drop down
list of all the available layers in a specific drawing. The user can then choose any layer which can
then be used within his routine.
The Dialogue Coding looks like this :
getlay : dialog { //dialog name
label = "Get Layer" ; //give it a label
: popup_list { //define list box
key = "sel1"; //give it a name
value = "0"; //initial value
} //end list
ok_cancel ; //predifined OK/Cancel

} //end dialog
Now the AutoLisp Coding :
(defun c:getlay ( / NAMES SIZ1)
;define funcion
(setvar "cmdecho" 0)
;switch off command echo
(setq siz1 "0")
;initiliase variable
(setq userclick T)
;set flag
(setq f 1)
Into the Database Page III
http://www.afralisp.com/lispa/lisp182.htm (2 of 5) [23/03/2005 05:52:09 p.m.]
;rewind pointer
(while
;start while loop
(setq t1 (tblnext "Layer" f))
;get the next layer
(setq f nil)
;reset pointer
(setq b (cdr (assoc 2 t1)))
;get the layer name
(if (/= b "DEFPOINTS")
;if name is not equal to DEFPOINTS
(setq NAMES (append NAMES (list b)))
;Add the layer name to the list
);if
);while
(setq dcl_id (load_dialog "getlay.dcl"))
;load dialogue
(if (not (new_dialog "getlay" dcl_id)
;check for errors
);not
(exit)
;if problem exit
);if

(set_tile "sel1" "0")
;initilise list box
(start_list "sel1")
;start the list
(mapcar 'add_list NAMES)
;add the layer names
(end_list)
;end the list
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
);action_tile
;if cancel set flag to nil
Into the Database Page III
http://www.afralisp.com/lispa/lisp182.htm (3 of 5) [23/03/2005 05:52:09 p.m.]
(action_tile
"accept"
(strcat
"(progn
(setq SIZ1 (get_tile \"sel1\"))"
" (done_dialog)(setq userclick T))"
);strcat
);action tile
;if OK get the layer selected
(start_dialog)
(unload_dialog dcl_id)
(if userclick
;if flag true
(progn
(setq SIZ1 (nth (atoi SIZ1) NAMES))
;get the name of the layer from the list
(alert (strcat "\nYou Selected Layer " SIZ1))
;display the name
);end progn
);end if
(princ)
);defun C:getlay
(princ)

If you would like the source coding for this AutoLisp Routine then simply Click Here. Cheers and
keep well......
Page I. Page II. Home.

Into the Database Page III


http://www.afralisp.com/lispa/lisp182.htm (4 of 5) [23/03/2005 05:52:09 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Into the Database Page III
http://www.afralisp.com/lispa/lisp182.htm (5 of 5) [23/03/2005 05:52:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DXF Group Codes
The following table gives the group code or group code range accompanied
by an explanation of the group code value. In the table, "fixed" indicates
that this group code always has the same purpose. The purpose of group codes that aren't fixed can
vary depending on the context.
Entity group codes by number :
Group code Description
-5 APP: persistent reactor chain
-4 APP: conditional operator (used only with ssget)
-3 APP: extended data (XDATA) sentinel (fixed)
-2 APP: entity name reference (fixed)
-1 APP: entity name. This changes each time a drawing is opened.
It is never saved. (fixed)
0 Text string indicating the entity type (fixed)
1 Primary text value for an entity
2 Name (attribute tag, block name, and so on)
3-4 Other textual or name values
5 Entity handle. Text string of up to 16 hexadecimal digits (fixed)
6 Linetype name (fixed)
7 Text style name (fixed)
8 Layer name (fixed)
9 DXF: variable name identifier (used only in HEADER section of the DXF file).
10 Primary point. This is the start point of a line or text entity, center of
a circle, and so on.
DXF: X value of the primary point (followed by Y and Z value codes 20 and 30)
APP: 3D point (list of three reals)
11-18 Other points.
DXF: X value of other points (followed by Y value codes 21-28 and Z value
codes 31-38)
APP: 3D point (list of three reals)
20, 30 DXF: Y and Z values of the primary point
21-28, 31-37 DXF: Y and Z values of other points
38 DXF: entity's elevation if nonzero. Exists only in output from versions
prior to AutoCAD Release 11.
39 Entity's thickness if nonzero (fixed)
40-48 Floating-point values (text height, scale factors, and so on)
48 Linetype scale. Floating-point scalar value. Default value is defined for
all entity types.
49 Repeated floating-point value. Multiple 49 groups may appear in one entity
for variable-length tables (such as the dash lengths in the LTYPE table).
A 7x group always appears before the first 49 group to specify the table
length.
50-58 Angles (output in degrees to DXF files and radians through AutoLISP and
ARX applications).
60 Entity visibility. Integer value. Absence or 0 indicates visibility;
1 indicates invisibility.
62 Color number (fixed)
66 "Entities follow" flag (fixed)
67 Space--that is, model or paper space (fixed)
68 APP: identifies whether viewport is on but fully off screen; is not active
or is off.
69 APP: viewport identification number.
70-78 Integer values, such as repeat counts, flag bits, or modes
90-99 32-bit integer values
100 Subclass data marker (with derived class name as a string). Required for
all objects and entity classes that are derived from another concrete class
to segregate data defined by different classes in the inheritance chain for
the same object.
This is in addition to the requirement for DXF names for each distinct
concrete class derived from ARX (see "Subclass Markers").
102 Control string, followed by "{" or "}". Similar to the
xdata 1002 group code, except that when the string begins with "{", it
can be followed by an arbitrary string whose interpretation is up to the
application.
DXF Group Codes
http://www.afralisp.com/lispa/dxf.htm (1 of 3) [23/03/2005 05:52:11 p.m.]
The only other allowable control string is "}" as a group terminator.
As noted before, AutoCAD does not interpret these strings except during
drawing audit operations; they are for application use.
105 DIMVAR symbol table entry object handle
210 Extrusion direction (fixed).
DXF: X value of extrusion direction
APP: 3D extrusion direction vector
220, 230 DXF: Y and Z values of the extrusion direction
280-289 8-bit integer values
300-309 Arbitrary text strings
310-319 Arbitrary binary chunks with same representation and limits as 1004 group
codes: hexadecimal strings of up to 254 characters represent data chunks
of up to 127 bytes.
320-329 Arbitrary object handles. Handle values that are taken "as is." They are
not translated during INSERT and XREF operations.
330-339 Soft-pointer handle. Arbitrary soft pointers to other objects within same
DXF file or drawing. Translated during INSERT and XREF operations.
340-349 Hard-pointer handle. Arbitrary hard pointers to other objects within same
DXF file or drawing. Translated during INSERT and XREF operations.
350-359 Soft-owner handle. Arbitrary soft ownership links to other objects within
same DXF file or drawing. Translated during INSERT and XREF operations.
360-369 Hard-owner handle. Arbitrary hard ownership links to other objects within
same DXF file or drawing. Translated during INSERT and XREF operations.
999 DXF: The 999 group code indicates that the line following it is a comment
string. DXFOUT does not include such groups in a DXF output file, but
DXFIN honors them and ignores the comments. You can use the 999 group to
include comments in a DXF file that you've edited.
1000 ASCII string (up to 255 bytes long) in extended data.
1001 Registered application name (ASCII string up to 31 bytes long) for
extended data.
1002 Extended data control string ("{"or "}").
1003 Extended data layer name.
1004 Chunk of bytes (up to 127 bytes long) in extended data.
1005 Entity handle in extended data. Text string of up to 16 hexadecimal digits
1010 A point in extended data
DXF: X value (followed by 1020 and 1030 groups)
APP: 3D point
1020, 1030 DXF: Y and Z values of a point
1011 A 3D world space position in extended data
DXF: X value (followed by 1021 and 1031 groups)
APP: 3D point
1021, 1031 DXF: Y and Z values of a World space position
1012 A 3D world space displacement in extended data
DXF: X value (followed by 1022 and 1032 groups)
APP: 3D vector
1022, 1032 DXF: Y and Z values of a World space displacement
1013 A 3D world space direction in extended data.
DXF: X value (followed by 1022 and 1032 groups)
APP: 3D vector
1023, 1033 DXF: Y and Z values of a World space direction
1040 Extended data floating-point value.
1041 Extended data distance value.
1042 Extended data scale factor.
1070 Extended data 16-bit signed integer.
1071 Extended data 32-bit signed long.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
DXF Group Codes
http://www.afralisp.com/lispa/dxf.htm (2 of 3) [23/03/2005 05:52:11 p.m.]
Search
Powered by CORBIMITE.com
DXF Group Codes
http://www.afralisp.com/lispa/dxf.htm (3 of 3) [23/03/2005 05:52:11 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Selection Sets.
When you work with AutoCAD, you very seldom work with only one entity or, for that matter,
one type of entity. To be able to work efficiently with a group, or selection set, of entities, you
need to be able to place them in one place and work on them as a group. You might also want
to filter the entities so that only a certain type is within the group.
The AutoLisp function that enables you to do this is the (ssget) function.
(setq sel1 (ssget))
This function allows you to select as many entities as you like using any selection method, such as
Window, Crossing, Fence, etc.
You can also include a selection set filter within the function.
(setq sel1 (ssget "x"))
The "x" following the (ssget) is the most basic of filters. This filter selects ALL. This is quite sufficient in
some circumstances but you can filter the entities further by following the "x" with a list of associative
codes. For example :
(setq sel1 (ssget "x" '((8 . "STEEL"))))
This expression would create a selection set containing only entities that are on the STEEL layer.
(Associative code 8 refers to the Layer.)
You can use more than one associative code if you desire :
(setq sel1 (ssget "x" '((0 . "CIRCLE")(8 . "STEEL"))))
The above example would create a selection set of all CIRCLES on the Layer STEEL.
If you don't want to search the entire drawing for a selection set, but would rather use a select by
Window or Crossing, then just omit the "x" option.
(setq sel1 (ssget '((0 . "CIRCLE")(8 . "STEEL"))))
This example permits the user to select entities using any selection method he
prefers but, will only create a selection set of CIRCLES on Layer STEEL.
Try this next :
(setq sel1 (ssget "w" "\nSelect Objects by Window: "))
Doesn't work, does it?
You cannot use prompts within the (ssget) function. But, you can use other AutoCad functions to feed the
required information to the (ssget) function.
(prompt "\nSelect Objects by Window")
(setq p1 (getpoint "\nFirst Corner: "))
(setq p2 (getpoint p1 "\nSecond Corner: "))
(setq sel1 (ssget "w" p1 p2))
You can also use other selection options with (ssget)
(setq sel1 (ssget "P"))
This will create a selection set of all "Previous" entities.
Other options available are "L" for "Last" and "I" for "Implied".
You can also use logical filters when creating selection sets.
Have a look at a previous example :
(setq sel1 (ssget '((0 . "CIRCLE")(8 . "STEEL"))))
What we are saying here is :
Selection Sets
http://www.afralisp.com/lispa/lisp19.htm (1 of 3) [23/03/2005 05:52:12 p.m.]
"Create a selection set of all the CIRCLES from the entities selected
AND they must be on Layer "STEEL".
AND is the default logical filter when you string associative codes together.
You can also use the OR logical filter, but to do this you must inform AutoLisp
first. To do this you use a special type of associative code, the -4.
(setq sel1 (ssget '((-4 . "<OR")(8 . "STEEL")(8 . "PIPE")(-4 . "OR>"))))
This would create a selection set of all entities on Layer STEEL "OR" on Layer PIPE.
As well as logical filters, you can also have relation filters :
(setq sel1 (ssget '(0 . "CIRCLE")(-4 . ">=")(40 . 2.0)))
This would create a selection set of all CIRCLES with a RADIUS (group 40) of
greater or equal to 2.0.
All of these different types of filters can be nested.
You can also Add and Delete entities from selection sets. Three guesses what
these function names are? You were right first time, (ssadd) and (ssdel).
(setq sel1 (ssget))
;create the first selection set
(setq ent (car (entsel))
;select an entity and use (car (ensel))
; to retrieve the entity name
(setq sel1 (ssadd ent sel1))
;add the entity to the selection set
To delete an entity is exactly the same except for the last line :
(setq sel1 (ssdel ent sel1))
But what would you do if you wanted to add two selection sets together? The following explains how to
create a "Union" between 2 selection sets :
(setq ct 0)
;set counter to zero
(repeat (sslength sel2)
;get the number of items in selection set 2
;and loop that number of times
(ssadd (ssname sel2 ct) sel1)
;get the name of the entity from selection set 2
;by using the counter index number and add it to
;selection set 1
(setq ct (1+ ct))
;increment the counter by 1

);end repeat
Here's an example of a simple routine that will count the number of blocks
contained within a drawing :
(defun c:bcount ( / p1 b a n)
(setq p1 (getstring "\Name of Block : "))
;get the name of the block
(setq b (cons 2 p1))
;construct a dotted pair - code 2 is for blocks
(setq a (ssget "x" (list b)))
Selection Sets
http://www.afralisp.com/lispa/lisp19.htm (2 of 3) [23/03/2005 05:52:12 p.m.]
;filter for the block name
(if (/= a nil)
;check if there are any blocks of that name
(progn
;if there is...
(setq n (sslength a))
;count the number of blocks
(alert (strcat "\nThere are " (itoa n) " in the DataBase"))
;display the result
);progn
;if there are no blocks
(alert "\nThere are none in the DataBase")
;inform the user
);if
(princ)
);defun
(princ)
Well that's about it with selection sets. Just remember that you can save yourself an awful lot of work by
using selection sets with filters.
Filter at the source rather than programmatically trying to filter out the undesirable entities at a later
stage. Ta Ta for now........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Selection Sets
http://www.afralisp.com/lispa/lisp19.htm (3 of 3) [23/03/2005 05:52:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Selection Set Filters
Written by J arvis Fosdick
Very often I will want to select all items on a layer and move them off to the right hand side of my workspace,
but what happens if I want to select two layers? There are always several ways to do things. I have found
using the filter command is somewhat cumbersome. Another way to use these filters is from the ssget
function.
Command: copy
Select objects: (ssget ((8 . mylayer) (0 . circle) ))
This will only allow you to select circles on mylayer. If you wanted to select all the circles on layers mylayer and
mylayer2 it would look as follows.
Command: copy
Select objects: (ssget ((0 . circle) (-4 . <or) (8 . mylayer) (8 . mylayer2) (-4 . or>)))
The 4 dxf group code (-4 . <or) begins the conditional operator. The less than or open alligator symbol <
tells AutoCad to evaluate the conditional until it finds a closing alligator >. We use (-4 . or>) to end the
conditional.
Conditionals can be used together.
(ssget '(
(-4 . "<or")
(8 . "notes") (0 . "circle")
(-4 . "<and")
(8 . "s-boundary")(0 . "line")
(-4 . "and>")
(-4 . "or>")
))
This would select only those entities that are on the layer notes or are circles and entities that are both lines on
the layer s-boundary.
Conditional operators -- AND, OR, XOR, and NOT -- must be paired and balanced correctly in the filter list. The
number of operands you can enclose depends on the operation. Here is a list of the Conditionals or selection
set filters you can use:
<AND (One or more operands) AND>
(ssget ((-4 . <and) (0 . line) (8 . text) (62 . 3) (-4 . and>) ))
Selects entities that match all conditions.
<OR (One or more operands) OR>
(ssget ((-4 . <or) (0 . line) (8 . text) (62 . 3) (-4 . or>) ))
Selects entities that match any of the conditions.
<XOR (Two operands) XOR>
(ssget ((-4 . <xor) (8 . text) (62 . 3) (-4 . xor>) ))
Selects entities that match one or the other condition.
Selection Set Filters
http://www.afralisp.com/lisp/filter.htm (1 of 3) [23/03/2005 05:52:13 p.m.]
<NOT (One operand) NOT>
(ssget ((-4 . <not) (0 . line) (-4 . not>) ))
Selects entities that do not match one condition.
The XOR conditional works as an exclusive OR operator. For instance, using OR we may select entities that
are text and are either on the layer notes or have the color 3 or both.
(ssget ((0 . text) (-4 . <or) (8. notes) (62 . 3) (-4 . or>) ))
However, using XOR we may select only entities that are text and on layer notes or entities that are text and the
color 3. We cannot select entities that are text on the layer notes and the color 3.
(ssget ((0 . text) (-4 . <xor) (8. notes) (62 . 3) (-4 . xor>) ))
If we wish to select text that is both on the layer notes and the color 3 using XOR we must group these
properties with another conditional.
(ssget '(
(0 . text)
(-4 . "<xor")
(-4 . "<and") (8 . "notes") (62 . 3) (-4 . "and>")
(-4 . "xor>")
))
We can nest all sorts of conditionals into a selection set filter:
(ssget '(
(-4 . "<xor") (8 . "mylayer")
(-4 . "<or") (0 . "text")
(-4 . "<xor") (8 . "notes")
(-4 . "<and") (62 . 2) (0 . "line") (-4 . "and>")
(-4 . xor>")
(-4 . "or>")
(-4 . "xor>")
))
This is probably not practical, but it will work. See if you can figure out what it would select. There is not really
all that much to these conditionals and they are very handy. I use them mostly at the command prompt to copy
several layers at once, which tends to be easier then using the filter dialog box. The following lisp routine will let
you copy all the objects from two layers.
(defun c:layer_copy ( / laa la p1 p2 ss )
(princ "\n Choose an object on desired layer: ")
(setq laa (assoc 8 (entget (car (entsel)))))
(princ "\n Choose another object a different desired layer: ")
(setq la (assoc 8 (entget (car (entsel)))))
(setq ss (ssget "x" (list (cons -4 "<or") laa la (cons -4 "or>") )))
(command "copy" ss )
);defun
(princ)

Selection Set Filters


http://www.afralisp.com/lisp/filter.htm (2 of 3) [23/03/2005 05:52:13 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Selection Set Filters
http://www.afralisp.com/lisp/filter.htm (3 of 3) [23/03/2005 05:52:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Working with Layers & Styles.
I've had a lot of queries from people asking me how to create layers, change layers,
change text styles, etc. using AutoLisp.
This tutorial will take you through the steps of doing just that.
Before you do anything in regards to layers and styles, it's always best to retrieve the current layer,
or text style, so that you can restore it. To retrieve the current layer, use the following coding :
(setq oldlayer (getvar "CLAYER"))
This will retrieve the name of the current layer and store it in variable "oldlayer". To restore the
previous layer is just as simple:
(setvar "CLAYER" oldlayer)
This will set the current layer to the previous layer name stored in variable "oldlayer".
You would use exactly the same syntax for retrieving and restoring the name
of the current Text Style :
(setq oldstyle (getvar "TEXTSTYLE"))
(setvar "TEXTSTYLE" oldstyle)
You might think that this would be a good way of changing layers and style.
The problem here, is that if the layer name you want to change to does not exist your program will
crash.
You can use the "tblsearch" function to test if a layer or style exists :
(tblsearch "LAYER" "TESTLAYER")
(tblsearch "STYLE" "MYSTYLE")
If Layer "TESTLAYER" or Style "MYSTYLE" exists in your drawing, tblsearch will return
"True", otherwise it will return "Nil".
Here's an example that tests if a layer exist, and if it does, sets the current layer to that layer:
(setq oldlayer (getvar "clayer"))
;retrieve the current layer
(setq flag (tblsearch "LAYER" "NEWLAYER"))
;find out if the layer exists

(if flag
;if the layer exists
(setvar "CLAYER" "NEWLAYER")
;set current layer to "NEWLAYER"
);end if
This though, is quite a lot of coding just to check if a layer exists.
A better way, that applies to both Layers and Text Styles is to use the command function:
(command "Layer" "M" "NEWLAYER" "")
(command "Style" "Italict" "Italict.shx" "" "" "" "" "" "")
Both of these examples will change the layer or style, but will also create a new layer or text style if
Working with Layers and Styles
http://www.afralisp.com/lispa/lisp31.htm (1 of 2) [23/03/2005 05:52:14 p.m.]
the layer or style does not exist within the drawing. (The style .shx file must exist and be within the
AutoCad search path.)
I've also been asked that when I want to place text, dimensions, etc. into my drawing, how do I
ensure that they are drawn on a particular layer?
Now, you could modify the AutoCad Menu to achieve this, but I prefer to create
a partial menu with the modified macros in place.
The way to go about this is to simply prefix the menu macro with one that changes to the specific
layer :
[Dtext]^C^C^CLayer;M;5;;_Dtext
This ensures that I am on Layer 5 when I add text to a drawing.
Well, I hope this has helped you. Keep well.....

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Working with Layers and Styles
http://www.afralisp.com/lispa/lisp31.htm (2 of 2) [23/03/2005 05:52:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Extended Entity Data - Page I
What is Extended Entity Data?
For years AutoCAD has had the ability to store user information within a drawing by utilising
attributes. But, attributes have got their limitations.
They've got to be a block, or part of a block. They can be difficult to use.
They can be exploded or modified by the user and they can only hold certain types of information.
Extended Entity Data though, allows you to attach up to 16K of information to each and every entity in the
drawing. You can also keep it totally separate from other information and, because it uses a uniquely registered
name, can be kept relatively safe from being overwritten. You can also store lot's of different types of
information in Extented Entity Data.
Extended Entity Data is attached to an entity as an associated list with a code number of -3. The simplest form of
an Xdata Associative list would look something like this :
((-3 ("AFRALISP" (1000 . "Kenny is great"))))
Firstly, let's look at some of the different types of xdata that you can attach to an entity :
String 1000. A string of up to 255 characters.
Application Name 1001. An Application Name.
Layer Name 1003. The name of a Layer.
DataBase Handle 1005. The handle of an entity.
3D Point 1010. A 3D Coordinate value.
Real 1040. A real value.
Integer 1070. A 16 bit integer (signed or unsigned).
Long 1071. A 32 bit signed (long) integer.
Control String 1002. A control code to set off nested list.
World Space 1011. A 3D coordinate point that is moved, scaled
Position rotated, streched and mirrored along with the
entity.
World Space 1012. A 3D coordinate point that is scaled, rotated
Displacement or mirrored along with the entity. It cannot
be stretched.
World Space 1013. A 3D coordinate point that is rotated
Direction or mirrored along with the entity. It cannot
be scaled, streched or moved.
Distance 1041. A real value that is scaled along with the entity.
Used for distance.
Scale Factor 1042. A real value that is scaled along with the entity.
Used as a scale factor.
Another important thing to remember about Xdata is that you can have more than
one of the same associative code.
Let's attach some xdata to an entity in a drawing. Draw a line then type this:
(regapp "AFRALISP")
AutoLisp should return :
"AFRALISP"
You have now registered your external entity data name. This name is a unique identifier to your own extended
entity data.
Next we need to get the entity data list of the entity that we want to add exdata to. Type this :
(setq oldlist (entget (car (entsel))))
Extended Entity Data Page I
http://www.afralisp.com/lispa/lisp21.htm (1 of 3) [23/03/2005 05:52:15 p.m.]
AutoLisp should return something like this:
Select object: ((-1 . ) (0 . "LINE") (5 . "271") (100 .
"AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 336.561 591.45 0.0) (11
672.362 497.304 0.0) (210 0.0 0.0 1.0))
Now, let's create the exdata that we want to add to the entity:
(setq thedata '((-3 ("AFRALISP" (1000 . "Kenny is handsome")
(1000 . "And intelligent"))))
Append it to the entity data list:
(setq newlist (append oldlist thedata))
Now, update the entity:
(entmod newlist)
We have now attached the xdata to the entity. To retrieve it we would type this:
(setq elist (entget (car (ensel)) '("AFRALISP")))
This would return the modified entity list. It should look something like this:
Select object: ((-1 . ) (0 . "LINE") (5 . "271") (100 .
"AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 336.561 591.45 0.0) (11
672.362 497.304 0.0) (210 0.0 0.0 1.0) (-3 ("AFRALISP" (1000 . "Kenny is
handsome") (1000 . "And intelligent"))))
To retrieve the xdata we would type this:
(setq exlist (assoc -3 elist))
This gets the xdata list from the entity list.
(-3 ("AFRALISP" (1000 . "Kenny is handsome") (1000 . "And intelligent")))
To retrieve the xdata itself we would type this:
(setq thexdata (car (cdr exlist)))
Now, we should have this:
("AFRALISP" (1000 . "Kenny is handsome") (1000 . "And intelligent"))
We now have an ordinary list. Because we created the xdata list, and we know in what order we created it, it's
very simple to retrieve each individual part:
(setq data1 (cdr (nth 1 thexdata)))
(setq data2 (cdr (nth 2 thexdata)))
This should return:
"Kenny is handsome"
"And intelligent"
This, of course, is a factual statement.
On the next page we will have a look at a practical example using Xdata.
Come on, don't be scared..............
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Extended Entity Data Page I
http://www.afralisp.com/lispa/lisp21.htm (2 of 3) [23/03/2005 05:52:15 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Extended Entity Data Page I
http://www.afralisp.com/lispa/lisp21.htm (3 of 3) [23/03/2005 05:52:15 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Extended Entity Data - Page II
We are now going to write an application that attaches, as Extended Entity Data, bolt details to
holes in a drawing. The details we will store will be Bolt Size, Bolt Length and Bolt Grade. We
will design a dialogue box to enter this data.
If no data has been attached, the application will firstly attach some default data and then allow
you to edit this. If data has been already attached, it will display this data and then allow you to
change it, if you so wish.
Let's look at the Dialogue Box Coding first:
exbolt : dialog { //dialog name
label = "Bolt Details"; //give it a label
: boxed_row { //start boxed row
label = "Choose Size and Length"; //give it a label

: popup_list { //define list box
key = "sel1"; //give it a name
} //end list
: popup_list { //define list box
key = "sel2"; //give it a name
} //end list
} //end boxed row
: boxed_radio_row { //start boxed radio row
label = "Choose Grade"; //give it a label
: radio_button { //define radio button
key = "rb1"; //give it a name
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (1 of 8) [23/03/2005 05:52:16 p.m.]
label = "4,6"; //give it a label
} //end radio button
: radio_button { //define radio button
key = "rb2"; //give it a name
label = "8,8"; //give it a label
} //end radio button
: radio_button { //define radio button
key = "rb3"; //give it a name
label = "H.S.F.G."; //give it a label
} //end radio button
} //end boxed radio row
ok_cancel ; //predifined OK/Cancel

} //end dialog
And now the AutoLisp code:
(defun c:exbolt ( / )
;define function
(setvar "cmdecho" 0)
;switch off command echo
(prompt "\nSelect the Hole to Add/Modify Xdata : ")
;prompt the user

(setq e (entget (car (entsel)) '("AFRALISP")))
;get the associative code list
(setq e1 (assoc -3 e))
;get the xdata
(if (not e1)
;if there is no exdata
(progn
;do the following
(if (not (tblsearch "APPID" "AFRALISP"))
;check if the application has been registered

(regapp "AFRALISP")
;if not, register it
);if
(setq e1 '((-3 ("AFRALISP"
(1000 . "3")
(1000 . "3")
(1000 . "8,8")
))))
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (2 of 8) [23/03/2005 05:52:16 p.m.]
;create a default xdata list

(setq e (append e e1))
;append to to the main list
(entmod e)
;modify the entity

);progn

);if

(setq e2 (assoc -3 e))
;get the code -3 list
(setq e3 (car (cdr e2)))
;get the exdata list

(setq SIZ (cdr (nth 1 e3)))
;get the bolt size index number
(setq SIZ1 (cdr (nth 2 e3)))
;get the bolt length index number
(setq gr (cdr (nth 3 e3)))
;get the bolt grade

(setq userclick T)
;set flag
(setq NAMES '("M6" "M8" "M10" "M12" "M16" "M20" "M24" "M30" "M36"))
;create list of bolt sizes

(setq LEN '("10" "15" "20" "25" "30" "35" "40" "45" "50" "55" "60"))
;create list of bolt lengths

(setq dcl_id (load_dialog "exbolt.dcl"))
;load dialogue
(if (not (new_dialog "exbolt" dcl_id)
;check for errors
);not
(exit)
;if problem exit
);if

(set_tile "sel1" SIZ)
;initilise list box
(set_tile "sel2" SIZ1)
;initilise list box
(start_list "sel1")
;start the list
(mapcar 'add_list NAMES)
;add the bolt size
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (3 of 8) [23/03/2005 05:52:16 p.m.]
(end_list)
;end the list
(start_list "sel2")
;start the list
(mapcar 'add_list LEN)
;add the lengths
(end_list)
;end the list
(cond
;on condition
((= gr "4,6") (set_tile "rb1" "1"))
;if GR 4,6 switch on radio button rb1
((= gr "8,8") (set_tile "rb2" "1"))
;if GR 8,8 switch on radio button rb2
((= gr "HSFG") (set_tile "rb3" "1"))
;if GR HSFG switch on radio button rb3
);end cond
(action_tile "rb1"
;if radio button rb1 selected
"(setq gr \"4,6\")"
;set grade of bolt
);action_tile
(action_tile "rb2"
;if radio button rb2 selected
"(setq gr \"8,8\")"
;set grade of bolt
);action_tile
(action_tile "rb3"
;if radio button rb3 selected
"(setq gr \"HSFG\")"
;set grade of bolt
);action_tile
(action_tile "cancel"
;if cancel selected
"(done_dialog)
;end dialog
(setq userclick nil)"
;set flag to nill
);action_tile
;if cancel set flag to nil
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (4 of 8) [23/03/2005 05:52:16 p.m.]
(action_tile "accept"
"(setq siz (get_tile \"sel1\"))
;get the bolt size
(setq siz1 (get_tile \"sel2\"))
;get the bolt length
(done_dialog)
;end the dialog
(setq userclick T)"
;set the flag to true
);action tile
(start_dialog)
;start the dialogue
(unload_dialog dcl_id)
;unload the dialogue
(if userclick
;if OK has been selected
(progn
;do the following
(setq NSIZ (cons 1000 SIZ))
;construct a new bolt size list
(setq NSIZ1 (cons 1000 SIZ1))
;construct a new bolt length list
(setq NGR (cons 1000 gr))
;construct a new bolt grade list
(setq e4 (chnitem NSIZ 2 e3))
;change the existing bolt size list
(setq e5 (chnitem NSIZ1 3 e4))
;change the existing bolt length list
(setq e6 (chnitem NGR 4 e5))
;change the existing bolt grade list
(setq e7 (subst e6 e3 e2))
;update list
(setq e8 (subst e7 e2 e))
;update list
(entmod e8)
;update the entity
(setq SIZ (nth (atoi SIZ) NAMES))
;get the size of the bolt from the list
(setq SIZ1 (nth (atoi SIZ1) LEN))
;get the length of the bolt from the list
(alert (strcat "The size of bolt is " SIZ "\n"
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (5 of 8) [23/03/2005 05:52:16 p.m.]
"The length of bolt is " SIZ1 "\n"
"The grade of bolt is " GR)
);alert
);end progn
);end if
(princ)
;finish cleanly
);end defun
;;This function replaces any element in a list with another element
;;It requires 3 parameters (chnitem value itemnumber list)
(defun chnitem (value num lst)
(setq num (- num 1))
(setq tmplt (list nil))
(setq tmplt2 (list nil))
(setq counter 0)
(repeat num
(setq tmplt (append tmplt (list (nth counter lst))))
(setq counter (+ counter 1))
)
(setq counter (+ counter 1))
(repeat (- (length lst) (+ num 1))
(setq tmplt2 (append tmplt2 (list (nth counter lst))))
(setq counter (+ counter 1))
)
(setq tmplt (cdr tmplt))
(setq tmplt2 (cdr tmplt2))
(setq lst (append tmplt (list value) tmplt2))
)
(princ)
;load cleanly
Draw a few circles representing holes on your drawing and run this application. Clever, hey!!
Now, let's write a routine that extracts this data from the drawing and saves it, in a space deliminating
format, to an external text file.
(defun C:exfile ()
;define the function
(setq NAMES '("M6" "M8" "M10" "M12" "M16" "M20" "M24" "M30" "M36"))
;create list of bolt sizes
(setq LEN '("10" "15" "20" "25" "30" "35" "40" "45" "50" "55" "60"))
;create list of bolt lengths
(setq fname (getstring "\nEnter file name: "))
;get the file name
(setq fn (open fname "w"))
;open it to write
(setq a (ssget "x" '((-3 ("AFRALISP")))))
;get all the bolt exdata in the drawing
(setq lg (sslength a))
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (6 of 8) [23/03/2005 05:52:16 p.m.]
;get the number of bolts
(setq i 0)
;set counter to zero
(repeat lg
;repeat for the number of entities with bolt xdata
(setq e (entget (ssname a i) '("AFRALISP")))
;get the entity list
(setq i (1+ i))
;increment the counter
(setq d (assoc -3 e))
;get the xdata list
(setq d1 (cdr (car (cdr d))))
;get just the xdata
(mapcar 'set '(SIZ SIZ1 GR) d1)
;put each of the lists into variables
(setq SIZ (cdr SIZ))
;get the index number of the bolt size
(setq SIZ (nth (atoi SIZ) NAMES))
;retrieve the bolt size from the master list
(setq SIZ1 (cdr SIZ1))
;get the index number of the bolt length
(setq SIZ1 (nth (atoi SIZ1) LEN))
;retrieve the bolt size from the master list
(setq GR (cdr GR))
;retrieve the bolt grade
(princ SIZ fn)
;print bolt size
(princ " " fn)
;print a space
(princ SIZ1 fn)
;print bolt length
(princ " " fn)
;print a space
(princ GR fn)
;print the bolt grade
(princ "\n" fn)
;print a new line
);end repeat
(close fn)
;close the file
(alert (strcat "Exported Details of\n"
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (7 of 8) [23/03/2005 05:52:16 p.m.]
(itoa lg)
" Bolts to file : \n"
(strcase fname))
);alert
;inform the user
(princ)
;finish cleanly
);end defun
(princ)
;load cleanly
As you can see, you can attach xdata to any type of entity, and attach all sorts
of different types of information.
Well, that's about it for now. If you would like the source coding for the applications written on this page,
then just click here.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Extended Entity Data Page II
http://www.afralisp.com/lispa/lisp211.htm (8 of 8) [23/03/2005 05:52:16 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
(mapcar) and (lambda).
As you know, LISP stands for "List Processing". There are quite a few commands in
AutoLisp that allow you to manipulate lists. (subst, append, etc.)
But what about commands that will allow you to apply a function to items in a list. Let's
look at (mapcar) first.
(mapcar).
The function (mapcar) allows you to perform a "function" on each element of the list.
Let's try a simple example :
What we want to do is add 1 to each element of a list.
(setq a 1)
(mapcar '1+ (list a))
This will return 2.
This is what happened :
(mapcar...adds 1 to the (list a) to make 2.
Now a longer list :
(setq a '(1 2 3 4 5 6 7 8 9 10))
(mapcar '1+ a)
This will return :
(2 3 4 5 6 7 8 9 10 11)
Just a few words on creating lists in AutoLisp.
There are two ways to create lists.
The first way is to use a command that will create a list.
Examples of this are (getpoint) and (entget).
Both of these commands will return a list.
Secondly, you could use the (list) command.
For example :
(setq a (list 1 2 3 4 5))
If you looked at variable a it would look like this :
(1 2 3 4 5)
The other way of writing this is :
(setq a '(1 2 3 4 5))
Both methods do the same thing, create a list.
Here is another example using (mapcar) :
Say you have a list of data stored in variable arglist
(setq arglist '(12.0 145.8 67.2 "M20"))
You want to place each item in the list in it's own variable to use in your routine. One way to do it
would be as follows :
Mapcar and Lambda
http://www.afralisp.com/lispa/lisp9.htm (1 of 4) [23/03/2005 05:52:18 p.m.]
(setq a (nth 0 arglist))
(setq b (nth 1 arglist))
(setq c (nth 2 arglist))
(setq d (nth 3 arglist))
This works, but is an extremely slow way of processing the data as each variable requires a
program statement.
A much more efficient way is to use the MAPCAR technique.
(mapcar 'set '(a b c d) arglist)
This routine maps the SET function to each element of the first list and it's corresponding element
of the second list. SET is used instead of SETQ to evaluate each quoted element of the first list.
With the currently set list c, it sets a to 12.0, b to 145.8, c to 67.2 and d to "M20".
If you are reading a list from an external file, your routine may not read back the elements of the
list as they once were. Your routine will read them back as strings. For example :
Your list should look like this :
(10 20 30 40 50)
But after reading the list in from the file, it looks like this :
("10" "20" "30" "40" "50")
You can use (mapcar) to convert the list from strings to integers :
(setq b (mapcar '(atoi) thelist))
Now this works fine if you are using an AutoLisp function, but how would you use (mapcar) with a
user defined function?
Let's look at this example :
What we have is a list of angles that we want to convert to Radians.
(setq c '(23.0 47.8 52.1 35.6))
Firstly we would write a function to convert degrees to radians.
(defun dtr (a)
(* pi (/ a 180.0))
)
Our function to convert our list would look like this :
(setq d (mapcar 'dtr c))
This function will run the (dtr) function against each element of list c.
In other words, the value of each element is passed to the (dtr) function.
The function could also be written like this :
(setq d (mapcar (quote dtr) c))
(lambda).
Now this is where the (lambda) function comes into play.
(lambda) allows you to write the (dtr) function "in-line" within the (mapcar) expression
without having to define a separate function.
(setq d (mapcar (quote (lambda (a) (* pi (/ a 180.0)))) c))
or
(setq d (mapcar '(lambda (a) (* pi (/ a 180.0))) c))
This function will convert all the angles in the list c to radians and store them in variable d.
Mapcar and Lambda
http://www.afralisp.com/lispa/lisp9.htm (2 of 4) [23/03/2005 05:52:18 p.m.]
Let's look a bit closer at the (lambda) function.
(lambda (a) (* pi (/ a 180.0)))
is the same as
(defun (a) (* pi (/ a 180.0)))
Let's write a function to test this :
(defun c:test ()
(setq c '(23.0 47.8 52.1 35.6))
(setq d (mapcar '(lambda (a) (* pi (/ a 180.0))) c))
(mapcar 'set '(w x y z) d)
(princ)
)
!c should return (23.0 47.8 52.1 35.6)
!d should return (0.401426 0.834267 0.909317 0.621337)
!w should return 0.401426
!x should return 0.834267
!y should return 0.909317
!z should return 0.621337
To quote the AutoCad Customization Manual :
"Use the (lambda) function when the overhead of defining a new function is not justified. It also
makes the programmer's intention more apparent by laying out the function at the spot where it is to be
used."
In practice, (lambda) can be used anywhere you need a speedy function and you don't want the
trouble of writing and making sure a (defun) function is loaded.

There are another two AutoLisp commands that can apply a function to a list.
They are (apply) and (foreach).
Let's have a quick look at them.
(apply)
This function differs from (mapcar) in that it applies a function to the whole list and not to
the individual items in the list.
Here's a couple of examples :
(apply '+ '(1 2 3))
This will return 6
(apply 'strcat '("a" "b" "c"))
This will return "abc"
You can also use (apply) in comjunction with (lambda) :
(apply '(lambda (x y z)
(* x (- y z))
)
'(5 20 14)
)
This will return 30 (20-14*5=30)
(foreach)
The syntax for this is :
Mapcar and Lambda
http://www.afralisp.com/lispa/lisp9.htm (3 of 4) [23/03/2005 05:52:18 p.m.]
(foreach name list expression.....)
This function steps through list, assigning each element to name, and evaluates each expression for
every element in the list.
For example :
(foreach n a (princ n) (terpri))
If you had a list :
(setq a (1 2 3 4 5))
The previous expression would print vertically :
1
2
3
4
5

Right, I don't know about you, but my brain is full.


Time for a couple of beers. Cheers for Now....

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Mapcar and Lambda
http://www.afralisp.com/lispa/lisp9.htm (4 of 4) [23/03/2005 05:52:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The 'Eval' Function.
'Eval' is another of the least seldom used, but very powerful, AutoLisp functions. It is
defined in the AutoCad Customization Guide as follows :
Eval - Returns the result of evaluating an AutoLisp expression.
Syntax : (eval expr)
For example, have a look at the following code segment :
(eval (ascii "A"))
Which simply means, Evaluate the expression (ascii "A").
This should return "65", the ASCII character code for "A".
Fine, I understand that, but where would I use it? Here's a simple example.
Say we had a whole lot of distances that we had to measure and then come up with an accumulative
total. We could measure each one, write it down, and then, manually add them up. Here's a better
way.
We are now going to write an AutoLisp routine that allows us to measure each distance, and then
return a total of all the distances. Here we will use the 'eval' function to perform the final total
calculation for us.
Here's the coding :
;Program to measure non-sequential distances
(Defun C:ADIST ( / dst dstlst adist)
;define the function and declare variables
(setq dstlst '(+ ))
;create list with plus
(while
;while a return is not entered
(setq dst (getdist "\nPick point or Return to exit: "))
;get the distance
(setq dstlst (append dstlst (list dst)))
;append the distance to the list
(setq adist (eval dstlst))
;calculate the running total

(setq dst (rtos dst 2 2))
;convert to string
(setq adist (rtos adist 2 2))
;convert to string
(princ (strcat "\nDistance = " dst " Accum Dist = " adist))
;display the distance and the running total
The 'Eval' Function.
http://www.afralisp.com/lispa/lisp44.htm (1 of 5) [23/03/2005 05:52:19 p.m.]
);end while
(prompt (strcat "\nTotal Distance = " adist))
;display the total distance
(princ)
;clean finish
);defun
(princ)
;clean loading
We start of the function by defining a list that only contains the '+' function.
The heart of the routine is nested in a 'while' loop. As long as the user keeps on adding distances,
the routine runs, but as soon as he hits a return, 'while' evaluates to nil and the loop is ended.
The first line within the loop simply gets the required distance. The second line
appends the distances to the list. Thirdly, we evaluate the list adding all of the
distances together. We then format the distance and the running total and display them to the user.
Once the user has finished selecting the distances, we display the final total. Simple really!!
Hint - Have you ever thought of building a macro recorder similar to that used
in Excel. By storing the users AutoCAD commands in a list along with the AutoLisp command
function, you could use the 'eval' function to 'playback' the list of commands. For example :
(setq lst '(command "circle" pt2 rad))
(eval lst)
Here's another example of using the (eval) function, but this time we'll use it to replace the (cond)
function.
The following coding is a small application that converts various values. It uses the (cond) function
to determine which radio button was selected and then uses that information to run the relevant
sub-routine.
First the DCL coding :
//DCL CODING STARTS HERE
conversion : dialog {
label = "Conversion" ;
: radio_button {
key = "rb1" ;
label = "&Inches to Millimetres" ;
value = "1" ;
}
: radio_button {
key = "rb2" ;
label = "&Millimetres to Inches" ;
}
: radio_button {
key = "rb3" ;
label = "M&iles to Kilometres" ;
}
: radio_button {
key = "rb4" ;
The 'Eval' Function.
http://www.afralisp.com/lispa/lisp44.htm (2 of 5) [23/03/2005 05:52:19 p.m.]
label = "&Kilometres to Miles" ;
}
: edit_box {
key = "eb1";
label = "Value";
value = "1.0";
}
ok_cancel ;
}
//DCL CODING ENDS HERE

Save this as "Conversion.dcl".
And now the AutoLisp Coding :
;AUTOLISP CODING STARTS HERE
(defun C:Conversion ()
(setq retval "IM")
(setq edval 1.0)
(setq dcl_id (load_dialog "conversion.dcl"))
(if (not (new_dialog "conversion" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(mode_tile "eb1" 2)
(action_tile "rb1" "(setq retval \"IM\")")
(action_tile "rb2" "(setq retval \"MI\")")
(action_tile "rb3" "(setq retval \"MK\")")
(action_tile "rb4" "(setq retval \"KM\")")
(action_tile
"accept"
(strcat
"(progn (setq edval (atof (get_tile \"eb1\")))"
"(done_dialog) (setq userclick T))")
);action tile
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
);action_tile
(start_dialog)

The 'Eval' Function.
http://www.afralisp.com/lispa/lisp44.htm (3 of 5) [23/03/2005 05:52:19 p.m.]
(unload_dialog dcl_id)
(if userclick
(cond
((= retval "IM") (IM edval))
((= retval "MI") (MI edval))
((= retval "MK") (MK edval))
((= retval "KM") (KM edval))
);cond

);if userclick
(alert (strcat "Value = " (rtos ans)))
(princ)
);defun
;-------------------------
(defun IM (val)
(setq ans (* val 25.4))
)
;-------------------------
(defun MI (val)
(setq ans (/ val 25.4))
)
;-------------------------
(defun MK (val)
(setq ans (* val 1.609344))
)
;-------------------------
(defun KM (val)
(setq ans (/ val 1.609344))
)
;-------------------------
(princ)
;AUTOLISP CODING ENDS HERE
Save this a "Conversion.lsp" then load and run it.
As you will see, it's just a simple little conversion routine.
Now replace these lines :
(cond
((= retval "IM") (IM edval))
((= retval "MI") (MI edval))
((= retval "MK") (MK edval))
((= retval "KM") (KM edval))
);cond
with this line :
((eval (read retval)) edval)
This one line replaces the whole of the (cond) section.
The 'Eval' Function.
http://www.afralisp.com/lispa/lisp44.htm (4 of 5) [23/03/2005 05:52:19 p.m.]
Cheers for now and happy evaluating........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The 'Eval' Function.
http://www.afralisp.com/lispa/lisp44.htm (5 of 5) [23/03/2005 05:52:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Redefining Commands.
Most AutoCAD users know that it is possible to undefine an AutoCAD command and then redefine
it to do something else. But, very few people seem to use this very useful feature. I find it very
handy to stop people changing system settings that divert from drawing office standards. Let's
have a look at an example of this.
Say we had a block inserted into the drawing that we did not want to be exploded because it
contains attributes. This is how we would go about using AutoLisp to undefine and then redefine
the 'Explode' command.
First, we would create an AutoLisp file called 'Redefs.Lsp'.
Then we would add the following coding :
(command "UNDEFINE" "EXPLODE")
'undefine the Explode command
After undefining the explode command we would then redefine it:
(defun C:EXPLODE ( / lst1 en typ)
(setq lst1 (list "DRGTITLE1" "DRGTITLE2"))
;list of block names that must NOT be exploded
;If you wish to add additional block names, and want an easy way to
;figure out which ones you screened for each release, use this line with
;your block names.
;(setq lst1 (append lst1 (list "DRGTITLE2" "DRGTITLE3" "DRGTITLE4")))
(setq en (car (entsel "\n Select block reference,
polyline, dimension, or mesh: ")))
;gets the block and mimics the explode prompt

(setq typ (entget en))
;get the entity data
(setq typ (cdr (assoc 2 typ)))
;get the block name
(if (member typ lst1)
;if the selected block name is a member of our list
(alert "\nThis Block Cannot be Exploded.
\n Refer to System Manager")
;inform the user

;if it is not
(progn
;do the following
(command ^c^c)
;cancel any commands
(command ".EXPLODE" en)
;explode the block
);progn
Redefining Commands.
http://www.afralisp.com/lispa/lisp46.htm (1 of 3) [23/03/2005 05:52:20 p.m.]
)
;if
(princ)
;finish clean
);defun
(princ)
;load clean
We would, of course, load Redefs.Lsp from our Acad.Lsp file to ensure that it would be available all of the
time. Just please note, that because this routine uses the 'Command' function, we would have to load it from
the S::STARTUP section of the Acad.Lsp file. It would look something like this :
(defun S::STARTUP ()
(prompt "\nAfraLisp Custom Utilities Loaded....\n")
(load "REDEFS" "\nREDEFS.LSP not found")
(princ)
);defun

I'll tell you what we'll do next. Let's create our own Drawing AutoSave.
First of all we need a way to check when a certain amount of time has elapsed. One of the simplest ways of
doing this is to use one of the commonest used commands as a trigger. We'll use the 'Line' command.
Add the following coding to Redefs.Lsp :
Firstly we need to undefine the 'Line' command:
(command "UNDEFINE" "LINE")
;undefine the Line command
The we need to redefine it:
(defun C:LINE ()
;define the function
(autosave)
;call the Autosave function
(command ".LINE")
;call the line command
(princ)
);defun
Next we need to write our Autosave function:
(defun AUTOSAVE ( / T1 ECC)
;define the function
(setq ECC (getvar "CMDECHO"))
;get the value of the CMDECHO system variable
(setvar "CMDECHO" 0)
;switch it off
(if (not T3) (setq T3 (getvar "TDUSRTIMER")))
;check if we have the value of the drawing timer
;if we haven't got it, then get it.
(if (not T2) (setq T2 (getreal "\nHow many minute between Saves ??: ")))
;check if we have an AutoSave time.
;if we haven't got it, then get it.
Redefining Commands.
http://www.afralisp.com/lispa/lisp46.htm (2 of 3) [23/03/2005 05:52:20 p.m.]
(setq T1 (getvar "TDUSRTIMER"))
;get the drawing timer again for comparison purposes.
(if (> (- T1 T3) (/ T2 60.0 24.0))
;compare the drawing timer values
(progn
;if it is time to save
(prompt "\nAutoSaving Drawing..Please Wait...... ")
;inform the user
(command "QSAVE")
;save the drawing
(setq T3 (getvar "TDUSRTIMER"))
;reset the timer
);progn
);if
(setvar "CMDECHO" ECC)
;reset CMDECHO
(princ)
);defun
The first time you select the Line command, this function will ask you for an interval between saves. From
then on, every time you use the Line command the function will check to see if you have exceeded the time
interval. If you haven't, it will do nothing. But if you have, it will first inform you, and then save your
drawing. Handy little thing, Hey...
To download source coding for Redefs.lsp Click Here. (1Kb)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Redefining Commands.
http://www.afralisp.com/lispa/lisp46.htm (3 of 3) [23/03/2005 05:52:20 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Efficient Variables.
Every variable used in an AutoLisp routine uses up system resources. You've probably been advised
before now, not to use too many SETQ's. LISP, itself was originally a functional language, without any
variables. Here is a typical example of how we all go about collecting the values required for our routines.
(setq "oldecho" (getvar "CMDECHO"))
(setq "oldhigh" (getvar "HIGHLIGHT"))
(setq "oldsnap" (getvar "OSMODE"))
(setq pt1 (getpoint "\Enter First Point : "))
(setq pt2 (getpoint "\Enter Second Point : "))
(setq thk (getdist "\Enter Thickness : "))
(setq qty (getint "\Enter Number Required : "))
Programmatically, there is nothing wrong with this coding, except that seven (7) variables are used, each of which takes
up system resources. As well as this, each variable will need to be declared as Local to prevent a scattering of loose
variables all over the place.
A much better way of storing your variables is to place them in a list.
Here's one way of doing this :
(setq AList (append (list (getvar "CMDECHO")) AList))
(setq AList (append (list (getvar "HIGHLIGHT")) AList))
(setq AList (append (list (getvar "OSMODE")) AList))
(setq AList (append (list (getpoint "\Enter First Point : ")) AList))
(setq AList (append (list (getpoint "\Enter Second Point : ")) AList))
(setq AList (append (list (getdist "\Enter Thickness : ")) AList))
(setq AList (append (list (getint "\Enter Number Required : ")) AList))
If we ran this sequence of coding, the variable AList would contain something
like this :
(5 10.0 (660.206 391.01 0.0) (411.014 548.932 0.0) 32 1 0)
Now this is a lot better. Every variable stored in one list and only one variable to declare. To retrieve any of the values,
we would simply do the following :
(setvar "OSMODE" (nth 4 AList))
Efficient Variables
http://www.afralisp.com/lispa/lisp55.htm (1 of 5) [23/03/2005 05:52:21 p.m.]
This, of course would return 32, the value of the Snap that we previously saved.
The problem with this though, is remembering which value belongs to what. To achieve this we would need to keep
track of the order in which we passed the values to our list.
Wouldn't it be great if we could pass a label along with each value so that we could easily retrieve the value by just
quoting the label.
By using 'Associative Lists' we can do just that. Have a look at this :
(setq AList (append (list (cons "OLDECHO" (getvar "CMDECHO"))) AList))
(setq AList (append (list (cons "OLDHIGH" (getvar "HIGHLIGHT"))) AList))
(setq AList (append (list (cons "OLDSNAP" (getvar "OSMODE"))) AList))
(setq AList (append (list (cons "PT1" (getpoint "\Enter First Point : "))) AList))
(setq AList (append (list (cons "PT2" (getpoint "\Enter Second Point : "))) AList))
(setq AList (append (list (cons "THK" (getdist "\Enter Thickness : "))) AList))
(setq AList (append (list (cons "QTY" (getint "\Enter Number Required : "))) AList))
This coding would return something like this :
(("QTY" . 6) ("THK" . 12.0) ("PT2" 809.113 523.118 0.0) ("PT1" 356.314 646.115 0.0)
("OLDSNAP" . 32) ("OLDHIGH" . 1) "OLDECHO" 0)
Now, to retrieve any value from this list, irrespective of it's position in the list, we would simply do something like this :
(setvar "OSMODE" (cdr (assoc "OLDSNAP" AList)))
This, again would return 32.
Now, by converting the construction of the list, and the retrieving of values from the list, into functions, we have an
elegant and sophisticated way of storing our variables in an efficient and practical manner. Following, is an AutoLisp
routine that can be used, with just a wee bit of modification, in any situation to make the storage of your variable much
more efficient :
(defun c:efflist ( / AnItem item MainList)
(setq AnItem (getvar "OSMODE"))
;get the snap setting
(AList "OLDSNAP" AnItem)
;add it to the list
(setq AnItem (getvar "HIGHLIGHT"))
;get the highlight setting
(AList "OLDHIGH" AnItem)
;add it to the list
(setq AnItem (getvar "CMDECHO"))
Efficient Variables
http://www.afralisp.com/lispa/lisp55.htm (2 of 5) [23/03/2005 05:52:21 p.m.]
;get the command echo setting
(AList "OLDECHO" AnItem)
;add it to the list
(setvar "Osmode" 32)
;reset snap to intersection
(setvar "Highlight" 0)
;switch off highlight
(setvar "Cmdecho" 0)
;switch off command echo
(setq AnItem (getpoint "\nSelect First Point : "))
;get the first point
(AList "FirstPoint" AnItem)
;add it to the list
(setq AnItem (getpoint AnItem "\nSelect Second Point : "))
;get the second point
(AList "SecondPoint" AnItem)
;add it to the list
(setq AnItem (getpoint AnItem "\nSelect Third Point : "))
;get the third point
(AList "ThirdPoint" AnItem)
;add it to the list
(setq AnItem (getpoint AnItem "\nSelect Fourth Point : "))
;get the fourth point
(AList "FourthPoint" AnItem)
;add it to the list
(command "Line" (RList "FirstPoint")
(RList "SecondPoint")
(RList "ThirdPoint")
(RList "FourthPoint")
Efficient Variables
http://www.afralisp.com/lispa/lisp55.htm (3 of 5) [23/03/2005 05:52:21 p.m.]
"C"
)
;retrieve all the point values and draw the shape
(setvar "OSMODE" (RList "OLDSNAP"))
;retrieve and reset snap
(setvar "HIGHLIGHT" (RList "OLDHIGH"))
;retrieve and reset highlight
(setvar "CMDECHO" (RList "OLDECHO"))
;retrieve and reset command echo
(princ)
);defun
;This function constructs the list and adds it to the main list
(defun AList (Name Val)
(setq item (list (cons Name Val)))
;construct list
(setq MainList (append item Mainlist))
;add it to the main list
);defun
;This function retrieves the values from the main list
(defun RList (TheName)
(cdr (assoc TheName MainList))
;retrieve value from list
);defun
(princ)
After running this routine, the value of the variable MainList would look something like this :
(("FourthPoint" 456.598 514.007 0.0) ("ThirdPoint" 676.92 293.827 0.0)
("SecondPoint" 1030.95 526.155 0.0) ("FirstPoint" 576.636 732.669 0.0)
("OLDECHO" . 0) ("OLDHIGH" . 1) ("OLDSNAP" . 32))

Efficient Variables
http://www.afralisp.com/lispa/lisp55.htm (4 of 5) [23/03/2005 05:52:21 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Efficient Variables
http://www.afralisp.com/lispa/lisp55.htm (5 of 5) [23/03/2005 05:52:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
The "Dir" Command
Note: Before proceeding with this tutorial, ensure that the following is set correctly within your
Acad.pgp file (AutoCAD Program Parameters File.)
DIR, DIR, 1,File specification: ,
You will find the "DIR" parameters under the "Examples of external commands for command
windows" section within your Acad.pgp file.
The Acad.pgp file can normally be found within your AutoCAD Support directory.
eg. C:/Program Files/Autocad 2002/Support/Acad.pgp.
You can simply open and edit this file using Notepad.
The "DIR" command is a DOS (remember that dark place) command that displays a list of
a directories files and subdirectories. But did you know that you can use the "DIR"
command from within AutoLisp? This is a great function for obtaining a list of files in a
directory, especially useful for Batch Processing Routines.
Let's have a look at it. Fire up AutoCAD and type this at the Command prompt :
Command: (command "dir" "*.* > Temp.txt")
What this statement is asking for is a directory listing of all the files in the current directory output
to the file Temp.txt.
Now open Temp.txt and you should have something like this :
Volume in drive O has no label
Directory of O:\E51D\E51D1
. <DIR> 09-11-99 3:13p .
.. <DIR> 09-11-99 3:13p ..
9961 DXF 345,167 08-05-99 12:14p 9961.DXF
9962 DXF 8,246,298 08-05-99 12:14p 9962.DXF
Ant exe 701,121 08-05-99 11:36a Ant.exe
batchp1 exe 11,776 01-18-99 11:23a batchp1.exe
BATCHP1 EXE 13,312 01-19-99 8:19a BatchPurge.Exe
DCLTUT GIF 2,635 08-01-99 11:19p DCLTUT.GIF
debex <DIR> 07-28-99 7:04a debex
N1 dxf 245,702 08-02-99 3:23p N1.dxf
NAMDEB DXF 28,320,177 07-30-99 12:29p NAMDEB.DXF
projair dwg 120,055 07-06-99 3:11p projair.dwg
R12K471 DWG 421,118 07-02-99 10:28a R12K47646.dwg
sort dwg 125,471 07-26-99 1:17p sort.dwg
SORTER dwg 27,981 07-27-99 10:35a SORTER.dwg
temp <DIR> 09-11-99 3:13p temp
temp txt 0 09-11-99 3:13p temp.txt
test <DIR> 08-20-99 11:15a test
title dwg 99,381 08-02-99 2:30p title.dwg
truss1 dwg 84,382 07-09-99 11:13a truss1.dwg
truss2 dwg 88,296 07-09-99 11:13a truss2.dwg
uniglide dwg 205,715 07-19-99 9:09a uniglide.dwg
VALVE dwg 24,693 07-29-99 11:31a VALVE.dwg
18 file(s) 39,083,280 bytes
5 dir(s) 2,147,450,880 bytes free
The Dir command
http://www.afralisp.com/lispa/lisp56.htm (1 of 3) [23/03/2005 05:52:22 p.m.]
This is a listing of all the files and sub directories contained in your current working directory.
O.K. I know, it's not quite formatted the way we would want it to be.
So, let's use a couple "DIR" switches to format the file list the way that we would like it. Try this :
Command: (command "dir" " /b *.* >temp.txt")
That's better, we've now got just the file names. The /b switch limits the list to only file names.
Temp.txt should now look something like this :
9961.DXF
9962.DXF
Ant.exe
batchp1.exe
BatchPurge.Exe
DCLTUT.GIF
debex
N1.dxf
NAMDEB.DXF
projair.dwg
R12K47646.dwg
sort.dwg
SORTER.dwg
temp
temp.txt
test
title.dwg
truss1.dwg
truss2.dwg
uniglide.dwg
VALVE.dwg
Right, now retrieve just the DWG filenames :
Command: (command "dir" " /b *.dwg > temp.txt")
Temp.txt should now look something like this :
projair.dwg
R12K47646.dwg
sort.dwg
SORTER.dwg
title.dwg
truss1.dwg
truss2.dwg
uniglide.dwg
VALVE.dwg
That's it, we have now got our required file listing in the format that we require. The "DIR"
command has got a lot more switches that you can use to restrict your listings to whatever you
desire. I suggest you dust off one of your old DOS Reference Manuals and look "DIR" up.
Hint :
Would you like a listing of all the files in the current directory AND all sub-directories? Use the /s
switch :
Command: (command "dir" " /b/s *.dwg >temp.txt")
You should get a listing something like this :
O:\E51D\E51D1\projair.dwg
O:\E51D\E51D1\R12K47646.dwg
O:\E51D\E51D1\sort.dwg
O:\E51D\E51D1\SORTER.dwg
O:\E51D\E51D1\title.dwg
O:\E51D\E51D1\truss1.dwg
The Dir command
http://www.afralisp.com/lispa/lisp56.htm (2 of 3) [23/03/2005 05:52:22 p.m.]
O:\E51D\E51D1\truss2.dwg
O:\E51D\E51D1\uniglide.dwg
O:\E51D\E51D1\VALVE.dwg
O:\E51D\E51D1\test\SCANNEX1.dwg
O:\E51D\E51D1\test\SCANNEX2.dwg
O:\E51D\E51D1\test\SCANNEX3.dwg
O:\E51D\E51D1\test\SCANNEX4.dwg

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Dir command
http://www.afralisp.com/lispa/lisp56.htm (3 of 3) [23/03/2005 05:52:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Colours and Linetypes Bylayer.
Each layer in an AutoCAD drawing has a default colour and a default linetype. Thus, the term
"Bylayer" means that an object drawn on a particular layer has the default colour and linetype of
that layer.
You can, if you wish, change the colour and linetype of an object drawn on a layer to suit your
requirements. A good example of this is when dimensioning. Your dimensions reside on say layer
"Dim" which has a default color of "1" and a default linetype of "Continuous". The extension lines
though, are also on layer "Dim" but have a color of say "9". When you plot, colour "1" has a pen
width 0f 0.35mm but colour "9" has a pen width of 0.15mm which will plot out the extension lines
thinner.
Often though, you have to deal with a total mismatch of Layers, Colours and Linetypes and would
like to convert all objects back to their "Bylayer" default values. Let's have a look at how we would
go about this.
First of all, open a new, blank drawing and setup a Layer with the following properties :
Layer Name "2"
Layer Colour 2 - "Yellow"
Layer Linetype Dashed2
Now, draw a line on Layer "2" anywhere in the drawing then
enter the following :
Command: (setq sel (ssget)) Select the Line
Select objects: 1 found
Select objects: <enter>
<Selection set: 8>
Command: (setq entity (ssname sel 0))
<Entity name: 1838e10>
Command: (setq name (entget entity))
((-1 . <Entity name: 1838e10>) (0 . "LINE") (330 . <Entity name: 18388c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (100 .
"AcDbLine") (10 319.65 364.538 0.0) (11 338.809 500.026 0.0) (210 0.0 0.0 1.0))
We have just retrieved the entity list of the line object.
The DXF Group Code 8, is the layer name. Group Code 62 is the colour of the object, but where is
it?
Let's have a look for it. Type this :
Command: (setq layer (cdr (assoc 62 name)))
nil
It returns "nil". Hey Kenny, what's going here?
If an object is drawn on a layer using colour "Bylayer", no Group Code 62 exists as AutoCAD
already knows what colour to draw the object with.
O.K. let's mess AutoCAD around and change the colour :
Command: change
Select objects: 1 found
Select objects: <enter>
Specify change point or [Properties]: p
Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: c
Colours and Linetypes ByLayer
http://www.afralisp.com/lisp/clay.htm (1 of 5) [23/03/2005 05:52:23 p.m.]
Enter new color <ByLayer>: 4
Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: <enter>
Ha, take that you bounder. Let's look at the entity list again :
Command: (setq sel (ssget))
Select objects: 1 found
Select objects: <enter>
<Selection set: a>
Command: (setq entity (ssname sel 0))
<Entity name: 1838e10>
Command: (setq name (entget entity))
((-1 . <Entity name: 1838e10>) (0 . "LINE") (330 . <Entity name: 18388c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 4) (100 .
"AcDbLine") (10 319.65 364.538 0.0) (11 338.809 500.026 0.0) (210 0.0 0.0 1.0))
Hey, Group Code 62 has suddenly appeared in our list and tells us that the object is now colour 4!!!
Jeepers, AutoCAD is only clever.
But what happens if we want to change the line back to it's "Bylayer" colour and Linetype?
Have a look at the following :
Select the object :
Command: (setq sel (ssget))
Select objects: 1 found
Select objects: <enter>
<Selection set: 4>
Get it's name :
Command: (setq entity (ssname sel 0))
<Entity name: 1803610>
Retrieve the entity list :
Command: (setq name (entget entity))
((-1 . <Entity name: 1803610>) (0 . "LINE") (330 . <Entity name: 18030c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 4) (100 .
"AcDbLine") (10 275.439 544.206 0.0) (11 357.967 544.206 0.0) (210 0.0 0.0 1.0))
Get the layer name :
Command: (setq layer (cdr (assoc 8 name)))
"2"
Use "tblsearch" to get the layer default details :
Command: (setq layerinf (tblsearch "LAYER" layer))
((0 . "LAYER") (2 . "2") (70 . 0) (62 . 2) (6 . "DASHED2"))
Retrieve the "Bylayer" colour :
Command: (setq layercol (cdr (assoc 62 layerinf)))
2
Construct a new list and append it to the entity list
Command: (setq name (append name (list (cons 62 layercol))))
((-1 . <Entity name: 1803610>) (0 . "LINE") (330 . <Entity name: 18030c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 4) (100 .
"AcDbLine") (10 275.439 544.206 0.0) (11 357.967 544.206 0.0) (210 0.0 0.0 1.0)
(62 . 2))
Now modify the definition data of an object :
Command: (entmod name)
((-1 . <Entity name: 1803610>) (0 . "LINE") (330 . <Entity name: 18030c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 4) (100 .
"AcDbLine") (10 275.439 544.206 0.0) (11 357.967 544.206 0.0) (210 0.0 0.0 1.0)
(62 . 2))
And finally, update the object :
Colours and Linetypes ByLayer
http://www.afralisp.com/lisp/clay.htm (2 of 5) [23/03/2005 05:52:23 p.m.]
Command: (entupd entity)
<Entity name: 1803610>
Your line should have changed back to colour Yellow.
Let's check if our entity list has been change :
Command: (setq sel (ssget))
Select objects: 1 found
Select objects: <enter>
<Selection set: 6>
Command: (setq entity (ssname sel 0))
<Entity name: 1803610>
Command: (setq name (entget entity))
((-1 . <Entity name: 1803610>) (0 . "LINE") (330 . <Entity name: 18030c0>) (5 .
"95A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 2) (100 .
"AcDbLine") (10 275.439 544.206 0.0) (11 357.967 544.206 0.0) (210 0.0 0.0 1.0))
Yep, everything is hunky dory! Our entity list has been updated with the correct values.
Hey, this is great. Let's try the same thing, but this time with Linetypes.
Change your line to Linetype "CENTER2".
Command: CHANGE
Select objects: 1 found
Select objects: <enter>
Specify change point or [Properties]: P
Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: LT
Enter new linetype name <ByLayer>: CENTER2
Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: <enter>
Now let's change it back to it's "Bylayer" Linetype :
Command: (setq sel (ssget))
Select objects: 1 found
Select objects: <enter>
<Selection set: 4>
Command: (setq entity (ssname sel 0))
<Entity name: 17db268>
Command: (setq name (entget entity))
((-1 . <Entity name: 17db268>) (0 . "LINE") (330 . <Entity name: 17dacc0>) (5 .
"965") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 2) (6 ."CENTER2")
(100 . "AcDbLine") (10 170.804 532.425 0.0) (11 237.122 628.15 0.0)
(210 0.0 0.0 1.0))
Command: (setq layer (cdr (assoc 8 name)))
"2"
Command: (setq layerinf (tblsearch "LAYER" layer))
((0 . "LAYER") (2 . "2") (70 . 0) (62 . 2) (6 . "DASHED2"))
This time select Group Code 6 for the default Linetype:
Command: (setq layerltype (cdr (assoc 6 layerinf)))
"DASHED2"
Command: (setq name (append name (list (cons 6 layerltype))))
((-1 . <Entity name: 17db268>) (0 . "LINE") (330 . <Entity name: 17dacc0>) (5 .
"965") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 2) (6 ."CENTER2")
(100 . "AcDbLine") (10 170.804 532.425 0.0) (11 237.122 628.15 0.0)
(210 0.0 0.0 1.0) (6 . "DASHED2"))
Command: (entmod name)
((-1 . <Entity name: 17db268>) (0 . "LINE") (330 . <Entity name: 17dacc0>) (5 .
"965") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "2") (62 . 2) (6 ."CENTER2")
Colours and Linetypes ByLayer
http://www.afralisp.com/lisp/clay.htm (3 of 5) [23/03/2005 05:52:23 p.m.]
(100 . "AcDbLine") (10 170.804 532.425 0.0) (11 237.122 628.15 0.0)
(210 0.0 0.0 1.0) (6 . "DASHED2"))
Command: (entupd entity)
<Entity name: 17db268>
Now, is that not interesting? Let's put it into practice. Open Notepad and paste this coding into it,
saving it as "ColorToLayer.Lsp" :
;CODING BEGINS HERE
(defun c:ColorToLayer ()
;clear the loop control variables
(setq i 0 n 0)
;prompt the user
(prompt "\n Select entities to analyze ")
;get the selection set
(setq sel (ssget))
;get the number of objects
(setq n (sslength sel))
;start the loop
(repeat n
;get the entity name
(setq entity (ssname sel i))
;now get the entity list
(setq name (entget entity))
;if not Bylayer
(if (not (assoc 6 name))
;do the following
(progn
;retrieve the layer name
(setq layer (cdr (assoc 8 name)))
;get the layer data
(setq layerinf (tblsearch "LAYER" layer))
;extract the default layer colour
(setq layercol (cdr (assoc 62 layerinf)))
;construct an append the new list
(setq name (append name (list (cons 62 layercol))))
;update the entity
(entmod name)
;update the screen
(entupd entity)
);progn
);if
;increment the counter
(setq i (1+ i))
;loop
);repeat
(princ)
Colours and Linetypes ByLayer
http://www.afralisp.com/lisp/clay.htm (4 of 5) [23/03/2005 05:52:23 p.m.]
);defun
(princ)
;CODING END HERE
You can easily write coding that will do exactly the same for Linetypes and even incorporate the
two if you wish.
You could even take it a step further and develop a fully fledged Layer Mapping Application
Manager. Makes you think doesn't it?
No, I haven't forgotten! The source coding is here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Colours and Linetypes ByLayer
http://www.afralisp.com/lisp/clay.htm (5 of 5) [23/03/2005 05:52:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Debugging
Screams, intermittent yells and bangs, kid's and dogs cowering in the corner. What is going on?
Have I gone nuts? Have I finally cracked and lost my mind?
No, it's just me trying to debug my latest program. Go on laugh, but I'll guarantee we've all done it,
and we'll all do it again.
Debugging can be a real pain. "But it worked just now!" "Why did it crash?" "The coding looks
perfect. I've checked it line by line 23 times." "There must be something wrong with my
computer."
This tutorial will start off by showing you some of the more common AutoLisp bugs that I've come
across, and then show you a couple of things to assist you in your debugging efforts. Let's start with
some common bugs.
The simplest and most common is yourself. I don't know if you are aware of the fact that most
programming errors occur between the seat and the keyboard. Yes, sad but true. So, how do we fix
you up? A couple of tips :
Don't program or debug when you're tired. Walk away from it. Have a break, go shopping.
You'll be amazed at how a break from a program clears the mind.
G
Very rarely will it be a computer or system bug. 99.99999 times out of a hundred, it's YOU. G
The computer or any other sinister source will not change your program coding or the
variable values therein. YOU DO.
G
The second type of bug is the syntax bug. A syntax bug is where the command is in error. For
example when you've miss-spelt an AutoLisp function or command. e.g. (setq ang1 (angl pt1 pt2))
This is normally quite easy to spot and rectify as AutoLisp will not recognise the command and
your program will stop.
Another VERY common syntax bug is naming variables after an AutoLisp function or command.
The most common? Angle and T ( angle and t ). I must have seen these two used as variables a
thousand times. Length (length) is another very common one.
The third type of bug is the logical bug. Now this little beastie has numerous faces and comes in all
shapes and forms.
The simplest form is when you pass incorrect information to a function.
(setq ang (angle pt1 pt2))
But what happens if pt1 is nil. Crash!!
Another good example is trying to pass string values to a function that expects numbers. (and
vice-a-versa.)
Again, Crash!! Check your variable values and data types.
To check if a variable is a list, you can use the (type) command, which returns a variable type. But
since a list is not a string you must test it :
( if ( = ( eval v ) LIST) . . .
You could also use (listp) to see whether a variable is a list :
( if ( = T ( listp a ) ) . . .
(listp) returns T if it is a list and nil if it isn't.
Debugging
http://www.afralisp.com/lisp/debug.htm (1 of 5) [23/03/2005 05:52:25 p.m.]
To test whether a variable is a number, use the same test as earlier but test for REAL or INT. You
can also use (numberp), which works the same as (listp) on lists. If the variable is a real number or
an integer, it returns T. If not, it returns nil.
To test for a positive or negative number use (minusp). This returns T if a number is negative and
nil if it is positive.
Oh, and before I forget, another good example of wrong data types is confusing radians with
degrees. AutoLisp functions use radians, AutoCAD commands expect degrees.
Loops are another area that seem extremely susceptible to attracting bugs. Have a look at this :
(while flag
(+ cntr 1)
(program statements here)
( if ( = cntr 5)
(setq flag nil)
);if
);while
What is supposed to happen here is that the program will loop until flag is set to nil. cntr is
supposed to be incremented by one at each loop. But, as you can see from this coding, (at least I
hope you can see), cntr will never reach the value of 5. It will always be equal to 1. The correct
coding should be :
(setq cntr (+ cntr 1))
System variables can also create untold problems, especially Snaps. Switch them On only when you
need them and Off once finished or you'll find yourself snapping to some weird and wonderful
parts of your drawing.
And please remember the golden rule. "Reset the system back to the way you found it." Before
changing system variables, save their existing values then reset them back at the end of your
program. And don't forget to to include these settings in your error traps so that if something
untoward does happen, your error trap will reset them back to their original values.
Now let's have a quick look at some DCL coding bugs.
Have a look at the first one :
(action_tile "cancel" "(done_dialog) (setq bryt 1) (exit)")
I was told that every time the user clicked the "Cancel" button, AutoCAD would freeze. Any idea
why? The second example has a similar error :
(action_tile
"accept"
"(progn
(setq rimel (get_tile \"ebrim\"))
(setq maxel (get_tile \"ebmax\"))
(done_dialog) (setq flag T) (cutt))"
)
The answer to both examples is that they were trying to call a function (exit) and (cutt) from
within a dialog.
In other words, the dialog was still open when they called the function.
An easy error to make and one to look out for.
Debugging
http://www.afralisp.com/lisp/debug.htm (2 of 5) [23/03/2005 05:52:25 p.m.]
Please everybody, be careful out there!
Now we'll look at a couple of handy ideas for making your debugging a little be easier.
When writing an AutoLisp routine it's quite handy to have the program stop if it encounters an
error. It's also nice to be able to view the variables whilst the program is running to ensure that
they contain the correct values.
In Visual Lisp and Visual Basic you can insert "breakpoints" into your coding that do just that and
use the Watch window to check on their values. If you are not using Visual Lisp or Visual Basic
this can still easily be accomplished. Place the following statement within your coding where you
would like your program to stop :
(setq bp (getstring))
This statement will stop your program and only continue once you hit the space bar.
To print the variables, put a (princ) statement to print the variable before the break point.
(princ variablename)
(setq bp (getstring))
Do remember to remove your print statements and breakpoints on completion of debugging.
You could if you wish turn this little trick into a sub function. This would be quite handy if you
have a large program and can foresee a lot of debugging. Have a look at this small AutoLisp routine
that changes an objects colour to "Bylayer."
;CODING BEGINS HERE
(defun c:clay ()
;clear the loop control variables
(setq i 0 n 0)
;prompt the user
(prompt "\n Select entities to analyze ")
;get the selection set
(setq sel (ssget))
;get the number of objects
(setq n (sslength sel))
;start the loop
(repeat n
;get the entity name
(setq entity (ssname sel i))
;now get the entity list
(setq name (entget entity))
;retrieve the layer name
(setq layern (cdr (assoc 8 name)))
;get the layer data
(setq layerinf (tblsearch "LAYER" layern))
;extract the default layer colour
(setq layercol (cdr (assoc 62 layerinf)))
Debugging
http://www.afralisp.com/lisp/debug.htm (3 of 5) [23/03/2005 05:52:25 p.m.]
(bpt)
(setq bp (getstring))
;construct an append the new list
(setq name (append name (list (cons 62 layercol))))
;update the entity
(entmod name)
;update the screen
(entupd entity)
;increment the counter
(setq i (1+ i))
;loop
);repeat
(bpt)
(setq bp (getstring))
(princ)
);defun
(defun bpt ()
(princ i)
(princ "\n")
(princ n)
(princ "\n")
(princ sel)
(princ "\n")
(princ layern)
(princ "\n")
(princ layercol)
(princ "\n")
(princ i)
);defun
(princ)
;CODING END HERE
I included a sub routine that simply stops the program and lists the values of selected variables at
two places, one within the loop and one at the end of the program. This way you can easily track the
value of the variables whilst your program is in progress. You could even include this type of
breakpoint function within your error trap whilst debugging.
Another good trick is to always make your variables "global" at the beginning of a program. If you
make them "local", they may have no value at the end of the program and you won't be able to see
what was in them. The same as for the breakpoints, remember to declare your variables as "local"
after debugging.
Leaving your variables "global" can though, create it's own problems whilst debugging. You run
various programs that use the same variable names and suddenly you find your variables
Debugging
http://www.afralisp.com/lisp/debug.htm (4 of 5) [23/03/2005 05:52:25 p.m.]
"tripping" all over themselves. This can be difficult to find as sometimes your program runs
perfectly well and the next minute Crash!! Look out for this one.
I also found this little tit bit at AcadX, which I'm sure they won't mind me sharing with you.
Prior to A2K, AutoLisp would dump a bug trace to the command line when an error was
encountered.
While developers went out of their way to suppress this behavior in a released product, it was a
handy tool during the debugging cycle. To get that same behavior in A2K, replace the standard
error handler with this one:
(defun errdump (s)
(vl-bt)
(princ)
)
Oh, and one more thing! Please remember the power of your eyes. Watch the screen as your
program runs. You can pick up a lot of clues from watching what happens to entities whilst your
program runs.
Well, that's it for debugging. I hope this helped you and didn't leave you even more frustrated than
before.
Remember, test, test, test and test.
If you would like to know how "NOT" to write your AutoLisp coding,
then check this out.
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Debugging
http://www.afralisp.com/lisp/debug.htm (5 of 5) [23/03/2005 05:52:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Dictionaries and XRecords.
Written by Stig Madsen.
(Published here on AfraLisp with kind permission)
Since the dawn of times we've had at least 10 options to save private data with an AutoCAD drawing. Those
were and are the system variables USERI1-5 and USERR1-5 that holds integers and real numbers,
respectively. The idea is OK but the variables are exposed for everyone to use and you shouldn't assume
that your private data will stay intact.
Somewhere around release 10 came XData (Extended Entity Data) which is a rather clever invention. With
XData you can attach intelligent information to entities, and it works flawlessly. There aren't really
drawbacks to the technique, but there are limitations that has to do with the amount and type of data you
can attach.
During release 13 new forms of entities hit the deck in order to keep and maintain all sorts of data. Among
those were Dictionaries and XRecords. Like XData, Dictionaries can be attached to any kind of entity and
you can even attach XData to them. Additionally, with Dictionaries/Xrecords you can tell the drawing itself
to keep your data because the drawing maintains a dictionary in which you can save all the data you want.
So what is a Dictionary and how does it work? Instead of lengthy explanations, it'll be much easier to look
at one of the many Dictionaries that AutoCAD itself uses. Later we''ll briefly look at how to make our own
simple Dictionary, add an Xrecord to it and save them both with the drawing.
So, fire up AutoCAD and pay attention. As mentioned, the drawing maintains a Dictionary that is always
present. This is known as the 'named object dictionary' (although I prefer the term 'main dictionary'). In
VBA lingo it's a collection object and like all other collections it just holds a series of other objects. In VBA
it is accessed through the document object and in AutoLISP it's accessed by one function only,
NAMEDOBJDICT:
Command: (setq mainDict (namedobjdict))
<Entity name: 16a9860>
Command: (entget mainDict)
((-1 . <Entity name: 16a9860>) (0 . "DICTIONARY")
(330 . <Entity name: 0>) (5 . "C") (100 . "AcDbDictionary")
(280 . 0) (281 . 1) (3 . "ACAD_GROUP")(350 . <Entity name: 16a9868>)
(3 . "ACAD_LAYOUT") (350 . <Entity name: 16a98d0>)
(3 . "ACAD_MLINESTYLE") (350 . <Entity name: 16a98b8>)
(3 . "ACAD_PLOTSETTINGS") (350 . <Entity name: 16a98c8>)
(3 . "ACAD_PLOTSTYLENAME") (350 . <Entity name: 16a9870>))
By looking at the entity list of the main Dictionary, the most important thing about Dictionaries becomes
clear: they are complete entities by themselves. They are not fragments of data attached to other entities
like XData are.
However, the Dictionary itself is not where you will store your raw data, - it is merely a container for other
objects that in turn can hold the data. The main dictionary above shows 5 such objects. Its components are
given by a unique name in group 3. Corresponding entity names are given by groups 350 that follow, but
when referencing an object in a Dictionary it should be done by name only. For example, to reference the
"ACAD_MLINESTYLE" object, use DICTSEARCH:
Command: (setq mlineDict (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
((-1 . <Entity name: 16a98b8>) (0 . "DICTIONARY") (5 . "17")
(102 . "{ACAD_REACTORS") (330 . <Entity name: 16a9860>) (102 . "}")
(330 . <Entity name: 16a9860>) (100 . "AcDbDictionary") (280 . 0)
(281 . 1) (3 . "Standard") (350 . <Entity name: 16a98c0>))
Dictionaries and XRecords
http://www.afralisp.com/lisp/dict.htm (1 of 5) [23/03/2005 05:52:26 p.m.]
This member of the main Dictionary is a Dictionary itself. It holds all the mline styles that are available.
Any style that is created with MLSTYLE is added to the "ACAD_MLINESTYLE" Dictionary. To explore
a specific style we have to dig deeper and because we are dealing with Dictionaries we can use
DICTSEARCH again - this time by searching the recently returned Dictionary:
Command: (setq mlineStd (dictsearch (cdr (assoc -1 mlineDict)) "Standard"))
((-1 . <Entity name: 16a98c0>) (0 . "MLINESTYLE") (5 . "18")
(102 . "{ACAD_REACTORS") (330 . <Entity name: 16a98b8>) (102 . "}")
(330 . <Entity name: 16a98b8>) (100 . "AcDbMlineStyle") (2 . "STANDARD")
(70 . 0) (3 . "") (62 . 256) (51 . 1.5708) (52 . 1.5708) (71 . 2) (49 . 0.5)
(62 . 256) (6 . "BYLAYER") (49 . -0.5) (62 . 256) (6 . "BYLAYER"))
Now we are getting somewhere! All properties of the mline style "Standard" are exposed in all their glory.
Feel free to look up all properties in the DXF Reference. Want to change the color of multilines? Just
SUBSTitute group 62 and ENTMOD the style as usual:
Command: (entmod (subst (cons 62 2)(assoc 62 mlineStd) mlineStd))
((-1 . <Entity name: 16a98c0>) ..etc.. (62 . 2) ..etc.. (62 . 2) ..etc..)
Ok, so a Dictionary is a container that can hold a number of objects. Why not use existing structures like
symbol tables instead of complicating things? Many reasons, but two reasons come to mind. Symbol tables
are maintained by the people who implemented them and to expand them to hold every possible custom
object is not an option. Secondly, Dictionaries can be customized in a way that is not possible with symbol
tables, and that opens a range of possibilities only limited by imagination.
Dictionaries and XRecords go hand in hand. Like Dictionaries, XRecords are handled as named objects and
can be manipulated by the same functions that handle Dictionaries. In the following, we'll try to add our
own Dictionary to the main dictionary. We will also create an XRecord to hold various informations and
add it to our Dictionary.
When dealing with Dictionaries, at one point you will have to consider ownership. Which object is going to
own the Dictionary? Will it hold generic data for your application or will it hold data that is specific for
some entity or entities? In the first case you will probably use the main dictionary to save your data with the
drawing. If your application is maintaining data for linetypes, you will probably add an extension
dictionary to the linetype symbol table.
Whatever the ownership, the Dictionary is initially created without ownership and for that purpose we'll
use the function ENTMAKEX. It works like ENTMAKE, but it creates the entity without an owner - and it
returns an entity name instead of an entity list. Let's make a function that adds our own Dictionary to the
main dictionary. In this example we will name it "OUR_DICT":
(defun get-or-create-Dict (/ adict)
;;test if "OUR_DICT" is already present in the main dictionary
(if (not (setq adict (dictsearch (namedobjdict) "OUR_DICT")))
;;if not present then create a new one and set the main
;; dictionary as owner
(progn
(setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))
;;if succesfully created, add it to the main dictionary
(if adict (setq adict (dictadd (namedobjdict) "OUR_DICT" adict)))
)
;;if present then just return its entity name
(setq adict (cdr (assoc -1 adict)))
)
)
If you want to see what happens to the dictionary when added to an owner, then stop the routine right after
Dictionaries and XRecords
http://www.afralisp.com/lisp/dict.htm (2 of 5) [23/03/2005 05:52:26 p.m.]
ENTMAKEX and use ENTGET to investigate the newly created entity. Notice that the owner in group code
330 will not be specified. After using DICTADD the owner in group 330 will be the main dictionary.
Right now we have placed a Dictionary named "OUR_DICT" in the main dictionary. To check if it
succeeded we can investigate the main dictionary:
Command: (entget (namedobjdict))
((-1 . <Entity name: 16a9860>) (0 . "DICTIONARY") ..etc...
(3 . "ACAD_PLOTSTYLENAME") (350 . <Entity name: 16a9870>)
(3 . "OUR_DICT") (350 . <Entity name: 16a8da0>))
And there it is! But what good does it do us? It just sits there and doesn't hold any data. Well, let's say we
want to save data for a routine that creates annotations - for example a text style, a layer name and a text
height. Simple stuff, but it'll suffice for the purpose of illustration. With XRecords we can create an entity
that can hold any possible data within the range of defined data types. Unlike XData it uses regular group
codes to save data.
All group codes (except internal data like code 5 and the negative codes) can be used. Of course, the data
types that are defined for the specific group codes have to be respected. This means that, for example, a
code 70 cannot hold anything else than a 16-bit integer and so on. Code values can be examined in the DXF
Reference.
An XRecord is created in much the same way as a Dictionary. First we'll see if it already exists, then create
it without an owner with ENTMAKEX and lastly add it to our custom Dictionary. Again, we will name it in
order to retrieve it by name. In this example it will be called "OUR_DICT". Both name and initial values
are hardcoded into the function - in the real world we would probably make this a generic function and
specify name and values as arguments.
(defun get-or-make-Xrecord (/ adict anXrec)
(cond
;;first get our dictionary. Notice that "OUR_DICT" will be
;;created here in case it doesn't exist
((setq adict (get-or-create-Dict))
(cond
;;if "OUR_DICT" is now valid then look for "OUR_VARS" Xrecord
((not (setq anXrec (dictsearch adict "OUR_VARS")))
;;if "OUR_VARS" was not found then create it
(setq anXrec (entmakex '((0 . "XRECORD")
(100 . "AcDbXrecord")
(7 . "Arial")
(8 . "A09--T-")
(40 . 2.0)
)
)
)
;;if creation succeeded then add it to our dictionary
(if anXrec (setq anXrec (dictadd adict "OUR_VARS" anXrec)))
)
;;if it's already present then just return its entity name
(setq anXrec
(cdr (assoc -1 (dictsearch adict "OUR_VARS")))
)
)
)
)
)
Dictionaries and XRecords
http://www.afralisp.com/lisp/dict.htm (3 of 5) [23/03/2005 05:52:26 p.m.]
Now we have an XRecord that contains three different data: a text style name in group code 7, a layer name
in group code 8 and a text height in group code 40. All codes are chosen with respect to normal convention,
but any code that can be associated with the data type in question can be used. The structure from which to
access our data will now be like this:
Named object dictionary = Dictionary (owner = the drawing)
> OUR_DICT = Dictionary (owner = named object dictionary)
> OUR_VARS = Xrecord (owner = OUR_DICT)
(7 . "Arial") = Egenskab i Xrecord
(8 . "A09-T-") = Egenskab i Xrecord
(40 . 2.0) = Egenskab i Xrecord
The only thing that remains is to read the data:
(defun getvars (/ vars varlist)
;;retrieve XRecord "OUR_VARS" from dictionary "OUR_DICT"
;;which in turn calls both functions above
(setq vars (get-or-make-Xrecord))
;;if our Xrecord is found, then get values in group code 7, 8 and 40
(cond (vars
(setq varlist (entget vars))
(setq txtstyle (cdr (assoc 7 varlist)))
(setq txtlayer (cdr (assoc 8 varlist)))
(setq txtsize (cdr (assoc 40 varlist)))
)
;;otherwise return nil
(T nil)
)
)
Because of the naming scheme, Dictionaries work much like symbol tables in terms of accessing entries. In
addition to DICTSEARCH there's also a function, DICTNEXT, to iterate through all entries in a
Dictionary. It works like TBLNEXT - here shown by iterating through the main dictionary:
(defun C:LISTDICTS (/ maindict adict)
(setq maindict (namedobjdict))
(while (setq adict (dictnext maindict (not adict)))
(princ (cdr (assoc -1 adict)))
(princ (strcat "\t(type = " (cdr (assoc 0 adict)) ")\n")
)
)
(princ)
)
Command: listdicts
<Entity name: 185c0d0> (type = DICTIONARY)
<Entity name: 185f4b8> (type = DICTIONARY)
<Entity name: 185c0d8> (type = DICTIONARY)
<Entity name: 185f4a8> (type = ACDBDICTIONARYWDFLT)
<Entity name: 18c4320> (type = DICTIONARY)
<Entity name: 18c3d10> (type = XRECORD)
Dictionaries and XRecords
http://www.afralisp.com/lisp/dict.htm (4 of 5) [23/03/2005 05:52:26 p.m.]
There're also functions to rename a Dictionary, DICTRENAME, and to remove a Dictionary,
DICTREMOVE. The latter simply removes its entry from the owner, or in other words: detaches it from
the owner. It doesn't delete it unless the owner is "ACAD_GROUP" or "ACAD_MLINESTYLE".
Sometimes when updating a Dictionary it's easier to remove/delete it and replace it with a new entry, but
that will be for your pleasure to explore.
If you gained some understanding of Dictionaries and XRecords by now then I'll throw in a little
assignment: Figure out how you can add the XRecord directly to the main dictionary without first creating
a Dictionary!

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dictionaries and XRecords
http://www.afralisp.com/lisp/dict.htm (5 of 5) [23/03/2005 05:52:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Basic Tool System Primer
You need to be careful in your customizations of tools and tool palettes. Here are some basics...
Stock Tool Catalog (aka. Registered Tools)
In your C:\Documents and Settings\<Username>\Application Data\Autodesk\AutoCAD
2004\R16.0\enu\Support\RegisteredTools\ folder there is a file called: AcTpTools.atc. This is the catalog
of registered tools for the application. For AutoCAD I believe there are currently three tool types
(Hatch Tool, Block Tool, and the internal/unofficial Command Tool). ADT expands on this with about 30
different tool types.
When a new tool type is added to the system it will be added into the stock tool catalog and registered
with the system. Each app, including 3
rd
parties, will have their own stock tool catalog.
Here is what one of the stock tools in the AutoCAD stock catalog looks like:
<StockTool>
<ItemID idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>
<Properties>
<ItemName src="AcTpCatalogRes.dll" resource="185"/>
</Properties>
<Source idValue="59a63456-0025-4ea0-9cb2-608916d5177c"/>
<Object>
<ComClass>
<CLSID idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>
</ComClass>
<Module>
<File>AcTcTools.arx</File>
</Module>
</Object>
</StockTool>

ItemID: is a unique GUID for that tool type. Every instance of that tool type (e.g. Hatch Tool) will refer to
that stock tool by its GUID.
Properties: is that basic set of data you see when you look at the Tool Editor in the UI. In the above
case I believe the name of the tool type is in a resource dll for easy localization purposes, and then gets
created into the tool name you see for your locale. Of course when you manually rename a tool, that
name is saved instead for that instance. This dll also holds the default image for the tool.
The ComClass value is the GUID in your registry that points AutoCAD to the right dlls to actually run the
code for the tool.
Below is a typical stock tool from ADT. There are some similarities.
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (1 of 8) [23/03/2005 05:52:37 p.m.]
<!--AEC Door-->
<StockTool>
<ItemID idValue="6A56F31F-3F7B-4f8e-B10D-39433621B3C0"/>
<Properties>
<ItemName>Door</ItemName>
<Description>Creates a Door</Description>
</Properties>
<Object>
<ComClass>
<CLSID idValue="6A56F31F-3F7B-4f8e-B10D-39433621B3C0"/>
</ComClass>
</Object>
</StockTool>

Tool Instance
Every tool in the system is unique. When you copy a tool through the UI it will be assigned a unique
GUID, or Item ID. Be careful just blindly cutting and pasting xml to create new tools. Either do it
through the UI or get a hold of a GUID generator program.
As for the Stock Tools, the <Properties/> node contains all the basic tool info that you assign from the
Tool Editor. Only those elements that are actually in use are written out.
Each time you copy a tool through the UI a unique image is created in the form <tool type>_<Tool
GUID>.ext. Since the image is auto-generated from the tool data it is really just a visual expression of
that data. So, if you manually specify several tools to point to the same image, dont be surprised if
deleting one suddenly renders the others with a blank image. J
Image format: We chose to use PNGs because they have an alpha channel to support the tool images
having a transparent background. They are also a lossless compression format.
In the below example you will see how this tool instance refers to the StockTool. This is the same one
from above.
The <Data\> node is just that, all the data that you specify for that tool; in the example below it is all the
data to describe the solid fill Pantone hatch.

<Tool>
<ItemID idValue="{74CC8347-BEA2-46D7-B855-86700A2FD640}"/>
<Properties>
<ItemName>PANTONE 15-0525 TP</ItemName>
<Images>
<Image cx="32" cy="32" src="Images\Hatch
tool_8FC7645E-5F37-4200-8D7A-086354BBFB76.PNG"/>
<Image cx="64" cy="64" src="Images\Hatch
tool_8FC7645E-5F37-4200-8D7A-086354BBFB76 (1).PNG"/>
</Images>
<Description>Creates a solid fill hatch using PANTONE 15-0525 TP</Description>
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (2 of 8) [23/03/2005 05:52:37 p.m.]
<Time createdUniversalDateTime="2002-11-06T04:06:28"
modifiedUniversalDateTime="2002-11-06T04:06:28"/>
</Properties>
<Source/>
<StockToolRef idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>
<Data>
<GeneralProperties>
<Color>
<BasicPropInfo>
<PropValue unspecified="FALSE" valueType="2" value="0"/>
</BasicPropInfo>
<CreateInfo>
<AcCmColor mRGB="3266557304">
<ColorName>PANTONE 15-0525 TP</ColorName>
<BookName>PANTONE(R) a &amp; i-paper</BookName>
</AcCmColor>
</CreateInfo>
</Color>
<Layer>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
</Layer>
<Linetype>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
</Linetype>
<LinetypeScale>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="3" value="0"/>
</BasicPropInfo>
</LinetypeScale>
<PlotStyle>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (3 of 8) [23/03/2005 05:52:37 p.m.]
</PlotStyle>
<LineWeight>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="2" value="0"/>
</BasicPropInfo>
</LineWeight>
</GeneralProperties>
<Hatch>
<HatchType>Predefined</HatchType>
<PatternName>SOLID</PatternName>
<SourceFile>%INSTALL_DIR%\UserDataCache\Support\acad.pat</SourceFile>
<Angle>0</Angle>
<Scale>1</Scale>
<Spacing>1</Spacing>
<PenWidth>100</PenWidth>
<Double>0</Double>
<BlockExtent>0.5</BlockExtent>
</Hatch>
</Data>
</Tool>

Tool Palettes
Tool Palettes essentially have the same structure: a unique ItemID, a Properties node for the name/etc.,
and then all the tools contained on it.
<Palette>
<ItemID idValue="{EAAE2E08-02C4-4ABC-9B91-AF4C209CEAC9}"/>
<Properties>
<ItemName>General Drafting</ItemName>
<Images/>
<Description>This palette contains a sampling of basic 2D drafting tools</Description>
<Time createdUniversalDateTime="2002-11-06T21:45:34"
modifiedUniversalDateTime="2002-11-06T21:45:34"/>
</Properties>
<Source/>
<Tools>
<Tool>
<ItemID idValue="{2DDBB344-97D8-4085-84FD-1552F2F67430}"/>
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (4 of 8) [23/03/2005 05:52:37 p.m.]
<Properties>
<ItemName>PANTONE 8001 C</ItemName>
<Images>
<Image cx="32" cy="32" src="Images\Hatch
tool_FEDCC8B5-B55A-441D-8CA4-4720592B0494.PNG"/>
<Image cx="64" cy="64" src="Images\Hatch
tool_FEDCC8B5-B55A-441D-8CA4-4720592B0494 (1).PNG"/>
</Images>
<Description>Creates a solid fill hatch using PANTONE 8001 C</Description>
<Time createdUniversalDateTime="2002-11-06T04:06:28"
modifiedUniversalDateTime="2002-11-06T04:06:28"/>
</Properties>
<Source/>
<StockToolRef idValue="{AF0F641B-9CCE-4474-8582-EFE0A38410FC}"/>
<Data>
<GeneralProperties>
<Color>
<BasicPropInfo>
<PropValue unspecified="FALSE" valueType="2" value="0"/>
</BasicPropInfo>
<CreateInfo>
<AcCmColor mRGB="3263463287">
<ColorName>PANTONE 8001 C</ColorName>
<BookName>PANTONE(R) metallic coated</BookName>
</AcCmColor>
</CreateInfo>
</Color>
<Layer>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
</Layer>
<Linetype>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
</Linetype>
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (5 of 8) [23/03/2005 05:52:37 p.m.]
<LinetypeScale>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="3" value="0"/>
</BasicPropInfo>
</LinetypeScale>
<PlotStyle>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="1"/>
</BasicPropInfo>
</PlotStyle>
<LineWeight>
<BasicPropInfo>
<PropValue unspecified="TRUE" valueType="2" value="0"/>
</BasicPropInfo>
</LineWeight>
</GeneralProperties>
<Hatch>
<HatchType>Predefined</HatchType>
<PatternName>SOLID</PatternName>
<SourceFile>%INSTALL_DIR%\UserDataCache\Support\acad.pat</SourceFile>
<Angle>0</Angle>
<Scale>1</Scale>
<Spacing>1</Spacing>
<PenWidth>100</PenWidth>
<Double>0</Double>
<BlockExtent>0.5</BlockExtent>
</Hatch>
</Data>
</Tool>
</Tools>
</Palette>

Profiles and the Internal Workspace Catalog


Each AutoCAD Profile has associated with it an .aws file. This xml file specifies:
- where to store the tools and palettes associated with that profile (WorkspaceCatalogPath)
- all the tool palettes associated with the Tool Palette Set
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (6 of 8) [23/03/2005 05:52:37 p.m.]
- the UI info specific to that user:
- current tab
- palette set transparency
- size and position of the palette set
- title bar justification and docked state
- auto-hide state
- the GUID of each tool palette
- the order of each tool within the palette.
All this allows you to set up Profiles where each user can be pointing to the same tool palettes, but each
user stores their own UI/personal preferences.
In the Options dialog under Files, you will see that you can change the location from which to
store/retrieve tool palettes from. One use-case would be a different profile for different projects, each
pointing to a unique folder in which to store your project-specific tool palettes.

Adding Tools and Tool Palettes from Outside AutoCAD


In AutoCAD, via the Customize dialog you can export out a palette and import it into another profile. An
.xtp file is essentially a tool palette file with the UI info saved with it that was from the workspace
catalog.
You can also import a single tool or tool palette by dropping the .atc file from File Explorer.
Lastly, you can package tools and tool palettes in i-Drop packages and deliver them over the web. The
i-Drop object in your main html file would be something like:
<object name="idrop" classid="clsid:21E0CB95-1198-4945-A3D2-4BF804295F78" width="16"
height="16" align="right">
<param name="background" value="../images/background.jpg">
<param name="proxyrect" value="0,0, 16,16">
<param name="griprect" value="0, 0, 16,16">
<param name="package" value="./Tool Palettes/Idrop-Annotation.xml">
<param name="validate" value="1">
</object>
The i-Drop package that is referred to above (./Tool Palettes/Idrop-Annotation.xml"> would be
something like the following, where the dataset and datafile refers to the actual .atc file for the individual
palette. (For tools the clipformat is:
"CF_IDROP.XML_ACTCUI_TOOL"
<package>
<!-- xmlns="x-schema:idrop-schema.xml" -->
<proxy defaultsrc="../images/iDropButton.gif" />
<dataset defaultsrc="Tool Palettes/Annotation_0656B653-D7C2-41BE-B55B-ADFAFD56E6E3.atc
">
<datasrc clipformat="CF_IDROP.XML_ACTCUI_PALETTE">
<datafile src="Tool
Palettes/Annotation_0656B653-D7C2-41BE-B55B-ADFAFD56E6E3.atc"/>
</datasrc>
</dataset>
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (7 of 8) [23/03/2005 05:52:37 p.m.]
</package>
Adding a New Tool Type
This aspect is probably beyond the main user group here, but there is also functionality in the 3
rd
Party
APIs that will allow 3
rd
Parties to create new tool types, whichcan also be delivered via the web. The
process goes something like this:
1. User drops a tool from a 3
rd
Partys website that is actual new functionality, in other words an
unregistered tool. All that is downloaded is the basic tool properties: name, image, etc. and a link to
an MSIEXEC file back on the vendors website.
2. AutoCAD will inform the user that it is a new tool and do they wish to install now or defer to later.
3. When they choose to install the new tool, the system will go download the MSI installer and install
the tool. Now that tool is registered with the tool system and part of the users stock tool catalog.
Any, thats all. I hope this explains a bit more of the details and gets you all even more excited about
the possibilities ahead. J
Thanks
Chris Yanchar

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Basic Tool System Primer
http://www.afralisp.com/lispb/toolr.htm (8 of 8) [23/03/2005 05:52:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Getting Started
Dialog Control Language, or DCL, always seems to frighten off a lot of Lispers. I admit, it did me too until I was
forced into a situation were I had to learn it and quickly. (make it work, or you're out boy!)
Well, I would hate for any of you to be in the same situation, so for the next few issues, I'll be taking you step by
step, hand in hand, through the minefield of the DCL language. I will share your pain and misery, and will wipe
away your tears, I will.....
("Hey Kenny, get on with it!")
Oops, sorry!
Anyway, where was I? Oh yeah, I will suffer.......(thump!!)
As I was saying before I got this black eye, there are a few terms that you need to familiarise yourself with
before we get stuck into some coding.
Firstly, the dialog box itself is known as a "dialog definition".
Secondly, each "control" on the dialog is known as a "tile definition".
Thirdly, each "property" of a "tile" is known as a dialog "attribute".
And fourthly, each "method" of a "tile" is known as an "action expression".
Why? Who knows? Who cares? All I know is that it will help you immensely in understanding the AutoCAD DCL
reference book if you have a basic knowledge of these terms.
Right, enough waffle, I'm bored and my eye's sore. Let's have a look at some DCL coding and design ourselves
a simple dialog box.
Copy and paste this into Notepad and save it as "TEST_DCL1.DCL".
Oh, before I forget, please ensure that you save this file, and it's namesake AutoLisp file, into a directory that is
within your AutoCAD search path.
//DCL CODING STARTS HERE
test_dcl1
: dialog
{
label = "Test Dialog No 1";
: text
{
label = "This is a Test Message";
alignment = centered;
}
: button
{
key = "accept";
label = "Close";
is_default = true;
fixed_width = true;
alignment = centered;
}
}
//DCL CODING ENDS HERE
Dialog Boxes-Getting Started Page I
http://www.afralisp.com/lisp/dialog1.htm (1 of 5) [23/03/2005 05:52:39 p.m.]
We'll have a closer look at what this all means a bit later. First, let's load some AutoLisp coding and try out our
new dialog box.
Copy and paste this into Notepad and save it as "TEST_DCL.LSP".
;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL1 to run.....")
(defun C:TEST_DCL1 ()
(setq dcl_id (load_dialog "test_dcl1.dcl"))
(if (not (new_dialog "test_dcl1" dcl_id))
(exit )
);if
(action_tile "accept"
"(done_dialog)"
);action_tile
(start_dialog)
(unload_dialog dcl_id)
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
Now load and run your program.
A very simple dialog box containing a message should appear on your screen. It did? Good, well done!!
(thunderous applause from the peanut gallery.)
Right, let's dissect the DCL coding.
(theme music from an old Dracula movie starts in the background.)
//DCL CODING STARTS HERE
Anything starting with // in DCL is regarded as a comment.
test_dcl1
The name of the dialog.
: dialog
The start of the dialog definition
{
The opening bracket for the dialog definition
label = "Test Dialog No 1";
The Label of the dialog definition.
This is what appears in the title bar of the dialog
: text
The start of a text tile definition
{
Dialog Boxes-Getting Started Page I
http://www.afralisp.com/lisp/dialog1.htm (2 of 5) [23/03/2005 05:52:39 p.m.]
The opening bracket for the text tile definition
label = "This is a Test Message";
The label attribute of the text tile
alignment = centered;
The alignment attribute of the text tile
}
The closing bracket of the text tile
: button
The start of a button tile definition
{
The opening bracket for the button tile definition
key = "accept";
The key, or name of the button tile.
You will use this name to reference this button in your AutoLisp coding
label = "Close";
The label attribute. What appears on it.
is_default = true;
The default attribute. If this is true, this button will automatically be selected if the "Enter" button is pressed
fixed_width = true;
Forces the button to be just large enough for the label attribute
alignment = centered;
The alignment attribute
}
The closing bracket for the button tile
}
The closing bracket for the dialog definition
OK, that was easy hey? By the way, did you notice that each of the attribute lines finished with a semicolon? (;)
Another important thing that you must remember when dealing with attributes is that their values are case
sensitive. (e.g.. "True" does not equal "true".)
Now let's have a wee look at the AutoLisp coding that puts this whole thing together. Again, we'll take it line by
line :
(prompt "\nType TEST_DCL1 to run.....")
Inform the user how to start the program.
Just good manners.
(defun C:TEST_DCL1 (/ dcl_id)
Define the function and declare variables
(setq dcl_id (load_dialog "test_dcl1.dcl"))
Load the dialog file and set a reference to it.
(if (not (new_dialog "test_dcl1" dcl_id))
Load the dialog definition and check for it's existence.
Remember, a dialogue file can hold various dialogue definitions
(exit)
Exit the program if the dialog definition is not found.
);if
End if
(action_tile "accept"
If the user selects the tile who's name is "accept", then do the following :
"(done_dialog)"
Dialog Boxes-Getting Started Page I
http://www.afralisp.com/lisp/dialog1.htm (3 of 5) [23/03/2005 05:52:39 p.m.]
Close the dialog
);action_tile
End of action_tile
(start_dialog)
Start the dialog
(unload_dialog dcl_id)
Unload the dialog from memory
(princ)
finish clean
);defun
End of function
(princ)
Load clean
Many people get confused in regards to the order of AutoLisp statements when dealing with DCL files. I don't
blame 'em really. I mean look at the coding above!
First we load the dialog file. G
Then we load the dialog definition. G
Then we run an action_tile statement. G
Then we start the dialog. G
And right after that, we unload the dialog. G
Where's the logic in that?
Haha. But did you notice that the action_tile statement was quoted?
e.g.. "(done_dialog)".
In effect, what we are telling the tile is this:
"Remember this string, then pass it back to me when the user activates you."
"So, in other words, coding is pre-stored within a particular tile. When I select that tile the coding runs?"
Yep, that's it. But remember, no values will be returned until (done_dialog) is called, which is also quoted.
So, the sequence is like this :
First we load the dialog file. G
Then we load the dialog definition. G
Then we run AND REMEMBER all the action_tile statements. G
Then we start the dialog. G
The dialog is displayed. G
Any action_tile statement is processed IF the relevant tile is selected. G
When a tile that contains the (done_dialog) function is selected, we unload the dialog and return all tile values.
And that's it. Easy hey?
In Part II, we'll have a look at some predefined tiles, how to enter and retrieve values from a dialog, and how to
validate these values.
Home. Page II.

Dialog Boxes-Getting Started Page I


http://www.afralisp.com/lisp/dialog1.htm (4 of 5) [23/03/2005 05:52:39 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes-Getting Started Page I
http://www.afralisp.com/lisp/dialog1.htm (5 of 5) [23/03/2005 05:52:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Getting Started - Page II
OK, tea break over, back to work!!
Copy and paste this into Notepad and save it as "TEST_DCL2.DCL".
//DCL CODING STARTS HERE
test_dcl2
: dialog
{
label = "Test Dialog No 2";

: edit_box
{
label = "Enter Your Name :";
mnemonic = "N";
key = "name";
alignment = centered;
edit_limit = 30;
edit_width = 30;
}
: edit_box
{
label = "Enter Your Age :";
mnemonic = "A";
key = "age";
alignment = centered;
edit_limit = 3;
edit_width = 3;
value = "";
}
: button
{
key = "accept";
label = "OK";
is_default = true;
fixed_width = true;
alignment = centered;
}
: errtile
{
width = 34;
}
Dialog Boxes-Getting Started Page II
http://www.afralisp.com/lisp/dialog2.htm (1 of 4) [23/03/2005 05:52:43 p.m.]
}
//DCL CODING ENDS HERE
And now the AutoLisp coding. Copy and paste this and save it as "TEST_DCL2.LSP" and then load and run it :
;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL2 to run.....")
(defun C:TEST_DCL2 ( / dcl_id)
(setq dcl_id (load_dialog "test_dcl2.dcl"))
(if (not (new_dialog "test_dcl2" dcl_id))
(exit )
);if
(set_tile "name" "Enter Name Here")
(mode_tile "name" 2)
(action_tile "name" "(setq name $value)")
(action_tile "age" "(setq age $value)")
(action_tile "accept" "(val1)")
(start_dialog)
(unload_dialog dcl_id)
(alert (strcat "Your name is " name
"\nand you are " age " years of age."))
(princ)
);defun
-----------------------
(defun val1 ()
(if (= (get_tile "name") "Enter Name Here")
(progn
(set_tile "error" "You must enter a name!")
(mode_tile "name" 2)
);progn
(val2)
);if
);defun
-------------------
(defun val2 ()
(if (< (atoi (get_tile "age")) 1)
(progn
(set_tile "error" "Invalid Age - Please Try Again!!")
(mode_tile "age" 2)
);progn
(done_dialog)
);if
);defun
(princ)
Dialog Boxes-Getting Started Page II
http://www.afralisp.com/lisp/dialog2.htm (2 of 4) [23/03/2005 05:52:43 p.m.]
;AUTOLISP CODING ENDS HERE
The dialog that is displayed contains two edit boxes. One to enter your name into, and one your age. After
entering the relevant information select the "OK" button. An alert box will display showing your details.
Now run the program again, but do not enter your name. An error message will display informing you that you
must enter your name.
Fill in your name but leave your age blank. Press enter again. Another error message will inform you that you
have entered an invalid age.
Try it with a zero or a negative number. The same error message will display until you enter a number equal or
greater than 1. Both of these examples are know as validation.
Let's have a look at the DCL coding.
:edit_box - This is a predefined tile that allows the user to enter or edit a single line of text.
There are a few new attributes defined in this tile :
mnemonic = "A"; - This defines the mnemonic character for the tile.
edit_limit = 3; - This limits the size of the edit box to 3 characters.
edit_width = 3; - This limits the user to typing a maximum of 3 characters.
value = ""; - This sets the intial value of the edit box, in this case nothing.
Now let's have a look at the AutoLisp coding. First the "action expressions".
(set_tile "name" "Enter Name Here") - This sets the runtime (initial) value of a tile who's "key" attribute is "name".
Dialog Boxes-Getting Started Page II
http://www.afralisp.com/lisp/dialog2.htm (3 of 4) [23/03/2005 05:52:43 p.m.]
(mode_tile "name" 2) - This sets the mode of the tile who's "key" attribute is "name". In this example, we have
used a mode of "2" that allows for overwriting of what is already in the edit box.
(action_tile "name" "(setq name $value)") - Associates the specied tile with the action expression or call back
function. In this case we are saying "If the tile who's "key" attribute is "name" is selected, store the value of this
tile in the variable name."
(get_tile "name") - Retrieve the value of the tile who's "key" attribute is "name".
Did you notice that we wrote :
(action_tile "accept" "(val1)")
instead of :
(action_tile "accept" "(done_dialog)")
Instead of closing the dialog when OK is selected, we initiate a subroutine that checks (validates) that the name
information is exceptable. If it is not, the error tile is displayed.
(set_tile "error" "You must enter a name!")
Once the name has been validated, this routine then initiates a second subroutine that validates the age value.
If this not correct, the error tile is again displayed, this time with a different message.
(set_tile "error" "Invalid Age - Please Try Again!!")
If everything is correct, (done_dialog) is called, all values are returned and the alert box is displayed with the
relevant information.
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes-Getting Started Page II
http://www.afralisp.com/lisp/dialog2.htm (4 of 4) [23/03/2005 05:52:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Dialog Box Layout - Page I
Laying out Dialog Boxes in DCL can be a bit tricky and entails quite a lot of "trial and error". But, if you
follow a few simple guidelines, a complicated dialog box can be simplified quite considerably. To view
the dialogs throughout this tutorial, we will be making use of the Visual Lisp Editor and the "Preview
DCL in Editor" function. If you are unfamiliar with the usage of this very handy function, you'll find step
by step instructions here.
If you would rather call the dialog boxes from AutoCAD, I have included AutoLisp coding that will fulfill
this purpose in the download file that you can find at the end of this tutorial.
As well, explanations for all the tile attributes are covered in this section - "DCL Tile Attributes". I
suggest you refer to this whilst going through this tutorial.
OK, let's get started. Consider this :
Rather a complicated dialog hey?
Laying out a dialog is similar in way to writing a program. You don't start off by writing the whole
program in one go. You write the program in sections, testing each part as you go along. Only when
each part has been thoroughly tested, do you start to put the whole program together.
We are going to do exactly the same, splitting our dialog into 3 separate DCL files before merging them
all together into one.
Let's have a look at the button section first :
Dialog Box Layout - Page I
http://www.afralisp.com/lisp/dlayout.htm (1 of 5) [23/03/2005 05:52:49 p.m.]
We'll start off by creating a dialog with just two buttons, namely the "OK" and "Cancel" buttons. Open a
new file in the Visual Lisp editor and Copy and paste this.
afra : dialog {
label = "A" ;
: button {
label = "OK";
key = "accept";
mnemonic = "O";
alignment = centered;
width = 12;
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
mnemonic = "C";
alignment = centered;
width = 12;
}
}

Save this as "Afra.dcl".
Using the "Preview DCL in Editor" function, your dialog should look like this :
Did you notice something? The button layout "defaulted" to a column layout. But we need these two
buttons to be in a row! Ok, lets do that :
afra : dialog {
label = "A" ;
: row {
: button {
label = "OK";
key = "accept";
mnemonic = "O";
alignment = centered;
width = 12;
is_default = true;
}
: button {
Dialog Box Layout - Page I
http://www.afralisp.com/lisp/dlayout.htm (2 of 5) [23/03/2005 05:52:49 p.m.]
label = "Cancel";
key = "cancel";
mnemonic = "C";
alignment = centered;
width = 12;
}
}

}

Your dialog should now look like this :
A word of advice. Do not rely on your tiles to default to columns. Rather explicitly define a column
within your DCL Coding. If not? Well, confusion will reign......
Now we'll add the other four buttons to create our button cluster :
afra : dialog {
label = "A" ;
: column {
: row {
: button {
label = "OK";
key = "accept";
mnemonic = "O";
alignment = centered;
width = 12;
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
mnemonic = "C";
alignment = centered;
width = 12;
}
}
: row {
: button {
label = "Save";
key = "save";
mnemonic = "S";
alignment = centered;
width = 12;
}
Dialog Box Layout - Page I
http://www.afralisp.com/lisp/dlayout.htm (3 of 5) [23/03/2005 05:52:49 p.m.]
: button {
label = "Load";
key = "load";
mnemonic = "L";
alignment = centered;
width = 12;
}
}
: row {
: button {
label = "Help...";
key = "help";
mnemonic = "H";
alignment = centered;
width = 12;
}
: button {
label = "About...";
key = "About";
mnemonic = "H";
alignment = centered;
width = 12;
}
}
}

}
And, our dialog should now look like this :
Did you notice how only one of the button tiles has the "is_default" attribute set to "true"?
Good, you did! And why? Think about it!!!
For the sake of readability, and to save some space, you could also write the DCL coding like this :
afra : dialog {
label = "A" ;
: column {
: row {
: button {label = "OK"; key = "accept"; mnemonic = "O";
alignment = centered; width = 12;
is_default = true;}
: button {label = "Cancel"; key = "cancel";mnemonic = "C";
Dialog Box Layout - Page I
http://www.afralisp.com/lisp/dlayout.htm (4 of 5) [23/03/2005 05:52:49 p.m.]
alignment = centered; width = 12;}
}
: row {
: button {label = "Save"; key = "save"; mnemonic = "S";
alignment = centered; width = 12;}
: button {label = "Load";key = "load"; mnemonic = "L";
alignment = centered; width = 12;}
}
: row {
: button {label = "Help..."; key = "help"; mnemonic = "H";
alignment = centered; width = 12;}
: button {label = "About..."; key = "About"; mnemonic = "H";
alignment = centered; width = 12;}
}
}
}
On the next page we'll continue with our dialog.
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Box Layout - Page I
http://www.afralisp.com/lisp/dlayout.htm (5 of 5) [23/03/2005 05:52:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Previewing DCL Files
Firstly, open AutoCAD.
Now open the Visual Lisp Editor :
Tools ->AutoLisp ->Visual Lisp Editor
Open the DCL file that you wish to view :
File ->Open
Select "DCL Source Files" from the "Files of Type" and then select your DCL file.
Once your DCL file has opened, select :
Tools ->Interface Tools ->Preview DCL in Editor
Enter your dialog name if it is not already displayed.
Select "OK"
Your dialog should be displayed.
Back to Tutorial

Previewing DCL Files


http://www.afralisp.com/lisp/dlayout2.htm (1 of 2) [23/03/2005 05:52:50 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Previewing DCL Files
http://www.afralisp.com/lisp/dlayout2.htm (2 of 2) [23/03/2005 05:52:50 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DCL Tile Attributes
This tutorial will give you a detailed explanation of all attributes used in the design and
implementation of dialogue boxes used within AutoCAD/AutoLisp.
I have provided a sample dialogue image of each of the various aspects of attributes, and
the sample DCL Coding that was used to create the dialogue. The sample AutoLisp
coding required to display each dialogue can be found in the downloadable tutorial.
Attributes in DCL define the layout and functionality of tiles. If you are familiar with Visual Basic,
you will find that they are very similar to properties.
DCL Attributes consist of a name and a value.
Note: The value of certain attributes can change at run-time, with user input or
'set_tile' calls.
The value of a tile's attribute must be one of the following type:
Integer
Numeric Values (integer or real number) that represent distances such as width, or height of
a tile.
G
Real Number
A fractional real number must have a leading digit.
e.g. 0.1 not .1.
G
Quoted String
A quoted string consists of text enclosed in quotation marks (" "). Attribute values are case
sensitive. "RB1" is not the same as "rb1".
G
Reserved Word
A reserved word is an identifier made up of alphanumeric characters, beginning with a letter.
e.g. true or false. Reserved words are case sensitive: True does not equal true.
G
Global Attributes.
Attribute :
alignment G
fixed_height G
fixed_width G
height G
width G
Applies To :
All Tiles G
Attributes Associated with Action Tiles
Attribute :
DCL Tile Attributes
http://www.afralisp.com/lispa/lisp49.htm (1 of 5) [23/03/2005 05:52:51 p.m.]
action G
is_enabled G
is_tab_stop G
key G
mnemonic G
Applies To :
button; edit_box; image_button; list_box; popup_list;
radio_button; slider; toggle; radio_column; radio_row.
G
Attributes Associated with Tile Clusters
Attribute :
children_alignment G
children_fixed_height G
children_fixed_width G
Applies To :
row; column; radio_row; radio_column; boxed_row;
boxed_column; boxed_radio_row; boxed_radio_column.
G
Attributes Associative with Specific Tiles
Attribute :
allow_accept G
Applies To :
edit_box; image_button; list_box G
Attribute :
aspect_ration G
Applies To :
image; image_button. G
Attribute :
big_increment G
Applies To :
slider. G
Attribute :
color G
Applies To :
image; image_button. G
Attribute :
DCL Tile Attributes
http://www.afralisp.com/lispa/lisp49.htm (2 of 5) [23/03/2005 05:52:51 p.m.]
edit_limit G
Applies To :
edit_box. G
Attribute :
edit_width G
Applies To :
edit_box; popup_list. G
Attribute :
fixed_width_font G
Applies To :
edit_box; popup_list. G
Attribute :
initial_focus G
Applies To :
dialog. G
Attribute :
is_cancel G
Applies To :
button. G
Attribute :
is_default G
Applies To :
button. G
Attribute :
label G
Applies To :
boxed_row; boxed_column; boxed_radio_row;
boxed_radio_column; button; dialog; edit_box
list_box; popup_list; radio_button; text; toggle.
G
Attribute :
layout G
Applies To :
slider. G
Attribute :
list G
Applies To :
DCL Tile Attributes
http://www.afralisp.com/lispa/lisp49.htm (3 of 5) [23/03/2005 05:52:51 p.m.]
list_box; popup_list. G
Attribute :
max_value G
Applies To :
slider. G
Attribute :
min_value G
Applies To :
slider. G
Attribute :
multiple_select G
Applies To :
list_box. G
Attribute :
password_char G
Applies To :
edit_box. G
Attribute :
small_increment G
Applies To :
slider. G
Attribute :
tabs G
Applies To :
list_box; popup_list. G
Attribute :
tab_truncate G
Applies To :
list_box; popup_list G
Attribute :
value G
Applies To :
text; all active tiles (except buttons and
image_buttons).
G
To download all DCL and AutoLisp Code samples, stand up, go into the bathroom, look in the
mirror and stick your tongue out. Then return to the computer, place your mouse here, and click as
hard as you can. Enjoy..
DCL Tile Attributes
http://www.afralisp.com/lispa/lisp49.htm (4 of 5) [23/03/2005 05:52:51 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes
http://www.afralisp.com/lispa/lisp49.htm (5 of 5) [23/03/2005 05:52:51 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
alignment
Aligned Centered.
Aligned Right.
This attribute specifies the horizontal or vertical positioning of a tile within its cluster. If a tile is within a
column, the possible values are:
left, right or centered. (default: left)
If a tile is within a row, the possible values are:
top, bottom or centered. (default: centered)
You cannot specify the alignment along the long axis of a cluster. The first and last tiles in the cluster always
align themselves to the ends of the column or row.
DCL Code Sample
lisp49a : dialog { //dialog name
label = "aligment" ; //give it a label
: button { //define button
label="Button"; //give it a label
fixed_width=true; //fix the width
alignment=right; //align right
} //end button
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Alignment


http://www.afralisp.com/lispa/lisp49a.htm (1 of 2) [23/03/2005 05:52:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Alignment
http://www.afralisp.com/lispa/lisp49a.htm (2 of 2) [23/03/2005 05:52:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
fixed_height
Fixed_Height Not Set.
Fixed_Height Set to True.
This attribute specifies whether a tiles height is allowed to fill the available white space. If this attribute is
true, the tile will be restricted to it's preset height attribute.
Possible values are: true or false. (default: false)
DCL Code Sample
lisp49b : dialog { //dialog name
label = "fixed_height"; //give it a label
: row { //define a row
: list_box { //define a list box
key = "lb1"; //give it a name
label = "List Box 1"; //give it a label
list = "1\n2\n3\n4\n5\n6\n7\n8\n9"; //make a list
}
DCL Tile Attributes-Fixed_Height
http://www.afralisp.com/lispa/lisp49b.htm (1 of 2) [23/03/2005 05:52:53 p.m.]
: list_box { //define a list box
key = "lb2"; //give it a name
label = "List Box 2"; //give it a label
list = "A\nB\nC\nD"; //make a list
height = 5; //set the height
fixed_height = true; //fix the height
alignment = top; //align to top
} //end list box

} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Fixed_Height
http://www.afralisp.com/lispa/lisp49b.htm (2 of 2) [23/03/2005 05:52:53 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
fixed_width
Fixed_Width Not Set.
Fixed_Width Set to True.
This attribute specifies whether a tiles width is allowed to fill the available white
space. If this attribute is true, the tile will be restricted to it's preset width attribute.
Possible values are: true or false. (default = false)
DCL Code Sample
lisp49c : dialog { //dialog name
label = "fixed_width"; //give it a label
: edit_box { //define an edit box
key = "eb1"; //give it a name
label = "Edit Box 1"; //give it a label
width = 24; //give it a width
value = "A SMALL Box"; //give it a value
fixed_width = true; //fix the width
} //end edit box
: edit_box { //define an edit box
key = "eb2"; //give it a name
label = "Edit Box 2"; //give it a label
value = "...This is a LARGE Box..."; //give it a value
} //end edit box
ok_cancel_help ; //predefined OK/Cancel/Help button
} //end dialog

DCL Tile Attributes-Fixed_Width


http://www.afralisp.com/lispa/lisp49c.htm (1 of 2) [23/03/2005 05:52:55 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Fixed_Width
http://www.afralisp.com/lispa/lisp49c.htm (2 of 2) [23/03/2005 05:52:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
height
Height Not Set.
Height Set to 15.
This attribute specifies the height of tile. The height value must be an integer or a real number. The height
of image tiles and image buttons must be specified.
Note: The height of a tile is the MINIMUM value.
Possible values are platform dependent.
DCL Code Sample
lisp49d : dialog { //dialog name
label = "height"; //give it a label
: list_box { //define a list box
key = "lb1"; //give it a name
DCL Tile Attributes-Height
http://www.afralisp.com/lispa/lisp49d.htm (1 of 2) [23/03/2005 05:52:56 p.m.]
label = "List Box 1"; //give it a label
list = "1\n2\n3\n4\n5\n6\n7\n8\n9"; //make a list
height = 15; //give it a height
} //end list box
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Height
http://www.afralisp.com/lispa/lisp49d.htm (2 of 2) [23/03/2005 05:52:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
width
Width Not Set.
Width Set to 30.
This attribute specifies the width of tile. The width value must be an integer or a real value. The width of
image tiles and image buttons must be specified.
Note: The width of a tile is the MINIMUM value.
Possible values are platform dependent.
DCL Code Sample
lisp49e : dialog { //dialog name
label = "width"; //give it a label
: edit_box { //define an edit box
key = "eb1"; //give it a name
value = "This is a longer box"; //give it a value
width = 30; //give it a width
} //end edit box
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Width
http://www.afralisp.com/lispa/lisp49e.htm (1 of 2) [23/03/2005 05:52:58 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Width
http://www.afralisp.com/lispa/lisp49e.htm (2 of 2) [23/03/2005 05:52:58 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
action
Action Attribute in action.
This attribute specifies an AutoLisp expression to activate. The value must be quoted. eg. "(acad_colordlg 3)"

DCL Code Sample


lisp49f : dialog { //dialog name
label = "action"; //give it a label
: button { //define a button
fixed_width = true; //fix it's width
alignment = centered; //center it
label = "Action Button"; //give it a label
action = "(alert \"Kenny is Great\")"; //Trigger an AutoLisp Function
} //end button
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
DCL Tile Attributes-Action
http://www.afralisp.com/lispa/lisp49f.htm (1 of 2) [23/03/2005 05:52:59 p.m.]
Search
Powered by CORBIMITE.com
DCL Tile Attributes-Action
http://www.afralisp.com/lispa/lisp49f.htm (2 of 2) [23/03/2005 05:52:59 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
is_enabled
Enabled/Disabled.
This attribute specifies whether a tile is initially grayed out. (Unavailable.)
Possible values are: true or false. (default: true).
DCL Code Sample
lisp49g : dialog { //dialog name
label = "is_enabled"; //give it a label
: boxed_radio_row { //define boxed radio row
label = "Choose :"; //give it a label
: radio_button { //define radio button
label = "&Large"; //give it a label
key = "rb1"; //give it a name
value = "1"; //make it default
} //end radio button
: radio_button { //define radio button
label = "&Small"; //give it a label
key = "rb2"; //give it a name
} //end radio button
} //end boxed radio row
: boxed_radio_row { //define boxed radio row
: radio_button { //define radio button
label = "&Big"; //give it a label
key = "rb3"; //give it a name
value = "1"; //make it default
} //end radio button
: radio_button { //define radio button
label = "&Very Big"; //give it a label
key = "rb4"; //give it a name
DCL Tile Attributes-Is_Enabled
http://www.afralisp.com/lispa/lisp49g.htm (1 of 3) [23/03/2005 05:53:00 p.m.]
} //end radio button
} //end boxed radio row
: boxed_radio_row { //define boxed radio row
: radio_button { //define radio button
label = "&Small"; //give it a label
key = "rb5"; //give it a name
is_enabled = false; //switch off
} //end radio button
: radio_button { //define radio button
label = "&Very Small"; //give it a label
key = "rb6"; //give it a name
value = "1"; //make it default
is_enabled = false; //switch off
} //end radio button
} //end boxed radio row
spacer; //define spacer
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp49g ()
;define function
(setq dcl_id (load_dialog "lisp49g.dcl"))
;load dialog
(if (not (new_dialog "lisp49g" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile "rb2"
"(mode_tile \"rb3\" 1)
(mode_tile \"rb4\" 1)
(mode_tile \"rb5\" 0)
(mode_tile \"rb6\"0)"
)
(action_tile "rb1"
"(mode_tile \"rb3\" 0)
(mode_tile \"rb4\" 0)
(mode_tile \"rb5\" 1)
(mode_tile \"rb6\" 1)"
)
(action_tile
DCL Tile Attributes-Is_Enabled
http://www.afralisp.com/lispa/lisp49g.htm (2 of 3) [23/03/2005 05:53:00 p.m.]
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Is_Enabled
http://www.afralisp.com/lispa/lisp49g.htm (3 of 3) [23/03/2005 05:53:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
is_tab_stop
Tab Stops
This attribute specifies whether a tile is a tab stop. (receives keyboard focus when the user moves between
tiles by pressing the "Tab" key.) If a tile is disabled,
it isn't a tab stop even if this attribute is set to true.
If false, the tile is not a tab stop.
Possible values are: true or false. (default: true).
DCL Code Sample
lisp49h : dialog { //dialog name
label = "is_tab_stop"; //give it a label
: edit_box { //define edit box
key = "eb1"; //give it a name
label = "Edit Box 1"; //give it a label
value = "This is a Tab Stop"; //give it a value
width = 40; //give it a width
fixed_width = true; //fix the width
} //end edit box
: edit_box { //define edit box
key = "eb2"; //give it a name
label = "Edit Box 2"; //give it a label
value = "This is NOT a Tab Stop"; //give it a value
width = 40; //give it a width
fixed_width = true; //fix the width
is_tab_stop = false; //no tab stop
} //end edit box
: edit_box { //define edit box
key = "eb3"; //give it a name
label = "Edit Box 3"; //give it a label
value = "This is another Tab Stop"; //give it a value
width = 40; //give it a width
fixed_width = true; //fix the width
} //end edit box
spacer; //define spacer
DCL Tile Attributes-Is_Tab_Stop
http://www.afralisp.com/lispa/lisp49h.htm (1 of 2) [23/03/2005 05:53:02 p.m.]
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Is_Tab_Stop
http://www.afralisp.com/lispa/lisp49h.htm (2 of 2) [23/03/2005 05:53:02 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
key
A List of Keys
This attribute specifies an ASCII name that your program uses to refer to a specific tile. It must be a quoted
string (no default) and is case sensitive.
("eb1" does not equal "Eb1").
Each key value MUST be unique within a dialogue definition.
DCL Code Sample
lisp49i : dialog { //dialog name
label = "key"; //give it a label
: edit_box { //define edit box
key = "eb1"; //give it a name
label = "Edit Box 1"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
value = "Enter a Number and press Tab"; //give it a value
} //end edit box
: edit_box { //define edit box
key = "eb2"; //give it a name
label = "Edit Box 2"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
value = "Enter a Number and press Tab"; //give it a value
} //end edit box
: edit_box { //define edit box
key = "eb3"; //give it a name
label = "Edit Box 3"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
value = "Enter a Number and press Tab"; //give it a value
} //end edit box
: edit_box { //define edit box
key = "eb4"; //give it a name
DCL Tile Attributes-Key
http://www.afralisp.com/lispa/lisp49i.htm (1 of 4) [23/03/2005 05:53:03 p.m.]
label = "Key Edit Box 1"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
} //end edit box
: edit_box { //define edit box
key = "eb5"; //give it a name
label = "Key Edit Box 2"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
} //end edit box
: edit_box { //define edit box
key = "eb6"; //give it a name
label = "Key Edit Box 3"; //give it a label
width = 40; //give it a width
fixed_width = true; //fix the width
} //end edit box
spacer; //define spacer
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Code Sample
(defun C:lisp49i ()
;define function
(setq dcl_id (load_dialog "lisp49i.dcl"))
;load dialog
(if (not (new_dialog "lisp49i" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(mode_tile "eb1" 2)
(mode_tile "eb1" 3)
(action_tile "eb1"
;if this tile is selected
"(setq a $key)
;retrieve it's name
(set_tile \"eb4\" a)"
;set the tile 'eb4' to it's name
)
(action_tile "eb2"
;if this tile is selected
"(setq b $key)
;retrieve it's name
DCL Tile Attributes-Key
http://www.afralisp.com/lispa/lisp49i.htm (2 of 4) [23/03/2005 05:53:03 p.m.]
(set_tile \"eb5\" b)
;set the tile 'eb5' to it's name
(mode_tile a 1)"
;switch off the tile 'eb2'
)
(action_tile "eb3"
;if this tile is selected
"(setq c $key)
;retrieve it's name
(set_tile \"eb6\" c)"
;set the tile 'eb6' to it's name
)
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

DCL Tile Attributes-Key


http://www.afralisp.com/lispa/lisp49i.htm (3 of 4) [23/03/2005 05:53:03 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Key
http://www.afralisp.com/lispa/lisp49i.htm (4 of 4) [23/03/2005 05:53:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
mnemonic
Mnemonic
This attribute specifies a keyboard mnemonic character for a tile. The mnemonic character is underlined in
the tile's label. The value is a quoted string of a single character that must be one of the letters of the tile's
label. (No default).
The character does not have to be unique to the dialogue box. If more that one tile has the same mnemonic,
you press Tab to cycle through the tiles sequentially.
The label attribute can also specify a mnemonic by preceding a character with an ampersand: (&).
DCL Code Sample
lisp49j : dialog { //dialog name
label = "mnemonic"; //give it a label
: button { //define a button
key = "btn1"; //give it a name
label = "Button No 1"; //give it a label
fixed_width = true; //fix it's width
alignment = centered; //centre it
mnemonic = "1"; //the mnemonic
} //end button
: button { //define a button
key = "btn2"; //give it a name
label = "Button No &2"; //give it a label
//and define the
//mnemonic
fixed_width = true; //fix it's width
alignment = centered; //centre it
} //end button

spacer; //add a spacer
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Mnemonic


http://www.afralisp.com/lispa/lisp49j.htm (1 of 2) [23/03/2005 05:53:05 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Mnemonic
http://www.afralisp.com/lispa/lisp49j.htm (2 of 2) [23/03/2005 05:53:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
children_alignment
Aligned Center
This attribute specifies the default alignment for all tiles in a cluster.
It does not override a child's alignment attribute if that is set.
Possible values for columns are left; right or centered.
default: left
Possible values for rows are top; bottom or centered.
default: centered
DCL Code Sample
lisp49k : dialog { //dialog name
label = "children_alignment"; //give it a label
: column { //define a column
children_alignment = right; //put tiles on the right
: button { //define a button
key = "btn1"; //give it a name
label = "Button No &1"; //give it a label
fixed_width = true; //fix it's width
} //end button
: button { //define a button
key = "btn2"; //give it a name
label = "Button No &2"; //give it a label
fixed_width = true; //fix it's width
alignment = left; //override default
//alignment
} //end button
: button { //define a button
key = "btn3"; //give it a name
label = "Button No &3"; //give it a label
fixed_width = true; //fix it's width
} //end button
} //end column
DCL Tile Attributes-Children_Alignment
http://www.afralisp.com/lispa/lisp49k.htm (1 of 2) [23/03/2005 05:53:06 p.m.]
spacer; //add a spacer
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Children_Alignment
http://www.afralisp.com/lispa/lisp49k.htm (2 of 2) [23/03/2005 05:53:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
children_fixed_height
Children_Fixed_Height Not Set.
Children_Fixed_Height Set to True.
This attribute specifies the default height for all the tiles in a cluster.
It does not override a child's height attribute if it is specified. Possible values are: true or false. (default:
false)
DCL Code Sample
lisp49l : dialog { //dialog name
label = "children_fixed_height"; //give it a label
: row { //define a row
children_fixed_height = true; //fix the height
: list_box { //define a list box
key = "lb1"; //give it a name
label = "List Box 1"; //give it a label
list = "1\n2\n3\n4"; //make a list
height = 5; //define height
}
: list_box { //define a list box
key = "lb2"; //give it a name
label = "List Box 2"; //give it a label
DCL Tile Attributes-Children_Fixed_Height
http://www.afralisp.com/lispa/lisp49l.htm (1 of 2) [23/03/2005 05:53:08 p.m.]
list = "A\nB\nC\nD"; //make a list
height = 5; //define height
}

} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Children_Fixed_Height
http://www.afralisp.com/lispa/lisp49l.htm (2 of 2) [23/03/2005 05:53:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
children_fixed_width
Children_Fixed_Width Not Set.
Children_Fixed_Width Set to True.
This attribute specifies the default width for all the tiles in a cluster.
It does not override a child's width attribute if it is specified. Possible values are: true or false. (default: false)
DCL Code Sample
lisp49m : dialog { //dialog name
label = "children_fixed_width"; //give it a label
: column { //define column
children_fixed_width = true; //fix the width
: edit_box { //define an edit box
key = "eb1"; //give it a name
label = "Edit Box 1"; //give it a label
width = 10; //give it a width
value = "Edit Box 1"; //fill it
} //end edit box
: edit_box { //define an edit box
key = "eb2"; //give it a name
label = "Edit Box 2"; //give it a label
width = 10; //give it a width
value = "Edit Box 2"; //fill it
} //end edit box
} //end column
spacer; //a spacer
ok_cancel_help ; //predefined OK/Cancel/Help button
} //end dialog

DCL Tile Attributes-Children_Fixed_Width


http://www.afralisp.com/lispa/lisp49m.htm (1 of 2) [23/03/2005 05:53:09 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Children_Fixed_Width
http://www.afralisp.com/lispa/lisp49m.htm (2 of 2) [23/03/2005 05:53:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
allow_accept
Allow_Accept.
This attribute specifies whether a particular tile can be double-clicked.
If true and the user double-clicks the tile, the tile who's key is "accept" is selected. (Normally the O.K. tile.)
This attribute defaults to false.
DCL Code Sample
lisp49n : dialog { //dialog name
label = "allow_accept"; //give it a label
: list_box { //define a list box
key = "lb1"; //give it a name
label = "Double Click a Letter:"; //give it a label
list = "A\nB\nC\nD\nE\nF\nG\nH\nI"; //make a list
height = 5; //define height
fixed_height = true; //fix the height
allow_accept = true; //allow double click
} //end list box

spacer; //add a space

ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Allow_Accept
http://www.afralisp.com/lispa/lisp49n.htm (1 of 2) [23/03/2005 05:53:10 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Allow_Accept
http://www.afralisp.com/lispa/lisp49n.htm (2 of 2) [23/03/2005 05:53:10 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
aspect_ratio
Aspect_Ratio set to 0.5.
Aspect_Ratio set to 2.0.
This attribute specifies the ratio of the width of an image to it's height. (width divided by height.) If zero
(0.0), the tile is fitted to the size of the image.
Possible values are floating-point values.
default: none.
DCL Code Sample
lisp49o : dialog { //dialog name
label = "aspect_ratio" ; //give it a label

: image { //define image tile
key = "im1" ; //give it a name
width = 5.0 ; //set width
aspect_ratio = 2.0; //set the ratio
alignment = centered; //center the image
} //end image
spacer; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Aspect_Ratio


http://www.afralisp.com/lispa/lisp49o.htm (1 of 2) [23/03/2005 05:53:11 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Aspect_Ratio
http://www.afralisp.com/lispa/lisp49o.htm (2 of 2) [23/03/2005 05:53:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
big_increment
Big Increment.
This attribute specifies the value that the slider will increase or decrease by, if you click the slider bar. This
value must be between the min_value, and the max_value.
Default value: One-tenth of the total range.
DCL Code Sample
lisp49p : dialog { //dialog name
label = "big_increment" ; //give it a label
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
big_increment = 5; //define big increment
} //end slider
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Big_Increment
http://www.afralisp.com/lispa/lisp49p.htm (1 of 2) [23/03/2005 05:53:13 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Big_Increment
http://www.afralisp.com/lispa/lisp49p.htm (2 of 2) [23/03/2005 05:53:13 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
color
Color.
This attribute specifies the background (fill) colour of an image.
Possible values are an integer or reserved word (default: 7) specified as an AutoCAD colour number or as
one of the symbolic names as shown in the following table:
dialog_line Current dialog box line colour
dialog_foreground Current dialog box foreground colour
dialog_background Current dialog box background colour
graphics_background Current background of the AutoCAD graphics screen.
(Usually equivalent to 0)
black AutoCAD colour = 0 (black) (appears light on a
black background)
red AutoCAD colour = 1 (red)
yellow AutoCAD colour = 2 (yellow)
green AutoCAD colour = 3 (green)
cyan AutoCAD colour = 4 (cyan)
blue AutoCAD colour = 5 (blue)
magenta AutoCAD colour = 6 (magenta)
white AutoCAD colour = 7 (white)
graphics_foreground Appears black on a light background
Note: If an image tile containing slides is blank when you first display it, try changing it's color attribute to
graphics_background or graphics_foreground.
DCL Code Sample
lisp49q : dialog { //dialog name
label = "color" ; //give it a label

: row { //begin row
children_fixed_height = true; //fix the height
children_alignment = centered;
: image { //define image tile
key = "im1" ; //give it a name
height = 1.0 ; //and a height
width = 2.0 ; //and now a width
color = green; //set the colour
} //end image
: image { //define image tile
key = "im2" ; //give it a name
height = 1.0 ; //and a height
width = 2.0 ; //and now a width
color = dialog_line; //set the colour
DCL Tile Attributes-Color
http://www.afralisp.com/lispa/lisp49q.htm (1 of 2) [23/03/2005 05:53:14 p.m.]
} //end image
: image { //define image tile
key = "im3" ; //give it a name
height = 1.0 ; //and a height
width = 2.0 ; //and now a width
color = blue; //set the colour
} //end image
: image { //define image tile
key = "im4" ; //give it a name
height = 1.0 ; //and a height
width = 2.0 ; //and now a width
color = red; //set the colour
} //end image
: image { //define image tile
key = "im5" ; //give it a name
height = 1.0 ; //and a height
width = 2.0 ; //and now a width
color = cyan; //set the colour
} //end image
} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Color
http://www.afralisp.com/lispa/lisp49q.htm (2 of 2) [23/03/2005 05:53:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
edit_limit
Edit Limit.
This attribute specifies the maximum number of characters a user is allowed to enter into an edit box.
Possible value is an integer.
Default: 132.
DCL Code Sample
lisp49r : dialog { //dialog name
label = "edit_limit" ; //give it a label

: edit_box { //define edit box
key = "eb1"; //give it a name
label = "Input CD Key "; //give it a label
edit_limit = 4; //limit characters
} //end edit box
: edit_box { //define edit box
key = "eb2"; //give it a name
label = "Serial Number"; //give it a label
edit_limit = 8; //limit characters
} //end edit box
spacer; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Edit_Limit
http://www.afralisp.com/lispa/lisp49r.htm (1 of 2) [23/03/2005 05:53:16 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Edit_Limit
http://www.afralisp.com/lispa/lisp49r.htm (2 of 2) [23/03/2005 05:53:16 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
edit_width
Edit Width.
This attribute specifies the width in character units of an edit box.
Possible values are an integer or a real number.
Default: None.
DCL Code Sample
lisp49s : dialog { //dialog name
label = "edit_width" ; //give it a label

: edit_box { //define edit box
key = "eb1"; //give it a name
label = "Input CD Key "; //give it a label
edit_limit = 4; //limit characters
edit_width = 4; //fix the width
} //end edit box
: edit_box { //define edit box
key = "eb2"; //give it a name
label = "Serial Number"; //give it a label
edit_limit = 8; //limit characters
edit_width = 8; //fix the width
} //end edit box
spacer; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Edit_Width


http://www.afralisp.com/lispa/lisp49s.htm (1 of 2) [23/03/2005 05:53:17 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Edit_Width
http://www.afralisp.com/lispa/lisp49s.htm (2 of 2) [23/03/2005 05:53:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
fixed_width_font
Dialogue with Fixed Width Font.
This attribute specifies whether a 'list_box' or 'popup_list' will display text in a fixed pitch font. This allows
for easier spacing and tab alignment of columns.
This attribute is valid only for Windows/NT.
DCL Code Sample
lisp49ai : dialog { //dialog name
label = "fixed_width_font" ; //give it a label
: list_box { //define a list box
key = "lb1"; //give it a name
label = "Select Bolt Type:"; //give it a label
allow_accept = true; //allow double clicking
tabs = "8 16 24"; //set tabs
list = "M20\t40LG\tGr. 8,8\n
M16\t30LG\tGr. 4,6\n
M30\t60LG\tGr. 8,8\n
M12\t35LG\tGr. 4,6\n
M8\t45LG\tGr. 8,8"; //define the list
height = 6; //give it a height
fixed_height = true; //fix the height
width = 20; //give it a width
fixed_width_font = true; //fix the font width
} //end list box
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Fixed_Width_Font


http://www.afralisp.com/lispa/lisp49ai.htm (1 of 2) [23/03/2005 05:53:18 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Fixed_Width_Font
http://www.afralisp.com/lispa/lisp49ai.htm (2 of 2) [23/03/2005 05:53:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
initial_focus
Initial Focus.
This attribute specifies the the key of the tile within the dialogue box that receives the initial focus when the
dialogue is started.
Possible value is a quoted string.
Default: None.
DCL Code Sample
lisp49t : dialog { //dialog name
label = "intial_focus" ; //give it a label
initial_focus = "btn1"; //set focus
: button { //define button
key = "btn1"; //give it a name
label = "Initial Focus"; //give it a label
alignment = centered; //center it
fixed_width = true; //fix the width
} //end button
: button { //define button
key = "btn2"; //give it a name
label = "Not Focused"; //give it a label
alignment = centered; //center it
fixed_width = true; //fix the width
} //end button
spacer; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Initial_Focus


http://www.afralisp.com/lispa/lisp49t.htm (1 of 2) [23/03/2005 05:53:19 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Initial_Focus
http://www.afralisp.com/lispa/lisp49t.htm (2 of 2) [23/03/2005 05:53:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
is_cancel
Is_Cancel.
This attribute specifies whether the button is selected when the user presses
the cancel key (Esc or Ctrl+C). Possible values are true or false.
Default: false.
Only one button in a dialogue box can have the 'is_cancel' attribute set to true.
DCL Code Sample
lisp49v : dialog { //dialog name
label = "is_cancel" ; //give it a label
: button { //define button
label = "Press Escape"; //give it a label
key = "cancel"; //give it a name
fixed_width = true; //fix the width
is_cancel = true; //make it the cancel key
} //end button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Is_Cancel
http://www.afralisp.com/lispa/lisp49v.htm (1 of 2) [23/03/2005 05:53:21 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Is_Cancel
http://www.afralisp.com/lispa/lisp49v.htm (2 of 2) [23/03/2005 05:53:21 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
is_default
Is_Default.
This attribute specifies whether the button is the default button selected ("pushed") when the user
presses the accept key. (normally "Enter").
Possible values are true or false.
Default: false.
Only one button in a dialogue box can have the 'is_default' attribute set to true.
DCL Code Sample
lisp49w : dialog { //dialog name
label = "is_default" ; //give it a label
: button { //define button
label = "Press Enter"; //give it a label
key = "accept"; //give it a name
fixed_width = true; //fix the width
is_default = true; //make it the default key
} //end button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Is_Default
http://www.afralisp.com/lispa/lisp49w.htm (1 of 2) [23/03/2005 05:53:22 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Is_Default
http://www.afralisp.com/lispa/lisp49w.htm (2 of 2) [23/03/2005 05:53:22 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
label
A couple of Labels.
This attribute specifies the the text displayed within tile. Possible value is a quoted string.
Default: A blank string, " ".
The label can specify the mnemonic for a tile by preceding one of the letters of
the label with the ampersand character. (&)
DCL Code Sample
lisp49x : dialog { //dialog name
label = "label" ; //give it a label
: boxed_column { //define a boxed column
label = "This is a Label"; //give it a label
: toggle { //define a toggle
label = "Another Label"; //give it a label
key = "tog1"; //give it a name
} //end toggle
: toggle { //define a toggle
label = "Label with a &Mnemonic"; //give it a label
key = "tog2"; //give it a name
} //end toggle
: button { //define button
label="A Button Label"; //give it a label
fixed_width=true; //fix the width
alignment=centered; //align right
} //end button
} //end boxed column
spacer; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Label


http://www.afralisp.com/lispa/lisp49x.htm (1 of 2) [23/03/2005 05:53:23 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Label
http://www.afralisp.com/lispa/lisp49x.htm (2 of 2) [23/03/2005 05:53:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
layout
Vertical Layout.
This attribute specifies the orientation of a slider. Possible values are horizontal
or vertical. For horizontal sliders, the value increases from left to right.
For vertical sliders, it increases from bottom to top.
Default : horizontal.
DCL Code Sample
lisp49y : dialog { //dialog name
label = "layout" ; //give it a label
: row { //define row
: list_box { //define list box
key = "lb1"; //give it a name
list = "A\nF\nR\nA\nL\nI\nS\nP"; //the list
height = 8; //give it a height
fixed_height = true; //fix the height
width = 4; //give it a width
fixed_width = true; //fix the width
} //end list box
: column { //define column
: slider { //define slider
layout = vertical; //make it vertical
key = "myslider" ; //give it a name
max_value = 10; //upper value
min_value = 0; //lower value
value = "5"; //initial value
big_increment = 2; //define big increment
alignment = right; //align it right
} //end slider
: edit_box { //define edit box
key = "eb1" ; //give it a name
edit_width = 2 ; //2 characters only
} //end edit box
} //end column
DCL Tile Attributes-Layout
http://www.afralisp.com/lispa/lisp49y.htm (1 of 2) [23/03/2005 05:53:24 p.m.]
} //end row
ok_only ; //predefined OK button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Layout
http://www.afralisp.com/lispa/lisp49y.htm (2 of 2) [23/03/2005 05:53:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
list
List with Tabs.
This attribute specifies the initial set of lines (choices) to be placed in the 'popup_list' or 'list_box'. Possible
value is a quoted string.
Default : None.
Lines are separated by a new line symbol (\n). Tab characters (\t) can occur
within each line.
DCL Code Sample
lisp49z : dialog { //dialog name
label = "list" ; //give it a label
: list_box { //define list box
key = "lb1"; //give it a name
list = "A\tB\nC\tD\nE\tF\nG\tH"; //the list
tabs = "2 4"; //set tabs
height = 5; //give it a height
width = 6; //give it a width
fixed_width = true; //fix the width
fixed_height = true; //fix the height
alignment = centered; //center it
} //end list box
spacer ; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-List


http://www.afralisp.com/lispa/lisp49z.htm (1 of 2) [23/03/2005 05:53:26 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-List
http://www.afralisp.com/lispa/lisp49z.htm (2 of 2) [23/03/2005 05:53:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
max_value
Maximum Value = 50.
This attribute specifies the upper range of values that a slider returns.
Default: 10000.
This value must be no greater than 32767.
DCL Code Sample
lisp49aa : dialog { //dialog name
label = "max_value" ; //give it a label
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 50; //upper value
min_value = -50; //lower value
value = "50"; //initial value
big_increment = 5; //define big increment
} //end slider
: row { //define row

: text { //define text
value = "Min Value"; //give it a value
} //end text
: text { //define text
value = " "; //give it a value
} //end text
: text { //define text
value = "Max Value"; //give it a value
} //end text
} //end row
ok_cancel ; //predefined OK/Cancel button
DCL Tile Attributes-Max_Value
http://www.afralisp.com/lispa/lisp49aa.htm (1 of 2) [23/03/2005 05:53:27 p.m.]
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Max_Value
http://www.afralisp.com/lispa/lisp49aa.htm (2 of 2) [23/03/2005 05:53:27 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
min_value
Minimum Value = -50.
This attribute specifies the lower range of values that a slider returns.
Default: 0.
This value must be no less than -32767. The 'min_value' can be greater than the
'max_value'. This reverses the order in which these values appear on the screen. (Platform dependent).
DCL Code Sample
lisp49ab : dialog { //dialog name
label = "min_value" ; //give it a label
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 50; //upper value
min_value = -50; //lower value
value = "50"; //initial value
big_increment = 5; //define big increment
} //end slider
: row { //define row

: text { //define text
value = "Min Value"; //give it a value
} //end text
: text { //define text
value = " "; //give it a value
} //end text
: text { //define text
value = "Max Value"; //give it a value
} //end text
} //end row
ok_cancel ; //predefined OK/Cancel button
DCL Tile Attributes-Min_Value
http://www.afralisp.com/lispa/lisp49ab.htm (1 of 2) [23/03/2005 05:53:28 p.m.]
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Min_Value
http://www.afralisp.com/lispa/lisp49ab.htm (2 of 2) [23/03/2005 05:53:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
multiple_select
Multiple Select.
This attribute specifies whether multiple items in a 'list_box' can be selected
(and highlighted) at the same time. Possible values are true or false.
Default : false.
The method of selected multiple items is platform dependent. (On Windows you hold down the 'Ctrl' or 'Shift'
key whilst selecting.)
DCL Code Sample
lisp49ac : dialog { //dialog name
label = "multiple_select" ; //give it a label
: list_box { //define list box
key = "lb1"; //give it a name
list = "Steel\nConcrete\nWood\nPlastic";//the list
height = 5; //give it a height
width = 10; //give it a width
fixed_width = true; //fix the width
fixed_height = true; //fix the height
alignment = centered; //center it
multiple_select = true; //allow multiple select
} //end list box
spacer ; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
DCL Tile Attributes-Multiple Select
http://www.afralisp.com/lispa/lisp49ac.htm (1 of 2) [23/03/2005 05:53:29 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Multiple Select
http://www.afralisp.com/lispa/lisp49ac.htm (2 of 2) [23/03/2005 05:53:29 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
password_char
Password Character.
This attribute specifies the character to be used as a password character. If the
'password_char' is specified, that character is displayed in the 'edit_box' instead of the characters entered
by the user. The use of this attribute has no effect on the retrieval of the value entered by the user. It alters
only the display of the characters in the 'edit_box'.
DCL Code Sample
lisp49ad : dialog { //dialog name
label = "password_char" ; //give it a label
: edit_box { //define edit box
label = "Enter Password"; //give it a label
key = "eb1"; //give it a name
password_char = "*"; //password character
width = 6; //give it a width
edit_limit = 6; //limit to six characters
fixed_width = true; //fix the width
} //end edit box
spacer ; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
DCL Tile Attributes-Password_Char
http://www.afralisp.com/lispa/lisp49ad.htm (1 of 2) [23/03/2005 05:53:30 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Password_Char
http://www.afralisp.com/lispa/lisp49ad.htm (2 of 2) [23/03/2005 05:53:30 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
small_increment
Small Increment.
This attribute specifies the value that the slider will increase or decrease by, if you click the slider bar arrow
controls located at each end of the slider.
This value must be between the min_value, and the max_value.
Default value: One-hundredth of the total range.
DCL Code Sample
lisp49ae : dialog { //dialog name
label = "small_increment" ; //give it a label
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
small_increment = 2; //define small increment
big_increment = 5; //define big increment
} //end slider
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Small Increment


http://www.afralisp.com/lispa/lisp49ae.htm (1 of 2) [23/03/2005 05:53:32 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Small Increment
http://www.afralisp.com/lispa/lisp49ae.htm (2 of 2) [23/03/2005 05:53:32 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
tabs
List Box with Tabs.
This attribute specifies the placement of tabs in character width units.
Possible value is a quoted string containing integers or floating-point numbers separated by spaces.
Default = None.
These values are used for vertically aligning columns of text in a 'popup_list' or 'list_box'.
DCL Code Sample
lisp49af : dialog { //dialog name
label = "tabs" ; //give it a label
: list_box { //define a list box
key = "lb1"; //give it a name
label = "Select Bolt Type:"; //give it a label
allow_accept = true; //allow double clicking
tabs = "8 16 24"; //set tabs
list = "M20\t40LG\tGr. 8,8\n
M16\t30LG\tGr. 4,6\n
M30\t60LG\tGr. 8,8\n
M12\t35LG\tGr. 4,6\n
M8\t45LG\tGr. 8,8"; //define the list
height = 6; //give it a height
fixed_height = true; //fix the height
} //end list box
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Tile Attributes-Tabs


http://www.afralisp.com/lispa/lisp49af.htm (1 of 2) [23/03/2005 05:53:33 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Tabs
http://www.afralisp.com/lispa/lisp49af.htm (2 of 2) [23/03/2005 05:53:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
tab_truncate
List Box with Tabs NOT Truncated.
List Box with Tabs Truncated.
This attribute specifies whether the text in a 'list_box' or 'popup_list' is truncated if it is larger than the
associated tab stop.
Possible values are true or false.
Default : false.
DCL Code Sample
lisp49ag : dialog { //dialog name
label = "tab_truncate" ; //give it a label
: list_box { //define a list box
key = "lb1"; //give it a name
label = "Choose Date:"; //give it a label
allow_accept = true; //allow double clicking
tabs = "5 16 24"; //set tabs
list = "Jan\t28th\t1999\n
Feb\t16th\t1997\n
September\t6th\t2000\n
Jul\t14th\t1998\n
Mar\t12th\t1996"; //define list
tab_truncate = true; //truncate
height = 6; //give it a height
fixed_height = true; //fix the height
} //end list box
DCL Tile Attributes-Tab_Truncate
http://www.afralisp.com/lispa/lisp49ag.htm (1 of 2) [23/03/2005 05:53:35 p.m.]
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Tab_Truncate
http://www.afralisp.com/lispa/lisp49ag.htm (2 of 2) [23/03/2005 05:53:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
value
Value.
This attribute specifies the initial value of a tile. Possible value is a quoted string. The meaning of a tile's
value varies depending on the kind of tile. The value of a tile can change at run-time, with user input or
'set_tile' calls.
DCL Code Sample
lisp49ah : dialog { //dialog name
label = "value" ; //give it a label
: edit_box { //define edit box
key = "eb1"; //give it a name
value = "100.00"; //give it a value
label = "This has a value"; //give it a label
width = 6; //give it a width
fixed_width = true; //fix the width
} //end edit box
: edit_box { //define edit box
key = "eb2"; //give it a name
label = "This has nothing"; //give it a label
width = 6; //give it a width
fixed_width = true; //fix the width
} //end edit box
spacer; //define a space
: toggle { //define a toggle
key = "tog1"; //give it a name
value = "1"; //give it a value
label = "This has value"; //give it a label
} //end toggle
: toggle { //define a toggle
key = "tog2"; //give it a name
label = "This has no value"; //give it a label
} //end toggle
spacer; //define a space
DCL Tile Attributes-Value
http://www.afralisp.com/lispa/lisp49ah.htm (1 of 2) [23/03/2005 05:53:36 p.m.]
ok_cancel ; //predefined OK/Cancel button
} //end dialog

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Tile Attributes-Value
http://www.afralisp.com/lispa/lisp49ah.htm (2 of 2) [23/03/2005 05:53:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Dialog Box Layout - Page II.
Home Page I
Right, now sit up straight and pay attention.
Open a new file and copy and paste this into it :
afra1 : dialog {
label ="B" ;
: column {
: row {
: text {label ="No";}
: text {label ="Chainage";}
: text {label ="Existing";}
: text {label ="Chainage";}
: text {label ="Proposed";}
}
: row {
: text {label =" 1";}
: edit_box {key =eb1; width =7; value ="000.000";}
: edit_box {key =eb1a; width =7; value ="00.000";}
: edit_box {key =eb1b; width =7; value ="000.000";}
: edit_box {key =eb1c; width =7; value ="00.000";}
}
: row {
: text {label =" 2";}
: edit_box {key =eb2; width =7; value ="000.000";}
: edit_box {key =eb2a; width =7; value ="00.000";}
: edit_box {key =eb2b; width =7; value ="000.000";}
: edit_box {key =eb2c; width =7; value ="00.000";}
}
: row {
: text {label =" 3";}
: edit_box {key =eb3; width =7; value ="000.000";}
: edit_box {key =eb3a; width =7; value ="00.000";}
: edit_box {key =eb3b; width =7; value ="000.000";}
: edit_box {key =eb3c; width =7; value ="00.000";}
}
: row {
: text {label =" 4";}
: edit_box {key =eb4; width =7; value ="000.000";}
: edit_box {key =eb4a; width =7; value ="00.000";}
: edit_box {key =eb4b; width =7; value ="000.000";}
: edit_box {key =eb4c; width =7; value ="00.000";}
}
: row {
: text {label =" 5";}
: edit_box {key =eb5; width =7; value ="000.000";}
: edit_box {key =eb5a; width =7; value ="00.000";}
: edit_box {key =eb5b; width =7; value ="000.000";}
: edit_box {key =eb5c; width =7; value ="00.000";}
}
: row {
: text {label =" 6";}
: edit_box {key =eb6; width =7; value ="000.000";}
: edit_box {key =eb6a; width =7; value ="00.000";}
: edit_box {key =eb6b; width =7; value ="000.000";}
: edit_box {key =eb6c; width =7; value ="00.000";}
}
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (1 of 8) [23/03/2005 05:53:45 p.m.]
: row {
: text {label =" 7";}
: edit_box {key =eb7; width =7; value ="000.000";}
: edit_box {key =eb7a; width =7; value ="00.000";}
: edit_box {key =eb7b; width =7; value ="000.000";}
: edit_box {key =eb7c; width =7; value ="00.000";}
}
: row {
: text {label =" 8";}
: edit_box {key =eb8; width =7; value ="000.000";}
: edit_box {key =eb8a; width =7; value ="00.000";}
: edit_box {key =eb8b; width =7; value ="000.000";}
: edit_box {key =eb8c; width =7; value ="00.000";}
}
: row {
: text {label =" 9";}
: edit_box {key =eb9; width =7; value ="000.000";}
: edit_box {key =eb9a; width =7; value ="00.000";}
: edit_box {key =eb9b; width =7; value ="000.000";}
: edit_box {key =eb9c; width =7; value ="00.000";}
}
: row {
: text {label ="10";}
: edit_box {key =eb10; width =7; value ="000.000";}
: edit_box {key =eb10a; width =7; value ="00.000";}
: edit_box {key =eb10b; width =7; value ="000.000";}
: edit_box {key =eb10c; width =7; value ="00.000";}
}
: row {
: text {label ="11";}
: edit_box {key =eb11; width =7; value ="000.000";}
: edit_box {key =eb11a; width =7; value ="00.000";}
: edit_box {key =eb11b; width =7; value ="000.000";}
: edit_box {key =eb11c; width =7; value ="00.000";}
}
: row {
: text {label ="12";}
: edit_box {key =eb12; width =7; value ="000.000";}
: edit_box {key =eb12a; width =7; value ="00.000";}
: edit_box {key =eb12b; width =7; value ="000.000";}
: edit_box {key =eb12c; width =7; value ="00.000";}
}
: row {
: text {label ="13";}
: edit_box {key =eb13; width =7; value ="000.000";}
: edit_box {key =eb13a; width =7; value ="00.000";}
: edit_box {key =eb13b; width =7; value ="000.000";}
: edit_box {key =eb13c; width =7; value ="00.000";}
}
: row {
: text {label ="14";}
: edit_box {key =eb14; width =7; value ="000.000";}
: edit_box {key =eb14a; width =7; value ="00.000";}
: edit_box {key =eb14b; width =7; value ="000.000";}
: edit_box {key =eb14c; width =7; value ="00.000";}
}
: row {
: text {label ="15";}
: edit_box {key =eb15; width =7; value ="000.000";}
: edit_box {key =eb15a; width =7; value ="00.000";}
: edit_box {key =eb15b; width =7; value ="000.000";}
: edit_box {key =eb15c; width =7; value ="00.000";}
}
}
ok_only;

}
Save this as "afra1.dcl". Now view the dialog :
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (2 of 8) [23/03/2005 05:53:45 p.m.]
Did you notice how we where forced to include an "OK" button within the dialog?
Don't worry though, we'll remove that later.
Ok, on to the next section. Open a new file and add this coding :
afra2 : dialog {
label ="C" ;
: column {
: edit_box {key ="eb16"; label ="Base Level";
edit_width =12;value ="00.000";}
: edit_box {key ="eb17"; label ="Top Level";
edit_width =12; value ="00.000";}
: edit_box {key ="eb18"; label ="Horizontal Scale 1 :";
edit_width =12; value ="200";}
: edit_box {key ="eb19"; label ="Vertical Scale 1 :";
edit_width =12; value ="50";}
: edit_box {key ="eb20"; label ="Title";
edit_width =20;value ="Chainage";}
: toggle {key ="tg1"; value =1;
label ="Description On/Off";}
}

ok_only;
}

Save this as "afra2.dcl" and then display it. It will look like this :
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (3 of 8) [23/03/2005 05:53:45 p.m.]
Now let's add the the other two text boxes :
afra2 : dialog {
label = "C" ;
: column {
: edit_box {key = "eb16"; label = "Base Level";
edit_width = 12;value = "00.000";}
: edit_box {key = "eb17"; label = "Top Level";
edit_width = 12; value = "00.000";}
: edit_box {key = "eb18"; label = "Horizontal Scale 1 :";
edit_width = 12; value = "200";}
: edit_box {key = "eb19"; label = "Vertical Scale 1 :";
edit_width = 12; value = "50";}
: edit_box {key = "eb20"; label = "Title";
edit_width = 20; value = "Chainage";}
: toggle {key = "tg1"; value = 1;
label = "Description On/Off";}
: edit_box {key = "eb21"; label = "Path";
edit_width = 20; value = "C:\\";}
: edit_box {key = "eb22"; label = "File Name";
edit_width = 20; value = "default";}
}

ok_only;
}
This will give us this :
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (4 of 8) [23/03/2005 05:53:45 p.m.]
Ok, time now to put this all together. This is what we need to do :

The following coding is a merged version of the three dialog boxes that you have just created:
afralisp : dialog {
label ="Cross Section Level Information" ;
: row {
: boxed_column {
: row {
: text {label ="No";}
: text {label ="Chainage";}
: text {label ="Existing";}
: text {label ="Chainage";}
: text {label ="Proposed";}
}
: row {
: text {label =" 1";}
: edit_box {key =eb1; width =7; value ="000.000";}
: edit_box {key =eb1a; width =7; value ="00.000";}
: edit_box {key =eb1b; width =7; value ="000.000";}
: edit_box {key =eb1c; width =7; value ="00.000";}
}
: row {
: text {label =" 2";}
: edit_box {key =eb2; width =7; value ="000.000";}
: edit_box {key =eb2a; width =7; value ="00.000";}
: edit_box {key =eb2b; width =7; value ="000.000";}
: edit_box {key =eb2c; width =7; value ="00.000";}
}
: row {
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (5 of 8) [23/03/2005 05:53:45 p.m.]
: text {label =" 3";}
: edit_box {key =eb3; width =7; value ="000.000";}
: edit_box {key =eb3a; width =7; value ="00.000";}
: edit_box {key =eb3b; width =7; value ="000.000";}
: edit_box {key =eb3c; width =7; value ="00.000";}
}
: row {
: text {label =" 4";}
: edit_box {key =eb4; width =7; value ="000.000";}
: edit_box {key =eb4a; width =7; value ="00.000";}
: edit_box {key =eb4b; width =7; value ="000.000";}
: edit_box {key =eb4c; width =7; value ="00.000";}
}
: row {
: text {label =" 5";}
: edit_box {key =eb5; width =7; value ="000.000";}
: edit_box {key =eb5a; width =7; value ="00.000";}
: edit_box {key =eb5b; width =7; value ="000.000";}
: edit_box {key =eb5c; width =7; value ="00.000";}
}
: row {
: text {label =" 6";}
: edit_box {key =eb6; width =7; value ="000.000";}
: edit_box {key =eb6a; width =7; value ="00.000";}
: edit_box {key =eb6b; width =7; value ="000.000";}
: edit_box {key =eb6c; width =7; value ="00.000";}
}
: row {
: text {label =" 7";}
: edit_box {key =eb7; width =7; value ="000.000";}
: edit_box {key =eb7a; width =7; value ="00.000";}
: edit_box {key =eb7b; width =7; value ="000.000";}
: edit_box {key =eb7c; width =7; value ="00.000";}
}
: row {
: text {label =" 8";}
: edit_box {key =eb8; width =7; value ="000.000";}
: edit_box {key =eb8a; width =7; value ="00.000";}
: edit_box {key =eb8b; width =7; value ="000.000";}
: edit_box {key =eb8c; width =7; value ="00.000";}
}
: row {
: text {label =" 9";}
: edit_box {key =eb9; width =7; value ="000.000";}
: edit_box {key =eb9a; width =7; value ="00.000";}
: edit_box {key =eb9b; width =7; value ="000.000";}
: edit_box {key =eb9c; width =7; value ="00.000";}
}
: row {
: text {label ="10";}
: edit_box {key =eb10; width =7; value ="000.000";}
: edit_box {key =eb10a; width =7; value ="00.000";}
: edit_box {key =eb10b; width =7; value ="000.000";}
: edit_box {key =eb10c; width =7; value ="00.000";}
}
: row {
: text {label ="11";}
: edit_box {key =eb11; width =7; value ="000.000";}
: edit_box {key =eb11a; width =7; value ="00.000";}
: edit_box {key =eb11b; width =7; value ="000.000";}
: edit_box {key =eb11c; width =7; value ="00.000";}
}
: row {
: text {label ="12";}
: edit_box {key =eb12; width =7; value ="000.000";}
: edit_box {key =eb12a; width =7; value ="00.000";}
: edit_box {key =eb12b; width =7; value ="000.000";}
: edit_box {key =eb12c; width =7; value ="00.000";}
}
: row {
: text {label ="13";}
: edit_box {key =eb13; width =7; value ="000.000";}
: edit_box {key =eb13a; width =7; value ="00.000";}
: edit_box {key =eb13b; width =7; value ="000.000";}
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (6 of 8) [23/03/2005 05:53:45 p.m.]
: edit_box {key =eb13c; width =7; value ="00.000";}
}
: row {
: text {label ="14";}
: edit_box {key =eb14; width =7; value ="000.000";}
: edit_box {key =eb14a; width =7; value ="00.000";}
: edit_box {key =eb14b; width =7; value ="000.000";}
: edit_box {key =eb14c; width =7; value ="00.000";}
}
: row {
: text {label ="15";}
: edit_box {key =eb15; width =7; value ="000.000";}
: edit_box {key =eb15a; width =7; value ="00.000";}
: edit_box {key =eb15b; width =7; value ="000.000";}
: edit_box {key =eb15c; width =7; value ="00.000";}
}
}

: boxed_column {
: edit_box {key ="eb16"; label ="Base Level";
edit_width =12;value ="00.000";}
: edit_box {key ="eb17"; label ="Top Level";
edit_width =12; value ="00.000";}
: edit_box {key ="eb18"; label ="Horizontal Scale 1 :";
edit_width =12; value ="200";}
: edit_box {key ="eb19"; label ="Vertical Scale 1 :";
edit_width =12; value ="50";}
: edit_box {key ="eb20"; label ="Title";
edit_width =20; value ="Chainage";}
: toggle {key ="tg1"; value =1;
label ="Description On/Off";}
: edit_box {key ="eb21"; label ="Path";
edit_width =20; value ="C:\\";}
: edit_box {key ="eb22"; label ="File Name";
edit_width =20; value ="default";}

: row {
: button {label ="OK"; key ="accept"; mnemonic ="O";
alignment =centered; width =12; is_default =true;}
: button {label ="Cancel"; key ="cancel";mnemonic ="C";
alignment =centered; width =12;}
}
: row {
: button {label ="Save"; key ="save";
mnemonic ="S"; alignment =centered; width =12;}
: button {label ="Load";key ="load";
mnemonic ="L"; alignment =centered; width =12;}
}
: row {
: button {label ="Help..."; key ="help";
mnemonic ="H"; alignment =centered; width =12;}
: button {label ="About..."; key ="About";
mnemonic ="H"; alignment =centered; width =12;}
}
}
}
}
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (7 of 8) [23/03/2005 05:53:45 p.m.]
Save this as "AfraLisp.dcl".
Your merged dialog will now look like this :
Ok, I admit that it's not exactly the same but it's as close as dammit.
You could, if you are that way inclined, mess around with boxed columns, boxed rows, and spacers, to get
a closer match, and if you feel the need, then go for it!!!
Me, I'm out of here to fetch myself a beer.
Want to download the source coding? Just click here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Box Layout - Page II
http://www.afralisp.com/lisp/dlayout1.htm (8 of 8) [23/03/2005 05:53:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III. Page IV.
Dialogue Boxes - Step by Step - Page I.
To download source coding Click Here.
This tutorial will take you through all the steps of designing an AutoLISP routine with, a Dialogue Box Interface.
It will guide you through the coding of the DCL file, to the retrieval of the data from the Dialogue Box.
The dialogue box we will be designing will consist of the following :
A Radio Column consisting of 6 Radio Buttons to allow the user to choose the type of bolt. G
A Drop Down List Box for the size of the bolt. G
An Edit Box for the length of the slot. G
A Slider, also for the length of the slot. G
A Boxed Row containing 2 Toggle Buttons. G
An Edit Box to enter Notes. G
An OK/Cancel pre-defined set of tiles. G
An Image Tile. G
A Paragraph tile containing Text. G
Let's start with a very simple Dialogue Box containing simply, an OK button and a cancel button.
The dialogue box will look like this :
Let's look at the DCL coding for this dialogue :
samp1 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
ok_cancel ; //predifined OK/Cancel

} //end dialog
Note the use of the predefined OK/Cancel tile. This is a standard tile set as defined in the AutoCAD Base. DCL
File. (You can refer to the AutoCAD Customization Manual for more examples.)
Now for the AutoLISP coding that calls the dialogue and handles each tile :
(defun C:samp1 () ;define function

(setq dcl_id (load_dialog "samp1.dcl")) ;load dialog
(if (not (new_dialog "samp1" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(action_tile
"cancel" ;if cancel button pressed
Dialog Boxes
http://www.afralisp.com/lispa/lisp71.htm (1 of 5) [23/03/2005 05:53:48 p.m.]
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)
Let's add a paragraph of text to the dialogue. Only the DCL file changes here, the AutoLISP coding remains the
same except for the function name.
NOTE : //* preceding the comments denotes new coding :
The revised DCL coding looks like this :
samp2 : dialog { //dialog name
label = "Structural Holes" ; //give it a label

ok_cancel ; //predifined OK/Cancel
: paragraph { //*define paragraph
: text_part { //*define text
label = "Designed and Created"; //*give it some text
} //*end text
: text_part { //*define more text
label = "by Kenny Ramage"; //*some more text
} //*end text
} //*end paragraph
} //end dialog
And the coding remains the same except for name change :
(defun C:samp2 () ;define function

(setq dcl_id (load_dialog "samp2.dcl")) ;load dialog
(if (not (new_dialog "samp2" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(action_tile
"cancel" ;if cancel button pressed
Dialog Boxes
http://www.afralisp.com/lispa/lisp71.htm (2 of 5) [23/03/2005 05:53:48 p.m.]
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)
Now we will add an image tile to make it look nice :
The DCL coding :
samp3 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //*define image tile
key = "im" ; //*give it a name
height = 1.0 ; //*and a height
width = 1.0 ; //*and now a width
} //*end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
} //end row

} //end dialog
Because we haven't given the image tile a fixed height or a fixed width, it will expand or contract to suit the
available space. Now the AutoLISP coding :
(defun C:samp3 () ;define function
(setq dcl_id (load_dialog "samp3.dcl")) ;load dialog
(if (not (new_dialog "samp3" dcl_id) ;test for dialog
);not
Dialog Boxes
http://www.afralisp.com/lispa/lisp71.htm (3 of 5) [23/03/2005 05:53:48 p.m.]
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;*get image tile width
h (dimy_tile "im") ;*get image tile height
);setq
(start_image "im") ;*start the image
(fill_image 0 0 w h 5) ;*fill it with blue
(end_image) ;*end image
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)
Note the following coding :
(setq w (dimx_tile "im") ;*get image tile width
h (dimy_tile "im") ;*get image tile height
This retrieves the width and height of the image tile and allocates them to variables w and h respectively.
The next code fragment uses these variables to "draw" the image tile.
The number "5" denotes the AutoCAD colour "Blue" :
(start_image "im") ;*start the image
(fill_image 0 0 w h 5) ;*fill it with blue
(end_image) ;*end image
Home. Page II. Page III. Page IV.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Dialog Boxes
http://www.afralisp.com/lispa/lisp71.htm (4 of 5) [23/03/2005 05:53:48 p.m.]
Search
Powered by CORBIMITE.com
Dialog Boxes
http://www.afralisp.com/lispa/lisp71.htm (5 of 5) [23/03/2005 05:53:48 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III. Page IV.
Dialogue Boxes - Step by Step - Page II.
We are now going to add a set of radio buttons enclosed in a radio column.
This is to allow the user to select the type of bolt.
The DCL coding :
samp4 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
:boxed_radio_column { //*define radio column
label = "Type" ; //*give it a label
: radio_button { //*define radion button
key = "rb1" ; //*give it a name
label = "Bolt Holes &Site" ; //*give it a label
value = "1" ; //*switch it on
} //*end definition
: radio_button { //*define radio button
key = "rb2" ; //*give it a name
label = "Bolt Holes Sho&p" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "rb3" ; //*give it a name
label = "Bolt Holes &Hidden" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "rb4" ; //*give it a name
label = "Bolt Holes &Ctsnk" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "rb5" ; //*give it a name
label = "Bolt Holes &Elevation" ; //*give it a label
} //*end definition
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (1 of 6) [23/03/2005 05:53:49 p.m.]
: radio_button { //*define radion button
key = "rb6" ; //*give it a name
label = "Bolt Holes &Slotted" ; //*give it a label
} //*end definition
} //*end radio column
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
} //end row

} //end dialog
And the AutoLISP coding :
(defun C:samp4 () ;define function
(setq dcl_id (load_dialog "samp4.dcl")) ;load dialog
(if (not (new_dialog "samp4" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
(action_tile "rb1" "(setq hole \"site\")") ;*store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;*store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;*store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;*store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;*store hole type
(action_tile "rb6" "(setq hole \"slot\")") ;*store hole type
(action_tile
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (2 of 6) [23/03/2005 05:53:49 p.m.]
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
);defun C:samp
(princ)
Now we'll add a drop down list so that we can select the bolt size.
The DCL coding :
samp5 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
: row { //*define row
:boxed_radio_column { //define radio column
label = "Type" ; //give it a label
: radio_button { //define radion button
key = "rb1" ; //give it a name
label = "Bolt Holes &Site" ; //give it a label
value = "1" ; //switch it on
} //end definition
: radio_button { //define radio button
key = "rb2" ; //give it a name
label = "Bolt Holes Sho&p" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb3" ; //give it a name
label = "Bolt Holes &Hidden" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb4" ; //give it a name
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (3 of 6) [23/03/2005 05:53:49 p.m.]
label = "Bolt Holes &Ctsnk" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb5" ; //give it a name
label = "Bolt Holes &Elevation" ; //give it a label
} //end definition
: radio_button { //define radion button
key = "rb6" ; //give it a name
label = "Bolt Holes &Slotted" ; //give it a label
} //end definition
} //end radio column
: boxed_column { //*define boxed column
label = "&Size"; //*give it a label
: popup_list { //*define popup list
key = "selections"; //*give it a name
value = "5" ; //*initial value
} //*end list
} //*end boxed column
} //*end row
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
} //end row

} //end dialog
Note how we have put the Radio Column and the Drop Down List box into a Row. Looks good hey....Now the
AutoLISP coding :
(defun C:samp5 () ;define function
(setq siz "M20") ;*preset hole size
(setq NAMES '("M6" "M8" "M10" "M12"
"M16" "M20" "M24" "M30") ;*define list
);setq
(setq dcl_id (load_dialog "samp5.dcl")) ;load dialog
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (4 of 6) [23/03/2005 05:53:49 p.m.]
(if (not (new_dialog "samp5" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
(start_list "selections") ;*start the list box
(mapcar 'add_list NAMES) ;*fill the list box
(end_list) ;*end list
(action_tile "rb1" "(setq hole \"site\")") ;store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;store hole type
(action_tile "rb6" "(setq hole \"slot\")") ;store hole type

(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
(strcat ;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))" ;*get list selection
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);strcat
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if userclick ;*check O.K. was selected
(progn
(setq SIZ (fix SIZ)) ;*convert to integer
(setq SIZ (nth SIZ NAMES)) ;*get the size
);progn
);if userclick
(princ)
);defun C:samp
(princ)
Page I. Home. Page III. Page IV.
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (5 of 6) [23/03/2005 05:53:49 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes II
http://www.afralisp.com/lispa/lisp72.htm (6 of 6) [23/03/2005 05:53:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home. Page IV.
Dialogue Boxes - Step by Step - Page III.
Let us now add an Edit Box and a slider so that the user can enter the size of the slot, if a slotted hole is
chosen.
Note that the Edit Box and Slider only become active if the slotted bolt radio button is selected.
The DCL coding :
samp6 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
: row { //define row
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (1 of 13) [23/03/2005 05:53:51 p.m.]
:boxed_radio_column { //define radio column
label = "Type" ; //give it a label
: radio_button { //define radion button
key = "rb1" ; //give it a name
label = "Bolt Holes &Site" ; //give it a label
value = "1" ; //switch it on
} //end definition
: radio_button { //define radio button
key = "rb2" ; //give it a name
label = "Bolt Holes Sho&p" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb3" ; //give it a name
label = "Bolt Holes &Hidden" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb4" ; //give it a name
label = "Bolt Holes &Ctsnk" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb5" ; //give it a name
label = "Bolt Holes &Elevation" ; //give it a label
} //end definition
: radio_button { //define radion button
key = "rb6" ; //give it a name
label = "Bolt Holes &Slotted" ; //give it a label
} //end definition
} //end radio column
: boxed_column { //define boxed column
label = "&Size"; //give it a label
: popup_list { //define popup list
key = "selections"; //give it a name
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (2 of 13) [23/03/2005 05:53:51 p.m.]
value = "5" ; //initial value
} //end list
} //end boxed column
} //end row
: edit_box { //*define edit box
key = "eb1" ; //*give it a name
label = "Slot &Length (O/All Slot)" ; //*give it a label
edit_width = 6 ; //*6 characters only
} //*end edit box
: slider { //*defin slider
key = "myslider" ; //*give it a name
max_value = 100; //*upper value
min_value = 0; //*lower value
value = "50"; //*initial value
} //*end slider
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (3 of 13) [23/03/2005 05:53:51 p.m.]
} //end row

} //end dialog
And now the AutoLISP coding :
(defun C:samp6 () ;define function
(setq lngth 50.0) ;*preset slot length
(setq hole "site") ;preset hole type
(setq siz "M20") ;preset hole size
(setq NAMES '("M6" "M8" "M10" "M12"
"M16" "M20" "M24" "M30") ;define list
);setq
(setq dcl_id (load_dialog "samp6.dcl")) ;load dialog
(if (not (new_dialog "samp6" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
(start_list "selections") ;start the list box
(mapcar 'add_list NAMES) ;fill the list box
(end_list) ;end list
(set_tile "eb1" "50") ;*put data into edit box
(mode_tile "eb1" 1) ;*disable edit box
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (4 of 13) [23/03/2005 05:53:51 p.m.]
(mode_tile "myslider" 1) ;*disable slider
(action_tile "myslider" ;*if user moves slider
"(slider_action $value $reason)") ;*pass arguments to slider_action
(action_tile "eb1" ;*is user enters slot length
"(ebox_action $value $reason)") ;*pass arguments to ebox_action
(defun slider_action (val why) ;*define function
(if (or (= why 2) (= why 1)) ;*check values
(set_tile "eb1" val))) ;*update edit box
(defun ebox_action (val why) ;*define function
(if (or (= why 2) (= why 1)) ;*check values
(set_tile "myslider" val))) ;*update slider
(action_tile "rb1" "(setq hole \"site\")") ;store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;store hole type
(action_tile "rb6" "(setq hole \"slot\") ;store hole type
(mode_tile \"eb1\" 0) ;*enable edit box
(mode_tile \"myslider\" 0) ;*enable slider
(mode_tile \"eb1\" 2)") ;*switch focus to edit box
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
(strcat ;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))" ;get list selection
"(setq lngth (atof (get_tile \"eb1\")))" ;*get slot length
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);strcat
);action tile
(start_dialog) ;start dialog
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (5 of 13) [23/03/2005 05:53:51 p.m.]
(unload_dialog dcl_id) ;unload
(if userclick ;check O.K. was selected
(progn
(setq SIZ (fix SIZ)) ;convert to integer
(setq SIZ (nth SIZ NAMES)) ;get the size
);progn
);if userclick
(princ)
);defun C:samp
(princ)
Now, for the fun of it, let's add some toggles :
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (6 of 13) [23/03/2005 05:53:51 p.m.]
Here is the DCL coding :
samp7 : dialog { //dialog name
label = "Structural Holes" ; //give it a label
: row { //define row
:boxed_radio_column { //define radio column
label = "Type" ; //give it a label
: radio_button { //define radion button
key = "rb1" ; //give it a name
label = "Bolt Holes &Site" ; //give it a label
value = "1" ; //switch it on
} //end definition
: radio_button { //define radio button
key = "rb2" ; //give it a name
label = "Bolt Holes Sho&p" ; //give it a label
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (7 of 13) [23/03/2005 05:53:51 p.m.]
} //end definition
: radio_button { //define radio button
key = "rb3" ; //give it a name
label = "Bolt Holes &Hidden" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb4" ; //give it a name
label = "Bolt Holes &Ctsnk" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb5" ; //give it a name
label = "Bolt Holes &Elevation" ; //give it a label
} //end definition
: radio_button { //define radion button
key = "rb6" ; //give it a name
label = "Bolt Holes &Slotted" ; //give it a label
} //end definition
} //end radio column
: boxed_column { //define boxed column
label = "&Size"; //give it a label
: popup_list { //define popup list
key = "selections"; //give it a name
value = "5" ; //initial value
} //end list
} //end boxed column
} //end row
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (8 of 13) [23/03/2005 05:53:51 p.m.]
: slider { //defin slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
} //end slider
:boxed_row { //*define boxed row
:toggle { //*define toggle
key = "tog1"; //*give it a name
label = "Ortho On/Off"; //*give it a label
} //*end toggle
:toggle { //*define toggle
key = "tog2"; //*give it a name
label = "Snap On/Off"; //*give it a label
} //*end definition
} //*end boxed row
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (9 of 13) [23/03/2005 05:53:52 p.m.]
} //end row

} //end dialog
And now the AutoLISP coding :
(defun C:samp7 () ;define function
(setq lngth 50.0) ;preset slot length
(setq hole "site") ;preset hole type
(setq siz "M20") ;preset hole size
(setq NAMES '("M6" "M8" "M10" "M12"
"M16" "M20" "M24" "M30") ;define list
);setq
(setq dcl_id (load_dialog "samp7.dcl")) ;load dialog
(if (not (new_dialog "samp7" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
(start_list "selections") ;start the list box
(mapcar 'add_list NAMES) ;fill the list box
(end_list) ;end list
(set_tile "eb1" "50") ;put dat into edit box
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (10 of 13) [23/03/2005 05:53:52 p.m.]
(mode_tile "eb1" 1) ;disable edit box
(mode_tile "myslider" 1) ;disable slider
(setq orth (itoa (getvar "orthomode"))) ;*get orthomode value
(set_tile "tog1" orth) ;*switch toggle on or off
(setq sna (itoa (getvar "snapmode"))) ;*get snap value
(set_tile "tog2" sna) ;*switch toggle on or off
(action_tile "myslider" ;if user moves slider
"(slider_action $value $reason)") ;pass arguments to slider_action
(action_tile "eb1" ;is user enters slot length
"(ebox_action $value $reason)") ;pass arguments to ebox_action
(defun slider_action (val why) ;define function
(if (or (= why 2) (= why 1)) ;check values
(set_tile "eb1" val))) ;update edit box
(defun ebox_action (val why) ;define function
(if (or (= why 2) (= why 1)) ;check values
(set_tile "myslider" val))) ;update slider
(action_tile "tog1" "(setq orth $value)") ;*get ortho toggle value
(action_tile "tog2" "(setq sna $value)") ;*get snap toggle value
(action_tile "rb1" "(setq hole \"site\")") ;store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;store hole type
(action_tile "rb6" "(setq hole \"slot\") ;store hole type
(mode_tile \"eb1\" 0) ;enable edit box
(mode_tile \"myslider\" 0) ;enable slider
(mode_tile \"eb1\" 2)") ;switch focus to edit box
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (11 of 13) [23/03/2005 05:53:52 p.m.]
"accept" ;if O.K. pressed
(strcat ;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))" ;get list selection
"(setq lngth (atof (get_tile \"eb1\")))" ;get slot length
"(setvar \"orthomode\" (atoi orth))" ;*ortho on/off
"(setvar \"snapmode\" (atoi sna))" ;*snap on/off
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);strcat
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if userclick ;check O.K. was selected
(progn
(setq SIZ (fix SIZ)) ;convert to integer
(setq SIZ (nth SIZ NAMES)) ;get the size
);progn
);if userclick
(princ)
);defun C:samp
(princ)
Page I. Page II. Home. Page IV.

Dialog Boxes III


http://www.afralisp.com/lispa/lisp73.htm (12 of 13) [23/03/2005 05:53:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes III
http://www.afralisp.com/lispa/lisp73.htm (13 of 13) [23/03/2005 05:53:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Page III. Home.
Dialogue Boxes - Step by Step - Page IV.
To finish off the box, we'll add an Edit Box so that the user can include some notes, if he so wishes.
The Complete DCL coding :
samp8 : dialog { //dialog name
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (1 of 7) [23/03/2005 05:53:53 p.m.]
label = "Structural Holes" ; //give it a label
: row { //define row
:boxed_radio_column { //define radio column
label = "Type" ; //give it a label
: radio_button { //define radion button
key = "rb1" ; //give it a name
label = "Bolt Holes &Site" ; //give it a label
value = "1" ; //switch it on
} //end definition
: radio_button { //define radio button
key = "rb2" ; //give it a name
label = "Bolt Holes Sho&p" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb3" ; //give it a name
label = "Bolt Holes &Hidden" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb4" ; //give it a name
label = "Bolt Holes &Ctsnk" ; //give it a label
} //end definition
: radio_button { //define radio button
key = "rb5" ; //give it a name
label = "Bolt Holes &Elevation" ; //give it a label
} //end definition
: radio_button { //define radion button
key = "rb6" ; //give it a name
label = "Bolt Holes &Slotted" ; //give it a label
} //end definition
} //end radio column
: boxed_column { //define boxed column
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (2 of 7) [23/03/2005 05:53:53 p.m.]
label = "&Size"; //give it a label
: popup_list { //define popup list
key = "selections"; //give it a name
value = "5" ; //initial value
} //end list
} //end boxed column
} //end row
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //defin slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
} //end slider
:boxed_row { //define boxed row
:toggle { //define toggle
key = "tog1"; //give it a name
label = "Ortho On/Off"; //give it a label
} //end toggle
:toggle { //define toggle
key = "tog2"; //give it a name
label = "Snap On/Off"; //give it a label
} //end definition
} //end boxed row
: edit_box { //*define edit box
key = "eb2" ; //*give it a name
label = "Notes :" ; //*give it a label
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (3 of 7) [23/03/2005 05:53:53 p.m.]
edit_width = 30 ; //*30 characters
} //*end edit box
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by Kenny Ramage"; //some more text
} //end text
} //end paragraph
} //end row

} //end dialog
And Now the Complete AutoLISP coding :
(defun C:samp8 () ;define function
(setq lngth 50.0) ;preset slot length
(setq hole "site") ;preset hole type
(setq siz "M20") ;preset hole size
(setq NAMES '("M6" "M8" "M10" "M12"
"M16" "M20" "M24" "M30") ;define list
);setq
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (4 of 7) [23/03/2005 05:53:53 p.m.]
(setq dcl_id (load_dialog "samp8.dcl")) ;load dialog
(if (not (new_dialog "samp8" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
(start_list "selections") ;start the list box
(mapcar 'add_list NAMES) ;fill the list box
(end_list) ;end list
(set_tile "eb1" "50") ;put dat into edit box
(mode_tile "eb1" 1) ;disable edit box
(mode_tile "myslider" 1) ;disable slider
(setq orth (itoa (getvar "orthomode"))) ;get orthomode value
(set_tile "tog1" orth) ;switch toggle on or off
(setq sna (itoa (getvar "snapmode"))) ;get snap value
(set_tile "tog2" sna) ;switch toggle on or off
(action_tile "myslider" ;if user moves slider
"(slider_action $value $reason)") ;pass arguments to slider_action
(action_tile "eb1" ;is user enters slot length
"(ebox_action $value $reason)") ;pass arguments to ebox_action
(defun slider_action (val why) ;define function
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (5 of 7) [23/03/2005 05:53:53 p.m.]
(if (or (= why 2) (= why 1)) ;check values
(set_tile "eb1" val))) ;update edit box
(defun ebox_action (val why) ;define function
(if (or (= why 2) (= why 1)) ;check values
(set_tile "myslider" val))) ;update slider
(action_tile "tog1" "(setq orth $value)") ;get ortho toggle value
(action_tile "tog2" "(setq sna $value)") ;get snap toggle value
(action_tile "rb1" "(setq hole \"site\")") ;store hole type
(action_tile "rb2" "(setq hole \"shop\")") ;store hole type
(action_tile "rb3" "(setq hole \"hid\")") ;store hole type
(action_tile "rb4" "(setq hole \"ctsk\")") ;store hole type
(action_tile "rb5" "(setq hole \"elev\")") ;store hole type
(action_tile "rb6" "(setq hole \"slot\") ;store hole type
(mode_tile \"eb1\" 0) ;enable edit box
(mode_tile \"myslider\" 0) ;enable slider
(mode_tile \"eb1\" 2)") ;switch focus to edit box
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
(strcat ;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))" ;get list selection
"(setq lngth (atof (get_tile \"eb1\")))" ;get slot length
"(setq notes (get_tile \"eb2\"))" ;*get notes
"(setvar \"orthomode\" (atoi orth))" ;ortho on/off
"(setvar \"snapmode\" (atoi sna))" ;snap on/off
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);strcat
);action tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (6 of 7) [23/03/2005 05:53:53 p.m.]
(if userclick ;check O.K. was selected
(progn
(setq SIZ (fix SIZ)) ;convert to integer
(setq SIZ (nth SIZ NAMES)) ;get the size
);progn
);if userclick
(princ)
);defun C:samp
(princ)
I have deliberately left all variables local, so that you can check their values at the command line.
That's it Folks....Enjoy your Dialogue Boxes..........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes IV
http://www.afralisp.com/lispa/lisp74.htm (7 of 7) [23/03/2005 05:53:53 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Dialog Boxes (or Dialogue as we British Say.)
So here we are. Dialogue boxes, the bane of all AutoLispers!
I must say they are quite a pain in the backside. This is when Visual Basic comes into its own.
Creating Dialogue Boxes using VB is a pure pleasure. (It's the rest that's a pain).
Anyway, I digress, so stuff the torpedoes and full steam ahead.
In this tutorial we are going to try to write a program that draws structural steel beams. The user will select
the size of beam from a list in a dialogue box. The data for the beam will then be retrieved from an external
data file. We will then draw the beam without touching our mouse or keyboard. (Pure Magic!!)
This is a complete working example of parametric programming.
First, lets start by writing the data file.
Create a file named BEAM.DAT containing the following :
You don't want to type? O.K. I'll be kind to you.
Click here for the source code - Beam.Zip (3 Kb)
**UNIVERSAL BEAMS DATA
**-----------------------
**H X B X T1 X T2 X R1
**-----------------------
*100x55x8
100.0,55.0,4.1,5.7,7.0
*120x64x10
120.0,64.0,4.4,6.3,7.0
*140x73x13
140.0,73.0,4.7,6.9,7.0
*160x82x16
160.0,82.0,5.0,7.4,9.0
*180x91x19
180.0,91.0,5.3,8.0,9.0
*200x100x22
200.0,100.0,5.6,8.5,12.0
*203x133x25
203.2,133.4,5.8,7.8,7.6
*203x133x30
206.8,133.8,6.3,9.6,7.6
*254x146x31
251.5,146.1,6.1,8.6,7.6
*254x146x37
256.0,146.4,6.4,10.9,7.6
*254x146x43
259.6,147.3,7.3,12.7,7.6
*305x102x25
**-------------------------
The first line (*100x55x8) is the name of the beam. (100 deep x 50 wide x 8 kg/m beam.)
The second line contains the physical dimensions that we need to draw the beam. (100.0,55.0,4.1,5.7,7.0)
(Height, width, web thickness, flange thickness and root radius.)
Next we need to write our DCL (Dialog Control Language) file.
Name this file BEAM.DCL. The coding is below :
beam : dialog { //dialog name
label = "Beams."; //dialog label
: list_box { //list box
label = "&Choose Section :"; //list box label
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (1 of 6) [23/03/2005 05:53:56 p.m.]
key = "selections"; //key to list
height = 12; //height
allow_accept = true ; //allow double clicking
}
ok_cancel ; //OK and Cancel Buttons
:text_part { //Text Label
label = "Designed and Created";
}
:text_part { //Text Label
label = "by Kenny Ramage";
}
}
As you can see, the first line is simply the name of the dialogue box.
Remember, this is the name that AutoLisp knows the box by.
The second line is the label attribute. This is the wording that you see at the top of the box when it is
displayed.
The third line displays a list box. This has it's own attributes :
A label attribute - Wording that is displayed above the list box.
A key attribute - This is the key that Autolisp uses to refer to the list.
Height - Simply the height of the box. If your list exceeds the height of the list box vertical scroll bars are
added.
Allow_accept - Instead of selecting an item from the list and then the OK
button, this allows you to select by double-clicking the list item.
The next section displays pre-constructed OK and Cancel buttons.
(Refer to the AutoCAD Customisation Manual for more examples of these.)
The last section is were you put your name, E-Mail address, Tel. Number, Thank You notes to me, etc.
Take note of were the { and } occur. DCL is very similar to AutoLISP in that what you open, you must close.
O.K Time for a rest and a cup of tea. (brantea!!)
What! Back already?
O.K. Now let us try and tie this lot together.
Time for the AutoLisp Coding. Ready, here we go :
(defun DTR (a) ;convert to radians
(* pi (/ a 180.0))
);defun
;;;*=================================================================
(defun C:BEAM (/) ;function defined
;;;*Initialise and Setup Dialogue Box

(setq OLDECHO (getvar "CMDECHO") ;store system variables
OLDBLIP (getvar "BLIPMODE")
OLDSNAP (getvar "OSMODE")
);setq
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq NAMES '("100x55x8" "120x64x10" "140x73x13" "160x82x16"
"180x91x19" "200x100x22" "203x133x25" "203x133x30"
"254x146x31" "254x146x37" "254x146x43");list of names
);setq
(setq dialogshow T) ;set flag
(setq dcl_id (load_dialog "beam.dcl")) ;initialise dialog box
(if (not ;check dcl exists
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (2 of 6) [23/03/2005 05:53:56 p.m.]
(new_dialog "beam" dcl_id) ;load into memory
);not
(setq dialogshow nil) ;if not exit
);if
(if dialogshow ;if dialog
(progn ;continue with programme
(start_list "selections") ;start list box
(mapcar 'add_list NAMES) ;add names from list
(end_list) ;end list box
(action_tile
"cancel" ;if cancel selected
"(done_dialog) (setq userclick1 nil)" ;close dialog, set flag
);action tile
(action_tile
"accept" ;if OK or double click
(strcat
"(progn (setq SIZA (atof (get_tile \"selections\")))" ;get size of beam
"(done_dialog) (setq userclick1 T))" ;close dialog and set flag
);strcat
);action tile
(start_dialog) ;display dialog
(unload_dialog dcl_id) ;unload dialog
(if userclick1 ;if OK or double click
(progn ;continue with programme
(setq SIZA (fix SIZA)) ;convert index to integer
(setq SIZA (nth SIZA NAMES)) ;retrieve name from list
;;;*Retrieve Data from External Data File
;;;*======================================================
;;;*This section is covered in the External Data Tutor
;;;*======================================================
(setq dlist nil
size (strcat "*" SIZA)
file (findfile "beam.dat")
fp (open file "r")
item (read-line fp)
);setq
(while item
(if (= item size)
(setq data (read-line fp)
item nil
);setq
(setq item (read-line fp))
);if
);while
;;;*Format List
(if data
(progn
(setq maxs (strlen data)
count 1
chrct 1
);setq
(while (< count maxs)
(if (/= "," (substr data count 1))
(setq chrct (1+ chrct))
(setq numb (atof (substr data (1+ (- count chrct)) chrct))
dlist (append dlist (list numb))
chrct 1
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (3 of 6) [23/03/2005 05:53:56 p.m.]
);setq
);if
(setq count (1+ count))
);while
(setq numb (atof (substr data (1+ (- count chrct))))
dlist (append dlist (list numb))
);setq
);progn
);if data
(close fp)
;;;*This routine draws the beam.
;;;*========================================================
;;;*This section is covered in the Calculating Points Tutor
;;;*========================================================
(mapcar 'set '(H B T1 T2 R1) dlist)
(setq OLDSNAP (getvar "OSMODE"))
(while
(setq IP (getpoint "\nInsertion Point: "))
(setvar "OSMODE" 0)
(setq P1 (polar IP 0 (/ T1 2))
P2 (polar P1 (DTR 90.0) (/ (- H (+ T2 T2 R1 R1)) 2))
P3 (polar P2 (DTR 90.0) R1)
P4 (polar P3 0 R1)
P5 (polar P4 0 (/ (- B (+ T1 R1 R1)) 2))
P6 (polar P5 (DTR 90.0) T2)
P7 (polar P6 (DTR 180.0) B)
P8 (polar P7 (DTR 270.0) T2)
P9 (polar P8 0 (/ (- B (+ T1 R1 R1)) 2))
P10 (polar P9 0 R1)
P11 (polar P10 (DTR 270.0) R1)
P12 (polar P11 (DTR 270.0) (- H (+ T2 T2 R1 R1)))
P13 (polar P12 (DTR 270.0) R1)
P14 (polar P13 (DTR 180.0) R1)
P15 (polar P14 (DTR 180.0) (/ (- B (+ T1 R1 R1)) 2))
P16 (polar P15 (DTR 270.0) T2)
P17 (polar P16 0 B)
P18 (polar P17 (DTR 90.0) T2)
P19 (polar P18 (DTR 180.0) (/ (- B (+ T1 R1 R1)) 2))
P20 (polar P19 (DTR 180.0) R1)
P21 (polar P20 (DTR 90.0) R1)
);setq
(command "PLINE" P1 "W" "0.0" "0.0" P2 "ARC"
P4 "LINE" P5 P6 P7 P8 P9 "ARC"
P11 "LINE" P12 "ARC" P14 "LINE" P15 P16
P17 P18 P19 "ARC" P21 "LINE" P1 ""
);command
(prompt "\nRotation Angle: ")
(command "ROTATE" "LAST" "" IP pause
);command
(setvar "OSMODE" OLDSNAP)
);while
);progn
);if userclick1
);progn
);if dialogshow
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "CMDECHO" OLDECHO)
(princ)
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (4 of 6) [23/03/2005 05:53:56 p.m.]
);defun BEAM
Phew, quite a mouthfull hey. Let's walk through it...
First, we define our degrees to radians function.
We then start defining our main function and declaring our variables.
(I have deliberatively left all variables global so that you can check their values once the programme has
run.)
After storing then resetting some of our system variables we create a list of names that will appear in our list
box.
Following this we load our dialogue box, setting up error checking to make sure that the dialogue file is
loaded before continuing.
If everything is OK we call start_list, add_list and end_list to create our list box. Here the MAPCAR
function is useful for turning a raw AutoLisp list into a listbox display :
(start_list "selections") - Specify name of the list box. (KEY)
(mapcar 'add_list NAMES) - Specify the list. (NAMES)
(end_list)
The value returned by a list box tile is the INDEX of the selected item.
(i.e. first item = 0 ; second item = 1 ; third item = 2 ; etc.)
The action_tile function is one of the most critical functions to employ when giving your dialogue box some
functionality.
On it's own a DCL definition does nothing more than define a lifeless dialogue box. Take a look at the
following code :
(action_tile
"cancel" ;if cancel selected
"(done_dialog) (setq userclick1 nil)" ;close dialog, set flag
);action tile
Did you notice all the quotes around the lisp code? When you write an action_tile
function for a DCL tile, your code is esentially telling the tile :
"Remember this string, then pass it back to me when the user activates you."
The string (i.e Anything within double-quotation marks) is dormant until the user picks the tile that is
remembering your string. At that time the tile passes the string back to AutoLisp. AutoLisp then converts
the string to functioning code and the code is executed.
Lets look at another code fragment.
The following is the action_tile expression assigned to the OK button :
(action_tile
"accept" ;if OK or double click
(strcat
"(progn (setq SIZA (atof (get_tile \"selections\")))" ;get size of beam
"(done_dialog) (setq userclick1 T))" ;close dialog and set flag
);strcat
);action tile
When the user selects the OK button, the lengthy string assigned to the button is passed-back and turned
into AutoLisp code that looks like this :
(progn
(setq SIZA (atof (get_tile "selections")))
(done_dialog)
(setq userclick1 T)
);
This code does several things :
It retrieves the value of the INDEX from the list box.
It terminates the dialog box.
It assigns a value of T to the variable userclick1.
Now that everything is set and ready to go, we invoke the dialogue box.
(start_dialog)
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (5 of 6) [23/03/2005 05:53:56 p.m.]
Once it is on the screen, it controls the programme flow, until the user hits OK, Cancel or double-clicks on
an item in the list box.
(unload_dialog dcl_id)
The user has made his selection so now we can unload the dialogue box.
For the rest of the program we are back to conventional AutoLisp code.
(This is basically self explanatory, especially if you have studied my earlier tutorials.)
The program retrieves the name of the item selected from the list box by utilising
the index (SIZA) of the selected item and the nth function.
(setq SIZA (nth SIZA NAMES)).
It then searches the data file for the corresponding name, retrieves the list of dimensions, formats the list
then stores the dimensions into individual variables.
(mapcar 'set '(H B T1 T2 R1) dlist)
The points required to draw the beam are then calculated using the POLAR function and the beam is
drawn and rotated if required.
Notice how this section of the coding is contained in a while loop to allow the user to draw more than one
beam if he wishes. This saves him from having to re-run the entire routine again and again if he wants to
draw multiple, identical beams.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Boxes Page
http://www.afralisp.com/lispa/lisp3.htm (6 of 6) [23/03/2005 05:53:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Nesting Dialogue Boxes.
This is another area that seems to cause a lot of confusion for some people.
Let's take a slow walk through the process of nesting and hiding dialogue boxes and see
if we can't explain it more clearly.
To nest dialogue boxes is pretty straightforward. You simply call the new, nested dialogue box from
within an action expression or callback function.
For example :
(action_tile "next" "(nextfunction)")
This simply says that when the tile with the key of 'next' is selected, then run the function
(nextfunction). (nextfunction), of course, would have it's own dialogue statements.
Just a couple of comments on nesting dialogue boxes.
Firstly, you cannot use the previous dialogue box whilst a nested dialogue is
active. You must close the nested dialogue first.
And secondly, AutoCAD states that there is a limit of no more than eight nested
dialogue boxes allowed, but recommends a maximum of four.
(Try it, I haven't!!!)
Thirdly, try and keep each nested dialogue smaller than the preceding dialogue.
Here's an example of a function with a main dialogue box and two nested
dialogue boxes.
First the DCL Coding:
main : dialog {
label = "Main Dialogue";
: column {
: text {
key = "txt1";
value = "This is the main dialogue box.";
}
: text {
key = "txt2";
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (1 of 7) [23/03/2005 05:53:58 p.m.]
value = "To display the next, nested dialogue,";
}
: text {
key = "txt3";
value = "Press Next....";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Next";
key = "next";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
nest1 : dialog {
label = "1st Nested Dialogue";
: column {
: text {
key = "txt1";
value = "This is the first nested dialogue box.";
}
: text {
key = "txt2";
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (2 of 7) [23/03/2005 05:53:58 p.m.]
value = "To display the next, nested dialogue, press Next";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Next";
key = "next";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
nest2 : dialog {
label = "2nd Nested Dialogue";
: column {
: text {
key = "txt1";
value = "This is the last nested dialogue box.";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (3 of 7) [23/03/2005 05:53:58 p.m.]
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
And now the Autolisp Coding:
(defun c:nest ()
;define the function
(setq dcl_id (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "main" dcl_id))
;load the dialogue box
(exit)
;if not loaded exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
;do this if Cancel button selected
(action_tile
"accept"
"(done_dialog)
(setq result T)"
)
;do this if OK button selected
(action_tile
"next"
"(nest1)"
)
;if Next button is selected, call
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (4 of 7) [23/03/2005 05:53:58 p.m.]
;the nested dialogue function
(start_dialog)
;start the dialogue
(unload_dialog dcl_id)
;unload the dialogue
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nest1 ()
;define the function
(setq dcl_id1 (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "nest1" dcl_id1))
;load the nested dialogue box
(exit)
;if not loaded exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result1 nil)"
)
;if cancel selected do this
(action_tile
"accept"
"(done_dialog)
(setq result1 T)"
)
;if OK selected do this
(action_tile
"next"
"(nest2)"
)
;if Next selected call the
;second nested dialogue function
(start_dialog)
;start the nested dialogue box
(unload_dialog dcl_id1)
;unload the nested dialogue box
(princ)
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (5 of 7) [23/03/2005 05:53:58 p.m.]
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nest2 ()
;define the function
(setq dcl_id2 (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "nest2" dcl_id2))
;load the second nested dialogue box
(exit)
;if not found exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result2 nil)"
)
;do this if Cancel selected
(action_tile
"accept"
"(done_dialog)
(setq result2 T)"
)
;do this if OK selected
(start_dialog)
;start the second nested dialogue box
(unload_dialog dcl_id2)
;unload it
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
See, pretty simple, hey....
Now, what you have all been waiting for....Hiding Dialogue Boxes!!!
(Sorry, but you will have to go to the next page.)
Hurry up, I'm waiting.....

Home. Page II.

Nesting and Hiding Dialog Boxes


http://www.afralisp.com/lispa/lisp43a.htm (6 of 7) [23/03/2005 05:53:58 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43a.htm (7 of 7) [23/03/2005 05:53:58 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Hiding Dialogue Boxes.
Often you need to make a selection on the screen whilst a dialogue box is active. But, to
do this, you need to be able to hide the dialogue box to allow the user to make a
selection from the screen. You must then restore the dialogue box, along with the values
that the user has selected.
When you end a dialogue box you use the (done_dialog) function. But did you know that
when you call the (done_dialog) function a status argument is returned?
Well it's true!!! Now think about this. When (done_dialog) is called from a tile who's key is
'cancel' (The Cancel button), it returns a status of 0. If a tile who's key is 'accept' is
choosen (The OK button), it returns a status of 1. So, if you use the (done_dialog)
function alongwith a status argument of say 4, you know that the dialogue box has been
hidden and not ended or cancelled.
But how do I retrieve that status argument?
Easy, when you call (start_dialog), it returns the (done_dialog) status value. eg. (setq flag
(start_dialogue).
By testing this value in a loop we can determine whether the dialogue was simply hidden
or ended or cancelled. Below is a sample routine that should, hopefully, I hope and pray,
explain it to you a lot better.
This routine simply displays a dialogue box that asks the user for a point.
If the user choosers the pick point button the dialogue is hidden to allow the user to pick a point on
the screen. The dialogue is then re-displayed and the x, y and z edit boxes are updated to the new
point value. It also allows the user to
enter the point values directly into the edit boxes if he so wishes.
First the DCL Coding:
hidebox : dialog {
label = "Hide Dialogue";
: boxed_column {
label = "Sample Point";
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43b.htm (1 of 5) [23/03/2005 05:54:00 p.m.]
: button {
label = "Pick Point <";
key = "hide";
width = 12;
fixed_width = true;
mnemonic = "P";
}
: edit_box {
key = "eb1";
label = "&X:";
width = 8;
fixed_width = true;
}
: edit_box {
key = "eb2";
label = "&Y:";
width = 8;
fixed_width = true;
}
: edit_box {
key = "eb3";
label = "&Z:";
width = 8;
fixed_width = true;
}
}
ok_cancel;
}
And now the AutoCAD Coding:
(defun c:hidebox ()
;define the function
(setq ptx "1.000"
pty "0.000"
ptz "0.000"
flag 4
);setq
;set default x,y, and z values
;and set flag to 4
(setq dcl_id (load_dialog "hidebox.dcl"))
;load the DCL file
(while (> flag 2)
;check the flag status and carry on looping
;if it is greater than 2
(if (not (new_dialog "hidebox" dcl_id))
;load the dialogue box
(exit)
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43b.htm (2 of 5) [23/03/2005 05:54:00 p.m.]
;if not loaded exit
)
(set_tile "eb1" ptx)
;display x value
(set_tile "eb2" pty)
;display y value
(set_tile "eb3" ptz)
;display z value
(mode_tile "eb1" 2)
;set focus to x edit box
(mode_tile "eb1" 3)
;select contents
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
;if Cancel button selected, close
;the dialogue. This action sets the
;flag to 0.
(action_tile
"accept"
"(setq ptx (get_tile \"eb1\"))
(setq pty (get_tile \"eb2\"))
(setq ptz (get_tile \"eb3\"))
(done_dialog)
(setq result T)"
)
;if OK button was selected, get the edit box
;point values, close the dialogue. This action
;sets the flag to 1.
(action_tile
"hide"
"(done_dialog 4)"
)
;if pick button selected, hide the dialogue
;and set the flag to 4
(setq flag (start_dialog))
;start the dialogue and set flag
;to value of start dialogue

(if (= flag 4)
;if the pick button was selected
(progn
;do the following

(setq selpoint (getpoint "\nInsertion Point: "))
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43b.htm (3 of 5) [23/03/2005 05:54:00 p.m.]
;get the insertion point
(setq ptx (rtos (car selpoint) 2 4))
;get the x value
(setq pty (rtos (cadr selpoint) 2 4))
;get the y value
(setq ptz (rtos (caddr selpoint) 2 4))
;get the z value

);progn
);if
);while
(unload_dialog dcl_id)
;unload the dialogue
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean

To hide AND nest dialogue boxes is just a case of combining the two.
(I'll leave that up to you to figure out....)
Would you like the coding for these routines? Then put one leg in the air,
close your left eye, scream as loud as you can and click here. Enjoy.......
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43b.htm (4 of 5) [23/03/2005 05:54:00 p.m.]
Search
Powered by CORBIMITE.com
Nesting and Hiding Dialog Boxes
http://www.afralisp.com/lispa/lisp43b.htm (5 of 5) [23/03/2005 05:54:00 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp Message Box.
This library of AutoLisp Functions closely emulates the Visual Basic Message Box Function. It will
display 5 different types of message boxes and allows you to enter 3 text message lines and
customise the Message Box title.
The message boxes available are :
Ok Only G
Ok Cancel G
Rentry Cancel G
Yes No G
Yes No Cancel G
The syntax for usage is as follows:
(function name "message1" "message2" "message3" "title")
For example:
(lspokcancel "This is the first line" "This is the second line"
"This is the third line" "This is the title")
Here is a detailed explanation of each message box:
Ok Only.
Syntax : (lspOkOnly "message1" "message2" "message3" "title")
This message box returns nothing as it is used to convey a message only
Ok Cancel.
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (1 of 10) [23/03/2005 05:54:02 p.m.]
Syntax : (lspOkCancel "message1" "message2" "message3" "title")
This message box returns True if OK selected and nil if Cancel selected
Rentry Cancel.
Syntax : (lspRentryCancel "message1" "message2" "message3" "title")
This message box returns True if Rentry selected and nil if Cancel selected
Yes No.
Syntax : (lspYesNo "message1" "message2" "message3" "title")
This message box returns True if Yes selected and "F" if No selected
Yes No Cancel.
Syntax : (lspYesNoCancel "message1" "message2" "message3" "title")
This message box returns True if Yes selected, "F" if No selected
and nil if Cancel selected.
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (2 of 10) [23/03/2005 05:54:02 p.m.]
Source Coding.
Here is the DCL Source Coding:
lspOkCancel : dialog {
key = "main";
: column {
: text {
key = "message1";
}
: text {
key = "message2";
}
: text {
key = "message3";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
lspYesNo : dialog {
key = "main";
: column {
: text {
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (3 of 10) [23/03/2005 05:54:02 p.m.]
key = "message1";
}
: text {
key = "message2";
}
: text {
key = "message3";
}
}
: row {
: spacer { width = 1; }
: button {
label = "Yes";
key = "yes";
width = 12;
fixed_width = true;
mnemonic = "Y";
is_default = true;
}
: button {
label = "No";
key = "no";
width = 12;
fixed_width = true;
mnemonic = "N";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////
lspOkOnly : dialog {
key = "main";
: column {
: text {
key = "message1";
}
: text {
key = "message2";
}
: text {
key = "message3";
}
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (4 of 10) [23/03/2005 05:54:02 p.m.]
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
alignment = centered;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
lspYesNoCancel : dialog {
key = "main";
: column {
: text {
key = "message1";
}
: text {
key = "message2";
}
: text {
key = "message3";
}
}
: row {
: spacer { width = 1; }
: button {
label = "Yes";
key = "yes";
width = 12;
fixed_width = true;
mnemonic = "Y";
is_default = true;
}
: button {
label = "No";
key = "no";
width = 12;
fixed_width = true;
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (5 of 10) [23/03/2005 05:54:02 p.m.]
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////
lspRentryCancel : dialog {
key = "main";
: column {
: text {
key = "message1";
}
: text {
key = "message2";
}
: text {
key = "message3";
}
}
: row {
: spacer { width = 1; }
: button {
label = "Rentry";
key = "rentry";
width = 12;
fixed_width = true;
mnemonic = "R";
is_default = true;
}
: button {
label = "Cancel";
key = "Cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (6 of 10) [23/03/2005 05:54:02 p.m.]
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////
And the Autolisp Code:
(defun lspOkCancel (message1 message2 message3 main)
(setq dcl_id (load_dialog "msgbox.dcl"))
(if (not (new_dialog "lspOkCancel" dcl_id))
(exit)
)
(set_tile "message1" message1)
(set_tile "message2" message2)
(set_tile "message3" message3)
(set_tile "main" main)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
(action_tile
"accept"
"(done_dialog)
(setq result T)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun lspYesNo (message1 message2 message3 main)
(setq dcl_id (load_dialog "msgbox.dcl"))
(if (not (new_dialog "lspYesNo" dcl_id))
(exit)
)
(set_tile "message1" message1)
(set_tile "message2" message2)
(set_tile "message3" message3)
(set_tile "main" main)
(action_tile
"no"
"(done_dialog)
(setq result \"F\")"
)
(action_tile
"yes"
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (7 of 10) [23/03/2005 05:54:02 p.m.]
"(done_dialog)
(setq result T)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun lspOkOnly (message1 message2 message3 main)
(setq dcl_id (load_dialog "msgbox.dcl"))
(if (not (new_dialog "lspOkOnly" dcl_id))
(exit)
)
(set_tile "message1" message1)
(set_tile "message2" message2)
(set_tile "message3" message3)
(set_tile "main" main)

(action_tile
"yes"
"(done_dialog)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun lspYesNoCancel (message1 message2 message3 main)
(setq dcl_id (load_dialog "msgbox.dcl"))
(if (not (new_dialog "lspYesNoCancel" dcl_id))
(exit)
)
(set_tile "message1" message1)
(set_tile "message2" message2)
(set_tile "message3" message3)
(set_tile "main" main)
(action_tile
"no"
"(done_dialog)
(setq result \"F\")"
)
(action_tile
"yes"
"(done_dialog)
(setq result T)"
)
(action_tile
"cancel"
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (8 of 10) [23/03/2005 05:54:02 p.m.]
"(done_dialog)
(setq result nil)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun lspRentryCancel (message1 message2 message3 main)
(setq dcl_id (load_dialog "msgbox.dcl"))
(if (not (new_dialog "lspRentryCancel" dcl_id))
(exit)
)
(set_tile "message1" message1)
(set_tile "message2" message2)
(set_tile "message3" message3)
(set_tile "main" main)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
(action_tile
"rentry"
"(done_dialog)
(setq result T)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)
If you would like the source coding for the the Message Box routine, just
place your mouse here, and click....Enjoy.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (9 of 10) [23/03/2005 05:54:02 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp Message Box
http://www.afralisp.com/lispa/lisp41a.htm (10 of 10) [23/03/2005 05:54:02 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLisp Input Box.
This routine is very similar to the Visual Basic Input Box Function.
To use this routine you feed the function 3 arguments, the Input Box Prompt, the Title of the Input
Box, and the Default Value of the Edit Box.
The syntax is straightforward:
(inputbox "prompt" "title" "default")
For example, the Input Box above was called by using the following command:
(inputbox "Enter Number" "AfraLisp Inputbox" "342.34")
The Input Box returns a variable "inputvalue" containing the value of the
Edit Box.
Source Coding.
First the DCL Coding:
inputbox : dialog {
key = "title";
: text {
key = "prompt";
}
: edit_box {
key = "eb1";
}
ok_cancel;
}
And next the AutoLisp Coding:
(defun inputbox (prompt title default)
(setq dcl_id (load_dialog "inputbox.dcl"))
(if (not (new_dialog "inputbox" dcl_id))
(exit)
)
(set_tile "prompt" prompt)
AutoLisp Input Box
http://www.afralisp.com/lispa/lisp42a.htm (1 of 2) [23/03/2005 05:54:04 p.m.]
(set_tile "title" title)
(set_tile "eb1" default)
(mode_tile "eb1" 2)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
(action_tile
"accept"
"(setq inputvalue (get_tile \"eb1\"))
(done_dialog)
(setq result T)"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)
If you would like the source coding for the the Input Box routine, just
place your mouse here, and click....Enjoy.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLisp Input Box
http://www.afralisp.com/lispa/lisp42a.htm (2 of 2) [23/03/2005 05:54:04 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Referencing DCL Files.
If you look in your AutoCAD Support directory, you will find a file entitled Base.Dcl. This
file contains the DCL definitions for the basic, predefined tiles and tile types. It also
contains definitions for commonly used prototypes.
You will also find Acad.Dcl in this directory. This file contains the standard definitions of
all dialogue boxes used by AutoCAD.
But, did you know that a DCL file can also use tiles defined in another DCL file by naming
the other file in what is called an include directory.
Let me try and show you how this works.
First create a new DCL file called Include1.Dcl:
include1 : dialog {
label = "Choose a Point:";
ok_cancel;
}

Now, create a new AutoLisp file entitled Include1.Lsp with the following coding:
(defun c:include1 ()
;define the function
(setq dcl_id (load_dialog "include1.dcl"))
;load the DCL file
(if (not (new_dialog "include1" dcl_id))
;load the dialogue box
(exit)
;if not loaded exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
;if Cancel button selected, close
;the dialogue.
(action_tile
"accept"
"(done_dialog)
(setq result T)"
)
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (1 of 7) [23/03/2005 05:54:06 p.m.]
;if OK button was selected
(start_dialog)
;start the dialogue
(unload_dialog dcl_id)
;unload the dialogue
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
Open AutoCAD and load and run the routine.
You should have a very simple dialogue box looking like this :
Now, let's say we had a company logo, or something like that, that we wanted
to display on all our custom dialogue boxes. We could put the DCL coding for the logo in all our
DCL files. But what happens, if say our telephone number changes. We would then have to edit all
of our dialogue boxes containing the DCL coding for our logo. Here's a better way. We will create
another DCL file containing the DCL coding for our logo, and include this file in our original DCL
file. By doing it this way, we only have to change the master DCL file if we want to make revisions
to our logo.
Let's create our logo DCL file first.
Create a new DCL file entitled Atitle.Dcl:
atitle : boxed_column {
: paragraph {

: text_part {
label = "Brought To";
}

: text_part {
label = " You By";
}

: text_part {
label = "AfraLisp";
}
: text_part {
label = "063-235837";
}
}

Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (2 of 7) [23/03/2005 05:54:06 p.m.]
}
Now revise the coding of our original include1.dcl to look like this:
@include "atitle.dcl"
include1 : dialog {
label = "Choose a Point:";
ok_cancel;
atitle;
}
Re-Load and run Include1.Lsp. It should look like this:
O.K I agree, it's not the best looking logo I've ever seen, but I'm sure you get the idea.
You can even include two or more references to DCL Files if you wish.
Let's have a look at another example. First create a new DCL file called gpoint.dcl. Add this coding
to it:
gpoint : boxed_column {
label = "Sample Point";
: button {
label = "Pick Point <";
key = "hide";
width = 12;
fixed_width = true;
mnemonic = "P";
}
: edit_box {
key = "eb1";
label = "&X:";
width = 8;
fixed_width = true;
}
: edit_box {
key = "eb2";
label = "&Y:";
width = 8;
fixed_width = true;
}
: edit_box {
key = "eb3";
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (3 of 7) [23/03/2005 05:54:06 p.m.]
label = "&Z:";
width = 8;
fixed_width = true;
}
}
Now create a new DCL file entitle Include.Dcl and add this coding:
@include "gpoint.dcl"
@include "atitle.dcl"
include : dialog {
label = "Choose a Point:";
gpoint;
ok_cancel;
atitle;
}
The coding for your lisp file, called Include.Lsp will look like this:
(defun c:include ()
;define the function
(setq ptx "1.000"
pty "0.000"
ptz "0.000"
flag 4
);setq
;set default x,y, and z values
;and set flag to 4
(setq dcl_id (load_dialog "include.dcl"))
;load the DCL file
(while (> flag 2)
;check the flag status and carry on looping
;if it is greater than 2
(if (not (new_dialog "include" dcl_id))
;load the dialogue box
(exit)
;if not loaded exit
)
(set_tile "eb1" ptx)
;display x value
(set_tile "eb2" pty)
;display y value
(set_tile "eb3" ptz)
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (4 of 7) [23/03/2005 05:54:06 p.m.]
;display z value
(mode_tile "eb1" 2)
;set focus to x edit box
(mode_tile "eb1" 3)
;select contents
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
;if Cancel button selected, close
;the dialogue. This action sets the
;flag to 0.
(action_tile
"accept"
"(setq ptx (get_tile \"eb1\"))
(setq pty (get_tile \"eb2\"))
(setq ptz (get_tile \"eb3\"))
(done_dialog)
(setq result T)"
)
;if OK button was selected, get the edit box
;point values, close the dialogue. This action
;sets the flag to 1.
(action_tile
"hide"
"(done_dialog 4)"
)
;if pick button selected, hide the dialogue
;and set the flag to 4
(setq flag (start_dialog))
;start the dialogue and set flag
;to value of start dialogue

(if (= flag 4)
;if the pick button was selected
(progn
;do the following

(setq selpoint (getpoint "\nInsertion Point: "))
;get the insertion point
(setq ptx (rtos (car selpoint) 2 4))
;get the x value
(setq pty (rtos (cadr selpoint) 2 4))
;get the y value
(setq ptz (rtos (caddr selpoint) 2 4))
;get the z value
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (5 of 7) [23/03/2005 05:54:06 p.m.]

);progn
);if
);while
(unload_dialog dcl_id)
;unload the dialogue
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
Your dialogue box should look like this:
If you wanted, you could create a whole library of DCL files containing customised dialogue
definitions which you could include/reference in all of your DCL files.
To download source coding for this Tutorial (27Kb) Click Here.
Sorry, not there, I mean here.

You are visitor number



Web afralisp.com
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (6 of 7) [23/03/2005 05:54:06 p.m.]
Search
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Referencing DCL Files.
http://www.afralisp.com/lispa/lisp47.htm (7 of 7) [23/03/2005 05:54:06 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoLISP Functions for Dialog Control Language (DCL)

(action_tile key action-expression) Assigns an action to evaluate the user selected specif tile in a dialog box
(add_list string) Adds or modifies a string in the currently active dialog box list
(client_data_tile key clientdata) Associates application-managed data with a dialog box tile
(dimx_tile key) and ( dimy_tile key) Retrieves the dimensions of a tile in dialog box units
(done_dialog [status]) Terminates a dialog box. If you specify the optional status argument, it must be
a positive integer, which start_dialog will return instead of returning 1 for OK
or 0 for Cancel. The meaning of any status value greater than 1 depends on
your application.
(end_image) Ends creation of the currently active dialog box image This function is the
complement of (start_image)
(end_list) Ends processing of the currently active dialog box list This function is the
complement of start_list.
(fill_image x1 y1 wid hgt color) Draws a filled rectangle in the currently active dialog box image tile
The fill_image function must be used between start_image and end_image
calls. The color parameter is an AutoCAD color number or one of the logical
color numbers shown in the following table.
Symbolic names for the color attribute
Color number ADI mnemonic Description
-2 BGLCOLOR Current background of the AutoCAD graphics screen
-15 DBGLCOLOR Current dialog box background color
-16 DFGLCOLOR Current dialog box foreground color (text)
-18 LINELCOLOR Current dialog box line color
The first (upper-left) corner of the rectangle is located at (x1,y1) and the second
(lower-right) corner is located the relative distance (wid,hgt) from the first
corner (wid and hgt must be positive values). The origin (0,0) is the upper-left
corner of the image. You can obtain the coordinates of the lower-right corner
by calling the dimension functions dimx_tile and dimy_tile.
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (1 of 6) [23/03/2005 05:54:08 p.m.]
(get_attr key attribute) Retrieves the DCL value of a dialog box attribute
The key argument is a string that specifies the tile and is case sensitive. The
attribute argument specifies the name of the attribute as it appears in the tile's
DCL description. Both the key and attribute arguments are strings. The value
returned is the attribute's initial value as specified in its DCL description; it
does not reflect changes to the state of the tile that come about with user input
or set_tile calls. Returns the attribute value as a string.
(get_tile key) Retrieves the current run-time value of a dialog box tile
The key argument is a string that specifies the tile and is case sensitive. It
returns the tile's value as a string.
(load_dialog dclfile) Loads a DCL file
The dclfile argument is a string that specifies the DCL file to load. If the dclfile
argument does not specify a file extension, .dcl is assumed. Returns a positive
integer value (dcl_id) if successful, and returns a negative integer if it can't
open the file. The dcl_id is used as a handle in subsequent new_dialog and
unload_dialog calls.
The load_dialog function searches for files according to the AutoCAD library
search path.
This function is the complement of unload_dialog. An application can load
multiple DCL files with multiple load_dialog calls.
(mode_tile key mode) Sets the mode of a dialog box tile
The key argument is a string that specifies the tile and is case sensitive. The
mode argument is an integer value. The mode argument values are described
in the following table.
Mode argument values
Value Description
0 Enable tile
1 Disable tile
2 Set focus to tile
3 Select edit box contents
4 Flip image highlighting on or off
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (2 of 6) [23/03/2005 05:54:08 p.m.]
(new_dialog dlgname dcl_id [action
[screen-pt]])
Begins a new dialog box and displays it, and can also specify a default action
The dlgname argument is a string that specifies the dialog box, and dcl_id
identifies the DCL file (you must have obtained its value from the load_dialog
call).
The action argument, which must be specified if you specify screen-pt, is a
string that contains an AutoLISP expression to use as the default action. If you
don't want to define a default action, pass action as the empty string (""). The
screen-pt argument is a 2D point list that specifies the X,Y location of the
dialog box on the screen. The point usually specifies the upper-left corner of
the dialog box, but this is platform dependent, as is the system of units in
which the location is specified. If you pass the point as'(-1 -1), the dialog box is
opened in the default position (the center of the AutoCAD graphics screen).
If new_dialog succeeds, it returns T; otherwise it returns nil.
Your application must call new_dialog before it calls start_dialog. All dialog
box initialization--such as setting tile values, creating images or lists for list
boxes, and associating actions with specific tiles (with the use of
action_tile)--must take place after the new_dialog call and before the
start_dialog call.
The default action is evaluated when the user picks an active tile that doesn't
have an action or callback explicitly assigned to it by action_tile or in DCL.
Note Always check the status new_dialog returns. Calling start_dialog when
the new_dialog call failed can have unpredictable results.
(set_tile key value) Sets the value of a dialog box tile
The key argument is a string that specifies the tile, and value is a string that
names the new value to assign (initially set by the value attribute).
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (3 of 6) [23/03/2005 05:54:08 p.m.]
sldname or libname(sldname) Displays an AutoCAD slide in the currently active dialog box image tile
(slide_image x1 y1 wid hgt sldname)
The slide can be a slide file (.sld) or a slide in a slide library file (.slb): the
sldname argument specifies it as you would specify it for the VSLIDE
command or for a menu file.
The first (upper-left) corner of the slide--its insertion point--is located at (x1,y1),
and the second (lower-right) corner is located at the relative distance (wid,hgt)
from the first (wid and hgt must be positive values). The origin (0,0) is the
upper-left corner of the image. You obtain the coordinates of the lower-right
corner by calling the dimension functions (dimx_tile and dimy_tile).
(start_dialog) Displays a dialog box and begins accepting user input
You must first initialize the dialog box by a previous new_dialog call. The
dialog box remains active until an action expression or callback function calls
done_dialog. Usually done_dialog is associated with the tile whose key is
"accept" (typically the OK button) and the tile whose key is "cancel" (typically
the Cancel button).
The start_dialog function has no arguments. It returns the optional status
passed to done_dialog. The default value is 1 if the user pressed OK, 0 if the
user pressed Cancel, or -1 if all dialog boxes were terminated with term_dialog.
But if done_dialog is passed an integer status greater than 1, start_dialog
returns this value, whose meaning depends on the application.
(start_image key) Starts the creation of an image in the dialog box tile
Subsequent calls to fill_image, slide_image, and vector_image affect this
image until the application calls end_image. The key argument is a string that
specifies the dialog box tile. The key argument is case sensitive.
Note Do not use the set_tile function between start_image and end_image
function calls.
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (4 of 6) [23/03/2005 05:54:08 p.m.]
(start_list key [operation [index]]) Starts the processing of a list in the list box or in the pop-up list dialog box tile
The key argument is a string that specifies the dialog box tile. The key
argument is case sensitive. The operation argument is an integer value whose
meaning is summarized in the following table.
List box codes for start_list
Value Description
1 Change selected list contents
2 Append new list entry
3 Delete old list and create new list (the default)
The index argument is ignored unless the start_list call begins a change
operation (1), in which case index indicates the list item to change by the
subsequent add_list call. The index is zero based. If you don't specify
operation, it defaults to 3 (create new list), and if you specify operation but not
index, the index defaults to 0.
Subsequent calls to add_list affect the list started by start_list until the
application calls end_list.
Note Do not use the set_tile function between start_list and end_list function
calls.
(term_dialog) Terminates all current dialog boxes as if the user had canceled each of them
If an application is terminated while any DCL files are open, AutoCAD
automatically calls term_dialog. This function is used mainly for aborting
nested dialog boxes. The term_dialog function always returns nil.
(unload_dialog dcl_id) Unloads a DCL file
Unloads the DCL file associated with dcl_id (which was obtained from a
previous new_dialog call).
Always returns nil.
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (5 of 6) [23/03/2005 05:54:08 p.m.]
(vector_image x1 y1 x2 y2 color) Draws a vector in the currently active dialog box image
This function draws a vector in the currently active dialog box image (opened
by start_image) from the point (x1,y1) to (x2,y2). The color parameter is an
AutoCAD color number or one of the logical color numbers shown in the
following table.
Symbolic names for the color attribute
Color
number ADI
mnemonic
Description
-2 BGLCOLOR Current background of the AutoCAD graphics screen
-15 DBGLCOLOR Current dialog box background color
-16 DFGLCOLOR Current dialog box foreground color (for text)
-18 LINELCOLOR Current dialog box line color
The origin (0,0) is the upper-left corner of the image. You can obtain the
coordinates of the lower-right corner by calling the dimension functions
(dimx_tile and dimy_tile).

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoLISP Functions for Dialog Control Language (DCL)
http://www.afralisp.com/lisp/dcl.htm (6 of 6) [23/03/2005 05:54:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Functional Synopsis of DCL Tiles.
Many people have requested a listing of all of the available DCL tiles along with a
working AutoLisp example of each tile.
In this tutorial we will have a look at each tile, the DCL coding for it, as well as the
AutoLisp coding required to make the dialogue box tile functional.
AutoCAD and DCL
The AutoCAD PDB facility has a large set of built-in, or predefined, tiles that can
be used by themselves or as the basis for more complex tiles.
These tiles can be sub-divided into 5 main catagories:
Exit Buttons and Error Tiles.
ok_only G
ok_cancel G
ok_cancel_help G
ok_cancel_help_errtile G
ok_cancel_help_info G
errtile G
Predefined Active Tiles.
button G
edit_box G
list_box G
popup_list G
radio_button G
toggle G
slider G
image_button G
Decorative and Informative Tiles.
image G
text G
spacer G
spacer_0 G
spacer_1 G
Text Clusters.
concatenation G
paragraph G
text_part G
Tile Clusters.
Functional Synopsis of DCL Tiles.
http://www.afralisp.com/lispa/lisp48.htm (1 of 2) [23/03/2005 05:54:09 p.m.]
boxed_column G
boxed_radio_column G
boxed_radio_row G
boxed_row G
column G
dialog G
radio_column G
radio_row G
row G
To download source coding for this Tutorial click here. (183 Kb)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles.
http://www.afralisp.com/lispa/lisp48.htm (2 of 2) [23/03/2005 05:54:09 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ok_only.
Syntax:
ok_only;
The ok_only tile is defined in the Base.Dcl file.
The key of the OK button is 'accept'.
DCL Coding:
lisp48a : dialog { //dialog name
label = "ok_only" ; //give it a label
ok_only ; //predefined OK button
} //end dialog
AutoLisp Coding:
(defun C:lisp48a ()
;define function
(setq dcl_id (load_dialog "lisp48a.dcl"))
;load dialog
(if (not (new_dialog "lisp48a" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(start_dialog)
;start dialog
Functional Synopsis of DCL Tiles-Ok_Only
http://www.afralisp.com/lispa/lisp48a.htm (1 of 2) [23/03/2005 05:54:10 p.m.]

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You Choose O.K.")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Ok_Only
http://www.afralisp.com/lispa/lisp48a.htm (2 of 2) [23/03/2005 05:54:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ok_cancel.
Syntax:
ok_cancel;
The ok_cancel tile is defined in the Base.Dcl file.
The key of the OK button is 'accept'.
The key of the Cancel button is 'cancel'.
DCL Coding:
lisp48b : dialog { //dialog name
label = "ok_cancel" ; //give it a label
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48b ()
;define function
(setq dcl_id (load_dialog "lisp48b.dcl"))
;load dialog
(if (not (new_dialog "lisp48b" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
Functional Synopsis of DCL Tiles-OK_Cancel.
http://www.afralisp.com/lispa/lisp48b.htm (1 of 2) [23/03/2005 05:54:11 p.m.]
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-OK_Cancel.
http://www.afralisp.com/lispa/lisp48b.htm (2 of 2) [23/03/2005 05:54:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ok_cancel_help.
Syntax:
ok_cancel_help;
The ok_cancel_help tile is defined in the Base.Dcl file.
The key of the OK button is 'accept'.
The key of the Cancel button is 'cancel'.
The key of the Help button is 'help'.
DCL Coding:
lisp48c : dialog { //dialog name
label = "ok_cancel_help" ; //give it a label
ok_cancel_help; //predefined OK/Cancel/Help
//button
} //end dialog
gotohelp : dialog { //dialog name
label = "Help Box" ; //give it a label
: text { //define text
label = "This is the Help Box" ; //give it a label
} //end text
ok_only ; //predefined OK Button
} //end dialog
AutoLisp Coding:
(defun C:lisp48c ()
;define function
(setq dcl_id (load_dialog "lisp48c.dcl"))
;load dialog
(if (not (new_dialog "lisp48c" dcl_id)
;test for dialog
);not
(exit)
Functional Synopsis of DCL Tiles-OK_Cancel_Help.
http://www.afralisp.com/lispa/lisp48c.htm (1 of 3) [23/03/2005 05:54:12 p.m.]
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(action_tile
"help"
;if help button pressed
"(gotohelp)"
;call help function
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(defun gotohelp ()
;define function
(setq dcl_id (load_dialog "lisp48c.dcl"))
;load dialog
(if (not (new_dialog "gotohelp" dcl_id)
Functional Synopsis of DCL Tiles-OK_Cancel_Help.
http://www.afralisp.com/lispa/lisp48c.htm (2 of 3) [23/03/2005 05:54:12 p.m.]
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog)"
;close dialog

);action tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-OK_Cancel_Help.
http://www.afralisp.com/lispa/lisp48c.htm (3 of 3) [23/03/2005 05:54:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ok_cancel_help_errtile.
Syntax:
ok_cancel_help_errtile;
The ok_cancel_help_errtile tile is defined in the Base.Dcl file.
The key of the OK button is 'accept'.
The key of the Cancel button is 'cancel'.
The key of the Help button is 'help'.
The key of the Error tile is 'error'.
DCL Coding:
lisp48d : dialog { //dialog name
label = "ok_cancel_help_errtile" ; //give it a label
ok_cancel_help_errtile; //predefined OK/Cancel/Help/
//errtile button
} //end dialog
gotohelp : dialog { //dialog name
label = "Help Box" ; //give it a label
: text { //defin text
label = "This is the Help Box" ; //give it a label
} //end text
ok_only ; //predefined OK Button
} //end dialog
AutoLisp Coding:
(defun C:lisp48d ()
;define function
(setq dcl_id (load_dialog "lisp48d.dcl"))
;load dialog
(if (not (new_dialog "lisp48d" dcl_id)
;test for dialog
);not
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Errtile.
http://www.afralisp.com/lispa/lisp48d.htm (1 of 3) [23/03/2005 05:54:13 p.m.]
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(action_tile
"help"
;if help button pressed
"(gotohelp)"
;call help function
);action_tile
(set_tile
"error"
;if there is an error
"There has been an *Error*"
;display this message
);set_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Errtile.
http://www.afralisp.com/lispa/lisp48d.htm (2 of 3) [23/03/2005 05:54:13 p.m.]
(defun gotohelp ()
;define function
(setq dcl_id (load_dialog "lisp48d.dcl"))
;load dialog
(if (not (new_dialog "gotohelp" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog)"
;close dialog

);action tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Errtile.
http://www.afralisp.com/lispa/lisp48d.htm (3 of 3) [23/03/2005 05:54:13 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
ok_cancel_help_info.
Syntax:
ok_cancel_help_info;
The ok_cancel_help_info tile is defined in the Base.Dcl file.
The key of the OK button is 'accept'.
The key of the Cancel button is 'cancel'.
The key of the Help button is 'help'.
The key of the Info button is 'info'.
DCL Coding:
lisp48e : dialog { //dialog name
label = "ok_cancel_help_info" ; //give it a label
ok_cancel_help_info; //predefined OK/Cancel/Help/
//Info button
} //end dialog
gotohelp : dialog { //dialog name
label = "Help Box" ; //give it a label
: text { //defin text
label = "This is the Help Box" ; //give it a label
} //end text
ok_only ; //predefined OK Button
} //end dialog
gotoinfo : dialog { //dialog name
label = "Info Box" ; //give it a label
: text { //define text
label = "This is the Info Box" ; //give it a label
} //end text
ok_only ; //predefined OK Button
} //end dialog
AutoLisp Coding:
(defun C:lisp48e ()
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Info.
http://www.afralisp.com/lispa/lisp48e.htm (1 of 4) [23/03/2005 05:54:15 p.m.]
;define function
(setq dcl_id (load_dialog "lisp48e.dcl"))
;load dialog
(if (not (new_dialog "lisp48e" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(action_tile
"help"
;if help button pressed
"(gotohelp)"
;call help function
);action_tile
(action_tile
"info"
;if Info button pressed
"(gotoinfo)"
;call info function
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Info.
http://www.afralisp.com/lispa/lisp48e.htm (2 of 4) [23/03/2005 05:54:15 p.m.]
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(defun gotohelp ()
;define function
(setq dcl_id (load_dialog "lisp48e.dcl"))
;load dialog
(if (not (new_dialog "gotohelp" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog)"
;close dialog

);action tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(princ)
);defun
(defun gotoinfo ()
;define function
(setq dcl_id (load_dialog "lisp48e.dcl"))
;load dialog
(if (not (new_dialog "gotoinfo" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Info.
http://www.afralisp.com/lispa/lisp48e.htm (3 of 4) [23/03/2005 05:54:15 p.m.]
(action_tile
"accept"
;if O.K. pressed

"(done_dialog)"
;close dialog

);action tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-OK_Cancel_Help_Info.
http://www.afralisp.com/lispa/lisp48e.htm (4 of 4) [23/03/2005 05:54:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
errtile.
Syntax:
errtile;
The errtile tile is defined in the Base.Dcl file.
The key of the errtile is 'error'.
DCL Coding:
lisp48f : dialog { //dialog name
label = "errtile" ; //give it a label
ok_cancel ; //predefined OK/Cancel button
errtile; //predefined Error tile
} //end dialog
AutoLisp Coding:
(defun C:lisp48f ()
;define function
(setq dcl_id (load_dialog "lisp48f.dcl"))
;load dialog
(if (not (new_dialog "lisp48f" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
Functional Synopsis of DCL Tiles-Errtile.
http://www.afralisp.com/lispa/lisp48f.htm (1 of 2) [23/03/2005 05:54:16 p.m.]
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;the following would be called
;from your error handler
(set_tile
"error"
;if there is an error
"There has been an *Error*"
;display this message
);set_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Errtile.
http://www.afralisp.com/lispa/lisp48f.htm (2 of 2) [23/03/2005 05:54:16 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
button.
Syntax:
: button {
action alignment fixed_height fixed_width
height is_cancel is_default is_enabled
is_tab_stop key label mnemonic width
}
DCL Coding:
lisp48g : dialog { //dialog name
label = "button" ; //give it a label
: button { //add a button
label = "Message"; //give it a label
key = "btn1"; //give it a name
mnemonic = "M"; //give it a mnemonic
fixed_width = true; //fix the width
alignment = centered; //center the button
} //end button
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48g ()
;define function
(setq dcl_id (load_dialog "lisp48g.dcl"))
;load dialog
(if (not (new_dialog "lisp48g" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"btn1"
;if the message button is pressed
"(setq col (acad_colordlg 2))"
Functional Synopsis of DCL Tiles-Button.
http://www.afralisp.com/lispa/lisp48g.htm (1 of 3) [23/03/2005 05:54:17 p.m.]
;display the AutoCAD colour dialogue
);action_tile
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected

(progn
;do the following
(setq col (itoa col))
;convert to string
(alert (strcat "You selected Colour No: " col))
;inform the user
);progn
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Button.


http://www.afralisp.com/lispa/lisp48g.htm (2 of 3) [23/03/2005 05:54:17 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Button.
http://www.afralisp.com/lispa/lisp48g.htm (3 of 3) [23/03/2005 05:54:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
edit_box.
Syntax:
: edit_box {
action alignment allow_accept edit_limit
edit_width fixed_height fixed_width
height is_enabled is_tab_stop key label mnemonic
value width password_char
}
DCL Coding:
lisp48h : dialog { //dialog name
label = "edit_box" ; //give it a label
: edit_box { //define edit box
key = "eb1"; //give it a name
edit_limit = 8; //restrict to 8 letters
label = "Enter Password"; //give it a label
mnemonic = "P"; //define mnemonic
password_char = "*"; //define password character
} //end edit box
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48h ()
;define function
(setq dcl_id (load_dialog "lisp48h.dcl"))
;load dialog
(if (not (new_dialog "lisp48h" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"eb1"
;if a password is entered
Functional Synopsis of DCL Tiles-Edit Box.
http://www.afralisp.com/lispa/lisp48h.htm (1 of 2) [23/03/2005 05:54:18 p.m.]
"(setq pass $value)"
;store the password in the variable 'pass'
);action_tile
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert (strcat "Password is: " pass))
;display the password
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Edit Box.
http://www.afralisp.com/lispa/lisp48h.htm (2 of 2) [23/03/2005 05:54:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
list_box.
Syntax:
: list_box {
action alignment allow_accept fixed_height
fixed_width height is_enabled is_tab_stop
key label list mnemonic multiple_select
tabs value width
}
DCL Coding:
lisp48i : dialog { //dialog name
label = "list_box" ; //give it a label
: list_box { //define list box
key = "selections"; //give it a name
} //end list
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48i ()
;define function
(setq NAMES '("Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday")
);setq
;define list
(setq dcl_id (load_dialog "lisp48i.dcl"))
;load dialog
(if (not (new_dialog "lisp48i" dcl_id)
;test for dialog
);not
Functional Synopsis of DCL Tiles-List_Box.
http://www.afralisp.com/lispa/lisp48i.htm (1 of 3) [23/03/2005 05:54:19 p.m.]
(exit)
;exit if no dialog
);if
(start_list "selections")
;start the list box
(mapcar 'add_list NAMES)
;fill the list box
(end_list)
;end list
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))"
;get list selection
"(done_dialog) (setq userclick T))"
;close dialog
);strcat
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(progn
;if it was do the following
(setq SIZ (fix SIZ))
;convert to integer
(setq SIZ (nth SIZ NAMES))
;get the Day
(alert (strcat "You Selected: " SIZ))
;display the Day
Functional Synopsis of DCL Tiles-List_Box.
http://www.afralisp.com/lispa/lisp48i.htm (2 of 3) [23/03/2005 05:54:19 p.m.]
);progn
);if userclick
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-List_Box.
http://www.afralisp.com/lispa/lisp48i.htm (3 of 3) [23/03/2005 05:54:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
popup_list.
Syntax:
: popup_list {
action alignment edit_width fixed_height
fixed_width height is_enabled is_tab_stop
key label list mnemonic tabs value width
}
DCL Coding:
lisp48j : dialog { //dialog name
label = "popup_list" ; //give it a label
: popup_list { //define popup list
label = "Choose Name:"; //give it a label
key = "selections"; //give it a name
value = "5" ; //initial value
edit_width = 12; //fix the width
} //end list
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48j ()
;define function
(setq NAMES '("Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday")
);setq
;define list
(setq dcl_id (load_dialog "lisp48j.dcl"))
;load dialog
(if (not (new_dialog "lisp48j" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
Functional Synopsis of DCL Tiles-Popup_List.
http://www.afralisp.com/lispa/lisp48j.htm (1 of 3) [23/03/2005 05:54:20 p.m.]
);if
(start_list "selections")
;start the list box
(mapcar 'add_list NAMES)
;fill the list box
(end_list)
;end list
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn
(setq SIZ (atof (get_tile \"selections\")))"
;get list selection
"(done_dialog) (setq userclick T))"
;close dialog
);strcat
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(progn
;if it was do the following
(setq SIZ (fix SIZ))
;convert to integer
(setq SIZ (nth SIZ NAMES))
;get the Day
(alert (strcat "You Selected: " SIZ))
;display the Day
);progn
Functional Synopsis of DCL Tiles-Popup_List.
http://www.afralisp.com/lispa/lisp48j.htm (2 of 3) [23/03/2005 05:54:20 p.m.]
);if userclick
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Popup_List.
http://www.afralisp.com/lispa/lisp48j.htm (3 of 3) [23/03/2005 05:54:20 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
radio_button.
Syntax:
: radio_button {
action alignment fixed_height fixed_width
height is_enabled is_tab_stop key label
mnemonic value width
}
DCL Coding:
lisp48k : dialog { //dialog name
label = "radio_button" ; //give it a label
: radio_button { //*define radio button
key = "rb1" ; //*give it a name
label = "Bolt Holes &Site" ; //*give it a label
value = "1" ; //*switch it on
} //*end definition
: radio_button { //*define radio button
key = "rb2" ; //*give it a name
label = "Bolt Holes Sho&p" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "rb3" ; //*give it a name
label = "Bolt Holes &Hidden" ; //*give it a label
} //*end definition
: radio_button { //*define radio button
key = "rb4" ; //*give it a name
label = "Bolt Holes &Ctsnk" ; //*give it a label
} //*end definition
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48k ()
;define function
Functional Synopsis of DCL Tiles-Radio_Button.
http://www.afralisp.com/lispa/lisp48k.htm (1 of 3) [23/03/2005 05:54:21 p.m.]
(setq hole "Site")
;store default hole type
(setq dcl_id (load_dialog "lisp48k.dcl"))
;load dialog
(if (not (new_dialog "lisp48k" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile "rb1" "(setq hole \"Site\")")
;*store hole type
(action_tile "rb2" "(setq hole \"Shop\")")
;*store hole type
(action_tile "rb3" "(setq hole \"Hidden\")")
;*store hole type
(action_tile "rb4" "(setq hole \"Countersunk\")")
;*store hole type
(action_tile
"accept"
;if O.K. pressed
"(done_dialog) (setq userclick T)"
;close dialog
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected: " hole))
;display the Hole Type
);if userclick
(princ)
Functional Synopsis of DCL Tiles-Radio_Button.
http://www.afralisp.com/lispa/lisp48k.htm (2 of 3) [23/03/2005 05:54:21 p.m.]
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Radio_Button.
http://www.afralisp.com/lispa/lisp48k.htm (3 of 3) [23/03/2005 05:54:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
toggle.
Syntax:
: toggle {
action alignment fixed_height fixed_width
height is_enabled is_tab_stop key label
mnemonic value width
}
DCL Coding:
lisp48l : dialog { //dialog name
label = "toggle" ; //give it a label
:toggle { //define toggle
key = "tog1"; //give it a name
label = "Ortho On/Off"; //give it a label
} //end toggle
:toggle { //define toggle
key = "tog2"; //give it a name
label = "Snap On/Off"; //give it a label
} //end definition
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48l ()
;define function
(setq dcl_id (load_dialog "lisp48l.dcl"))
;load dialog
(if (not (new_dialog "lisp48l" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(setq orth (itoa (getvar "orthomode")))
;get orthomode value
Functional Synopsis of DCL Tiles-Toggle.
http://www.afralisp.com/lispa/lisp48l.htm (1 of 3) [23/03/2005 05:54:22 p.m.]
(set_tile "tog1" orth)
;switch toggle on or off
(setq sna (itoa (getvar "snapmode")))
;get snap value
(set_tile "tog2" sna)
;switch toggle on or off
(action_tile "tog1" "(setq orth $value)")
;get ortho toggle value
(action_tile "tog2" "(setq sna $value)")
;get snap toggle value
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn
(setvar \"orthomode\" (atoi orth))"
;ortho on/off
"(setvar \"snapmode\" (atoi sna))"
;snap on/off
"(done_dialog)(setq userclick T))"
;close dialog, set flag
);strcat
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(progn
;do the following
(if (= orth 1)
(alert "Ortho is ON")
Functional Synopsis of DCL Tiles-Toggle.
http://www.afralisp.com/lispa/lisp48l.htm (2 of 3) [23/03/2005 05:54:22 p.m.]
(alert "Ortho is OFF")
);if
(if (= sna 1)
(alert "Snap is ON")
(alert "Snap is OFF")
);if
);progn
);if userclick
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Toggle.
http://www.afralisp.com/lispa/lisp48l.htm (3 of 3) [23/03/2005 05:54:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
slider.
Syntax:
: slider {
action alignment big_increment fixed_height
fixed_width height key label layout max_value
min_value mnemonic small_increment value width
}
Note : As a slider should be used in conjunction with an edit box, the DCL and
AutoLisp coding for the edit box has been included here.
DCL Coding:
lisp48m : dialog { //dialog name
label = "slider" ; //give it a label
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Slot &Length (O/All Slot)" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
} //end slider
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48m ()
;define function
(setq lngth 50.0)
;preset slot length
(setq dcl_id (load_dialog "lisp48m.dcl"))
;load dialog
(if (not (new_dialog "lisp48m" dcl_id)
;test for dialog
Functional Synopsis of DCL Tiles-Slider.
http://www.afralisp.com/lispa/lisp48m.htm (1 of 3) [23/03/2005 05:54:24 p.m.]
);not
(exit)
;exit if no dialog
);if
(set_tile "eb1" "50")
;put data into edit box
(mode_tile "eb1" 2)
;switch focus to edit box
(action_tile "myslider"
;if user moves slider
"(slider_action $value $reason)")
;pass arguments to slider_action
(action_tile "eb1"
;if user enters slot length
"(ebox_action $value $reason)")
;pass arguments to ebox_action
(defun slider_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "eb1" val)))
;update edit box
(defun ebox_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "myslider" val)))
;update slider
(action_tile
"accept"
;if O.K. pressed
(strcat
;string 'em together
"(progn
(setq lngth (get_tile \"eb1\"))"
;get slot length
"(done_dialog)(setq userclick T))"
;close dialog, set flag
);strcat
);action tile
Functional Synopsis of DCL Tiles-Slider.
http://www.afralisp.com/lispa/lisp48m.htm (2 of 3) [23/03/2005 05:54:24 p.m.]
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected: " lngth))
;display the selected length.
);if userclick
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Slider.
http://www.afralisp.com/lispa/lisp48m.htm (3 of 3) [23/03/2005 05:54:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
image_button.
Syntax:
: image_button {
action alignment allow_accept aspect_ratio
color fixed_height fixed_width height
is_enabled is_tab_stop key label mnemonic
width
}
DCL Coding:
lisp48n : dialog { //dialog name
label = "image_button" ; //give it a label
: boxed_row { //define a boxed row
label = "Choose a Colour"; //gie it a label
: image_button { //define image button
key = "im0" ; //give it a name
height = 1.0 ; //define height
width = 2.0 ; //define width
fixed_width = true; //fix the width
allow_accept = true ; //allow double-click
}
: image_button {
key = "im1" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im2" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im3" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
Functional Synopsis of DCL Tiles-Image_Button.
http://www.afralisp.com/lispa/lisp48n.htm (1 of 5) [23/03/2005 05:54:25 p.m.]
allow_accept = true ;
}
: image_button {
key = "im4" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im5" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im6" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im7" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}

} //end boxed row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48n ()
;define function
(setq dcl_id (load_dialog "lisp48n.dcl"))
;load dialog
(if (not (new_dialog "lisp48n" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(setq width (dimx_tile "im0")
;get the image width
Functional Synopsis of DCL Tiles-Image_Button.
http://www.afralisp.com/lispa/lisp48n.htm (2 of 5) [23/03/2005 05:54:25 p.m.]
height (dimy_tile "im0")
;get the image height
) ;_ end of setq
(start_image "im0")
;start the image
(fill_image 0 0 width height 1)
;fill it with the relevant colour
(end_image)
;end the image
(setq width (dimx_tile "im1")
height (dimy_tile "im1")
) ;_ end of setq
(start_image "im1")
(fill_image 0 0 width height 30)
(end_image)
(setq width (dimx_tile "im2")
height (dimy_tile "im2")
) ;_ end of setq
(start_image "im2")
(fill_image 0 0 width height 2)
(end_image)
(setq width (dimx_tile "im3")
height (dimy_tile "im3")
) ;_ end of setq
(start_image "im3")
(fill_image 0 0 width height 3)
(end_image)
(setq width (dimx_tile "im4")
height (dimy_tile "im4")
) ;_ end of setq
(start_image "im4")
(fill_image 0 0 width height 4)
(end_image)
(setq width (dimx_tile "im5")
height (dimy_tile "im5")
) ;_ end of setq
(start_image "im5")
(fill_image 0 0 width height 5)
(end_image)
(setq width (dimx_tile "im6")
height (dimy_tile "im6")
) ;_ end of setq
(start_image "im6")
(fill_image 0 0 width height 6)
(end_image)
(setq width (dimx_tile "im7")
height (dimy_tile "im7")
) ;_ end of setq
(start_image "im7")
(fill_image 0 0 width height 7)
(end_image)
Functional Synopsis of DCL Tiles-Image_Button.
http://www.afralisp.com/lispa/lisp48n.htm (3 of 5) [23/03/2005 05:54:25 p.m.]
(action_tile "im0" "(setq la \"0\")")
'get the name of the colour selected
(action_tile "im1" "(setq la \"1\")")
(action_tile "im2" "(setq la \"2\")")
(action_tile "im3" "(setq la \"3\")")
(action_tile "im4" "(setq la \"4\")")
(action_tile "im5" "(setq la \"5\")")
(action_tile "im6" "(setq la \"6\")")
(action_tile "im7" "(setq la \"7\")")
(action_tile
"accept"
;if O.K. pressed
"(done_dialog)(setq userclick T)"
;close dialog, set flag
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected Colour: " la))
;display the colour selected.
);if userclick
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Image_Button.


http://www.afralisp.com/lispa/lisp48n.htm (4 of 5) [23/03/2005 05:54:25 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Image_Button.
http://www.afralisp.com/lispa/lisp48n.htm (5 of 5) [23/03/2005 05:54:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
image.
Syntax:
: image {
action alignment aspect_ratio color
fixed_height fixed_width height
is_enabled is_tab_stop key label mnemonic
value width
}
DCL Coding:
lisp48o : dialog { //dialog name
label = "image" ; //give it a label

: row { //begin row
: image { //define image tile
key = "im1" ; //give it a name
height = 5.0 ; //and a height
width = 10.0 ; //and now a width
fixed_width = true; //fix the width
fixed_height = true; //fix the height
} //end image
: image { //define image tile
key = "im2" ; //give it a name
height = 5.0 ; //add a height
width = 10.0 ; //and now a width
fixed_width = true; //fix the width
fixed_height = true; //fix the height
} //end image
: image { //define image tile
key = "im3" ; //give it a name
height = 5.0 ; //add a height
width = 10.0 ; //and now a width
fixed_width = true; //fix the width
fixed_height = true; //fix the height
color = graphics_background; //set background color
} //end image
} //end row
Functional Synopsis of DCL Tiles-Image.
http://www.afralisp.com/lispa/lisp48o.htm (1 of 4) [23/03/2005 05:54:26 p.m.]
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48o ()
;define function
(setq dcl_id (load_dialog "lisp48o.dcl"))
;load dialog
(if (not (new_dialog "lisp48o" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(setq w (dimx_tile "im1")
;get image tile width
h (dimy_tile "im1")
;get image tile height
);setq
(start_image "im1")
;start the image
(fill_image 0 0 w h 1)
;fill it with red
(end_image)
;end image
(setq w (dimx_tile "im2")
;get image tile width
h (dimy_tile "im2")
;get image tile height
);setq
(start_image "im2")
;start the image
(fill_image 0 0 w h 5)
;fill the image with blue
(setq w1 (/ w 2))
;calculate vector
(setq h1 (/ h 2))
;calculate vector
(vector_image 0 h w1 0 2)
;draw vector
(vector_image w1 0 w h 2)
Functional Synopsis of DCL Tiles-Image.
http://www.afralisp.com/lispa/lisp48o.htm (2 of 4) [23/03/2005 05:54:26 p.m.]
;draw vector
(vector_image 0 h w1 h1 2)
;draw vector
(vector_image w1 h1 w h 2)
;draw vector
(end_image)
;end image
(setq w (dimx_tile "im3")
;get image tile width
h (dimy_tile "im3")
;get image tile height
);setq
(start_image "im3")
;start the image
(slide_image 0 0 w h "acad(torus)")
;display a slide
(end_image)
;end image
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
Functional Synopsis of DCL Tiles-Image.
http://www.afralisp.com/lispa/lisp48o.htm (3 of 4) [23/03/2005 05:54:26 p.m.]
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Image.
http://www.afralisp.com/lispa/lisp48o.htm (4 of 4) [23/03/2005 05:54:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
text.
Syntax:
: text {
alignment fixed_height fixed_width height
is_bold key label value width
}
DCL Coding:
lisp48p : dialog { //dialog name
label = "text" ; //give it a label
: text { //define text
key = "txt1"; //give it a name
value = "This is sample text."; //add some text
} //end text
: text { //define text
key = "txt2"; //give it a name
} //end text
: text { //define text
key = "txt3"; //give it a name
value = "This text is centered."; //center the text
alignment = centered; //center the text
} //end text
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48p ()
;define function
(setq dcl_id (load_dialog "lisp48p.dcl"))
;load dialog
(if (not (new_dialog "lisp48p" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
Functional Synopsis of DCL Tiles-Text.
http://www.afralisp.com/lispa/lisp48p.htm (1 of 3) [23/03/2005 05:54:27 p.m.]
);if
(set_tile "txt2" "AutoLisp wrote this.")
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
Functional Synopsis of DCL Tiles-Text.
http://www.afralisp.com/lispa/lisp48p.htm (2 of 3) [23/03/2005 05:54:27 p.m.]
Search
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Text.
http://www.afralisp.com/lispa/lisp48p.htm (3 of 3) [23/03/2005 05:54:27 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
spacer.
Dialogue Without Spacer
Dialogue With Spacer
Syntax:
: spacer {
alignment fixed_height fixed_width
height width
}
DCL Coding:
lisp48q : dialog { //dialog name
label = "spacer" ; //give it a label
: button { //define button
key = "btn1"; //give it a name
label = "Button1"; //give it a label
fixed_width = true; //fix it's width
alignment = centered; //center it
} //end button
: spacer { //define space
height = 3; //define height
} //end spacer
: button { //define button
key = "btn2"; //give it a name
label = "Button1"; //give it a label
fixed_width = true; //fix it's width
alignment = centered; //center it
} //end button
Functional Synopsis of DCL Tiles-Spacer.
http://www.afralisp.com/lispa/lisp48q.htm (1 of 3) [23/03/2005 05:54:28 p.m.]
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48q ()
;define function
(setq dcl_id (load_dialog "lisp48q.dcl"))
;load dialog
(if (not (new_dialog "lisp48q" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Spacer.


http://www.afralisp.com/lispa/lisp48q.htm (2 of 3) [23/03/2005 05:54:28 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Spacer.
http://www.afralisp.com/lispa/lisp48q.htm (3 of 3) [23/03/2005 05:54:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
spacer_0.
Dialogue Without Spacer_0
Dialogue With Spacer_0
Syntax:
spacer_0;
The spacer_0 tile is defined in the Base.Dcl file.
DCL Coding:
lisp48r : dialog { //dialog name
label = "spacer_0" ; //give it a label
: row { //define row
: radio_button { //define radio button
label = "1"; //give it a label
key = "rb1"; //give it a name
value = "1"; //switch it on
} //end radio button
: radio_button { //define radio button
label = "2"; //give it a label
key = "rb2"; //give it a name
} //end radio button
spacer_0; //add spacer_0
: radio_button { //define radio button
label = "3"; //give it a label
key = "rb3"; //give it a name
} //end radio button
} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
Functional Synopsis of DCL Tiles-Spacer_0.
http://www.afralisp.com/lispa/lisp48r.htm (1 of 3) [23/03/2005 05:54:29 p.m.]
AutoLisp Coding:
(defun C:lisp48r ()
;define function
(setq dcl_id (load_dialog "lisp48r.dcl"))
;load dialog
(if (not (new_dialog "lisp48r" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Spacer_0.


http://www.afralisp.com/lispa/lisp48r.htm (2 of 3) [23/03/2005 05:54:29 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Spacer_0.
http://www.afralisp.com/lispa/lisp48r.htm (3 of 3) [23/03/2005 05:54:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
spacer_1.
Dialogue Without Spacer_1
Dialogue With Spacer_1
Syntax:
spacer_1;
The spacer_1 tile is defined in the Base.Dcl file.
DCL Coding:
lisp48s : dialog { //dialog name
label = "spacer_1" ; //give it a label
: row { //define row
: radio_button { //define radio button
label = "1"; //give it a label
key = "rb1"; //give it a name
value = "1"; //switch it on
} //end radio button
: radio_button { //define radio button
label = "2"; //give it a label
key = "rb2"; //give it a name
} //end radio button
spacer_1; //add spacer_1
: radio_button { //define radio button
label = "3"; //give it a label
key = "rb3"; //give it a name
} //end radio button
} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
Functional Synopsis of DCL Tiles-Spacer_1.
http://www.afralisp.com/lispa/lisp48s.htm (1 of 3) [23/03/2005 05:54:31 p.m.]
(defun C:lisp48s ()
;define function
(setq dcl_id (load_dialog "lisp48s.dcl"))
;load dialog
(if (not (new_dialog "lisp48s" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Spacer_1.


http://www.afralisp.com/lispa/lisp48s.htm (2 of 3) [23/03/2005 05:54:31 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Spacer_1.
http://www.afralisp.com/lispa/lisp48s.htm (3 of 3) [23/03/2005 05:54:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
concatenation.
Syntax:
: concatenation {
}
The concatenation tile is defined in the Base.Dcl file.
DCL Coding:
lisp48t : dialog { //dialog name
label = "concatenation" ; //give it a label
: concatenation { //define concatenation
: text_part { //text part
label = "This is a"; //add text
} //end text
: text_part { //text part
label = "concenantation"; //add text
} //end text
: text_part { //text part
label = "of words"; //add text
} //end text
} //end concatenation
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48t ()
;define function
(setq dcl_id (load_dialog "lisp48t.dcl"))
;load dialog
(if (not (new_dialog "lisp48t" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
Functional Synopsis of DCL Tiles-Concatenation.
http://www.afralisp.com/lispa/lisp48t.htm (1 of 2) [23/03/2005 05:54:32 p.m.]
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Concatenation.
http://www.afralisp.com/lispa/lisp48t.htm (2 of 2) [23/03/2005 05:54:32 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
paragraph.
Syntax:
: paragraph {
}
The paragraph tile is defined in the Base.Dcl file.
DCL Coding:
lisp48u : dialog { //dialog name
label = "paragraph" ; //give it a label
: paragraph { //define paragraph
: text_part { //text
label = "This is a"; //add text
alignment = centered; //center the text
} //end text
: text_part { //text
label = "paragraph"; //add text
alignment = centered; //center the text
} //end text
: text_part { //text
label = "of words."; //add text
alignment = centered; //center the text
} //end text
} //end paragraph
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48u ()
;define function
(setq dcl_id (load_dialog "lisp48u.dcl"))
;load dialog
(if (not (new_dialog "lisp48u" dcl_id)
;test for dialog
Functional Synopsis of DCL Tiles-Paragraph.
http://www.afralisp.com/lispa/lisp48u.htm (1 of 3) [23/03/2005 05:54:33 p.m.]
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Functional Synopsis of DCL Tiles-Paragraph.
http://www.afralisp.com/lispa/lisp48u.htm (2 of 3) [23/03/2005 05:54:33 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Paragraph.
http://www.afralisp.com/lispa/lisp48u.htm (3 of 3) [23/03/2005 05:54:33 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
text_part.
Syntax:
: text_part {
key label
}
The text_part tile is defined in the Base.Dcl file.
DCL Coding:
lisp48v : dialog { //dialog name
label = "text_part" ; //give it a label
: paragraph { //define paragraph
: text_part { //text
label = "You are on"; //add text
alignment = centered; //center the text
} //end text
: text_part { //text
label = "Layer"; //add text
alignment = centered; //center the text
} //end text
: text_part { //text
key = "txt1"; //give it a name
alignment = centered; //center the text
} //end text
} //end paragraph
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48v ()
;define function
(setq la (getvar "clayer"))
(setq dcl_id (load_dialog "lisp48v.dcl"))
;load dialog
Functional Synopsis of DCL Tiles-Text_Part.
http://www.afralisp.com/lispa/lisp48v.htm (1 of 3) [23/03/2005 05:54:34 p.m.]
(if (not (new_dialog "lisp48v" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(set_tile "txt1" la)
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Text_Part.


http://www.afralisp.com/lispa/lisp48v.htm (2 of 3) [23/03/2005 05:54:34 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Text_Part.
http://www.afralisp.com/lispa/lisp48v.htm (3 of 3) [23/03/2005 05:54:34 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
boxed_column.
Syntax:
: boxed_column {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48w : dialog { //dialog name
label = "boxed_column" ; //give it a label
: boxed_column { //define boxed column
label = "boxed column"; //give it a label
: toggle { //define a toggle
key = "tog1"; //give it a name
label = "Toggle 1"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog2"; //give it a name
label = "Toggle 1"; //give it a label
value = "2"; //switch it off
} //end toggle
: toggle { //define a toggle
key = "tog3"; //give it a name
label = "Toggle 1"; //give it a label
value = "1"; //switch it on
} //end toggle
} //end boxed column
ok_cancel ; //predefined OK/Cancel button
Functional Synopsis of DCL Tiles-Boxed_Column.
http://www.afralisp.com/lispa/lisp48w.htm (1 of 3) [23/03/2005 05:54:36 p.m.]
} //end dialog
AutoLisp Coding:
(defun C:lisp48w ()
;define function
(setq dcl_id (load_dialog "lisp48w.dcl"))
;load dialog
(if (not (new_dialog "lisp48w" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Boxed_Column.


http://www.afralisp.com/lispa/lisp48w.htm (2 of 3) [23/03/2005 05:54:36 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Boxed_Column.
http://www.afralisp.com/lispa/lisp48w.htm (3 of 3) [23/03/2005 05:54:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
boxed_radio_column.
Syntax:
: boxed_radio_column {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48x : dialog { //dialog name
label = "boxed_radio_column"; //give it a label
: boxed_radio_column { //define boxed radio column
label = "boxed radio column"; //give it a label
: radio_button { //define a radio button
key = "rad1"; //give it a name
label = "Blonde"; //give it a label
value = "1"; //switch it on
} //end radio button
: radio_button { //define a radio button
key = "rad2"; //give it a name
label = "Brunette"; //give it a label
} //end radio button
: radio_button { //define a radio button
key = "rad3"; //give it a name
label = "Red Head"; //give it a label
} //end radio button
} //end boxed radio column
ok_cancel ; //predefined OK/Cancel button
} //end dialog
Functional Synopsis of DCL Tiles-Boxed_Radio_Column.
http://www.afralisp.com/lispa/lisp48x.htm (1 of 3) [23/03/2005 05:54:37 p.m.]
AutoLisp Coding:
(defun C:lisp48x ()
;define function
(setq dcl_id (load_dialog "lisp48x.dcl"))
;load dialog
(if (not (new_dialog "lisp48x" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Boxed_Radio_Column.


http://www.afralisp.com/lispa/lisp48x.htm (2 of 3) [23/03/2005 05:54:37 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Boxed_Radio_Column.
http://www.afralisp.com/lispa/lisp48x.htm (3 of 3) [23/03/2005 05:54:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
boxed_radio_row.
Syntax:
: boxed_radio_row {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48y : dialog { //dialog name
label = "boxed_radio_row"; //give it a label
: boxed_radio_row { //define boxed radio row
label = "boxed radio row"; //give it a label
: radio_button { //define a radio button
key = "rad1"; //give it a name
label = "Blonde"; //give it a label
value = "1"; //switch it on
} //end radio button
: radio_button { //define a radio button
key = "rad2"; //give it a name
label = "Brunette"; //give it a label
} //end radio button
: radio_button { //define a radio button
key = "rad3"; //give it a name
label = "Red Head"; //give it a label
} //end radio button
} //end boxed radio row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48y ()
Functional Synopsis of DCL Tiles-Boxed_Radio_Row.
http://www.afralisp.com/lispa/lisp48y.htm (1 of 3) [23/03/2005 05:54:38 p.m.]
;define function
(setq dcl_id (load_dialog "lisp48y.dcl"))
;load dialog
(if (not (new_dialog "lisp48y" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Boxed_Radio_Row.


http://www.afralisp.com/lispa/lisp48y.htm (2 of 3) [23/03/2005 05:54:38 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Boxed_Radio_Row.
http://www.afralisp.com/lispa/lisp48y.htm (3 of 3) [23/03/2005 05:54:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
boxed_row.
Syntax:
: boxed_row {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48z : dialog { //dialog name
label = "boxed_row"; //give it a label
: boxed_row { //define boxed row
label = "boxed row"; //give it a label
: toggle { //define a toggle
key = "tog1"; //give it a name
label = "Whiskey"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog2"; //give it a name
label = "Wine"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog3"; //give it a name
label = "Beer"; //give it a label
value = "0"; //switch it on
} //end toggle
} //end boxed row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
Functional Synopsis of DCL Tiles-Boxed_Row.
http://www.afralisp.com/lispa/lisp48z.htm (1 of 3) [23/03/2005 05:54:39 p.m.]
(defun C:lisp48z ()
;define function
(setq dcl_id (load_dialog "lisp48z.dcl"))
;load dialog
(if (not (new_dialog "lisp48z" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Boxed_Row.


http://www.afralisp.com/lispa/lisp48z.htm (2 of 3) [23/03/2005 05:54:39 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Boxed_Row.
http://www.afralisp.com/lispa/lisp48z.htm (3 of 3) [23/03/2005 05:54:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
column.
Syntax:
: column {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLips coding has been included for the Active Children Tiles.
DCL Coding:
lisp48aa : dialog { //dialog name
label = "column" ; //give it a label
: column { //define column
: toggle { //define a toggle
key = "tog1"; //give it a name
label = "Toggle 1"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog2"; //give it a name
label = "Toggle 1"; //give it a label
value = "2"; //switch it off
} //end toggle
: toggle { //define a toggle
key = "tog3"; //give it a name
label = "Toggle 1"; //give it a label
value = "1"; //switch it on
} //end toggle
} //end column
ok_cancel ; //predefined OK/Cancel button
} //end dialog
Functional Synopsis of DCL Tiles-Column.
http://www.afralisp.com/lispa/lisp48aa.htm (1 of 3) [23/03/2005 05:54:40 p.m.]
AutoLisp Coding:
(defun C:lisp48aa ()
;define function
(setq dcl_id (load_dialog "lisp48aa.dcl"))
;load dialog
(if (not (new_dialog "lisp48aa" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Column.


http://www.afralisp.com/lispa/lisp48aa.htm (2 of 3) [23/03/2005 05:54:40 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Column.
http://www.afralisp.com/lispa/lisp48aa.htm (3 of 3) [23/03/2005 05:54:40 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
dialog.
Syntax:
: dialog {
initial_focus label value
}
DCL Coding:
lisp48ab : dialog { //dialog name
label = "dialog" ; //give it a label
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48ab ()
;define function
(setq dcl_id (load_dialog "lisp48ab.dcl"))
;load dialog
(if (not (new_dialog "lisp48ab" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
Functional Synopsis of DCL Tiles-Dialog.
http://www.afralisp.com/lispa/lisp48ab.htm (1 of 2) [23/03/2005 05:54:42 p.m.]
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Dialog.
http://www.afralisp.com/lispa/lisp48ab.htm (2 of 2) [23/03/2005 05:54:42 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
radio_column.
Syntax:
: radio_column {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLips coding has been included for the Active Children Tiles.
DCL Coding:
lisp48ac : dialog { //dialog name
label = "radio_column"; //give it a label
: radio_column { //define radio column
: radio_button { //define a radio button
key = "rad1"; //give it a name
label = "Blonde"; //give it a label
value = "1"; //switch it on
} //end radio button
: radio_button { //define a radio button
key = "rad2"; //give it a name
label = "Brunette"; //give it a label
} //end radio button
: radio_button { //define a radio button
key = "rad3"; //give it a name
label = "Red Head"; //give it a label
} //end radio button
} //end radio column
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48ac ()
Functional Synopsis of DCL Tiles-Radio_Column.
http://www.afralisp.com/lispa/lisp48ac.htm (1 of 3) [23/03/2005 05:54:43 p.m.]
;define function
(setq dcl_id (load_dialog "lisp48ac.dcl"))
;load dialog
(if (not (new_dialog "lisp48ac" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Radio_Column.


http://www.afralisp.com/lispa/lisp48ac.htm (2 of 3) [23/03/2005 05:54:43 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Radio_Column.
http://www.afralisp.com/lispa/lisp48ac.htm (3 of 3) [23/03/2005 05:54:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
radio_row.
Syntax:
: radio_row {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48ad : dialog { //dialog name
label = "radio_row"; //give it a label
: radio_row { //define radio row
: radio_button { //define a radio button
key = "rad1"; //give it a name
label = "Blonde"; //give it a label
value = "1"; //switch it on
} //end radio button
: radio_button { //define a radio button
key = "rad2"; //give it a name
label = "Brunette"; //give it a label
} //end radio button
: radio_button { //define a radio button
key = "rad3"; //give it a name
label = "Red Head"; //give it a label
} //end radio button
} //end radio row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48ad ()
;define function
(setq dcl_id (load_dialog "lisp48ad.dcl"))
Functional Synopsis of DCL Tiles-Radio_Row.
http://www.afralisp.com/lispa/lisp48ad.htm (1 of 3) [23/03/2005 05:54:44 p.m.]
;load dialog
(if (not (new_dialog "lisp48ad" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Radio_Row.


http://www.afralisp.com/lispa/lisp48ad.htm (2 of 3) [23/03/2005 05:54:44 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Radio_Row.
http://www.afralisp.com/lispa/lisp48ad.htm (3 of 3) [23/03/2005 05:54:44 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
row.
Syntax:
: row {
alignment children_alignment children_fixed_height
children_fixed_width fixed_height fixed_width
height label width
}
Note: This Tile Cluster is for display purpose only.
No AutoLisp coding has been included for the Active Children Tiles.
DCL Coding:
lisp48ae : dialog { //dialog name
label = "row"; //give it a label
: row { //define row
: toggle { //define a toggle
key = "tog1"; //give it a name
label = "Whiskey"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog2"; //give it a name
label = "Wine"; //give it a label
value = "1"; //switch it on
} //end toggle
: toggle { //define a toggle
key = "tog3"; //give it a name
label = "Beer"; //give it a label
value = "0"; //switch it on
} //end toggle
} //end row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLisp Coding:
(defun C:lisp48ae ()
;define function
Functional Synopsis of DCL Tiles-Row.
http://www.afralisp.com/lispa/lisp48ae.htm (1 of 3) [23/03/2005 05:54:45 p.m.]
(setq dcl_id (load_dialog "lisp48ae.dcl"))
;load dialog
(if (not (new_dialog "lisp48ae" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(action_tile
"accept"
;if O.K. pressed

"(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;if OK selected
(alert "You selected OK")
;inform the user
(alert "You selected Cancel")
;inform the user
);if
(princ)
);defun
(princ)

Functional Synopsis of DCL Tiles-Row.


http://www.afralisp.com/lispa/lisp48ae.htm (2 of 3) [23/03/2005 05:54:45 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Functional Synopsis of DCL Tiles-Row.
http://www.afralisp.com/lispa/lisp48ae.htm (3 of 3) [23/03/2005 05:54:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Dialogue Box Default Data
When a user works with a dialogue box he enters the required data and then exits the dialogue box. On
returning to the dialogue box, the data contained in the box should be updated to reflect the users previous
entries. Most users tend to re-use the same set of data time after time, and it can be very frustrating to have to
retype the same data every time you re-open a dialogue box.
To create defaults in a dialogue box is a 5 step process :
Retrieve the global variables containing the default data. G
If they do not exist, create some default data. G
Display the default data to the user. G
Allow the user to change the data. G
When the user exits the dialogue box, store this data as defaults. G
The following application will show you how to do this :
DCL Coding:
test1 : dialog { //dialog name
label = "Dialogue Defaults" ; //give it a label
: row { //define row
: toggle { //define toggle
key = "tog1"; //give it a name
label = "On or Off"; //give it a label
} //end toggle
: toggle { //define toggle
key = "tog2"; //give it a name
label = "Left or Right"; //give it a label
} //end toggle
} //end row
spacer; //put in a space
: edit_box { //define edit box
key = "eb2" ; //give it a name
label = "&Enter a couple of Letters" ; //give it a label
} //end edit box
spacer; //put in a space
: edit_box { //define edit box
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (1 of 9) [23/03/2005 05:54:47 p.m.]
key = "eb1" ; //give it a name
label = "&Value of Slider" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
small_increment = 2; //define small increment
big_increment = 5; //define big increment
} //end slider
spacer; //put in a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLISP Coding:
(defun C:test1 ()
;define function
;;;*****************************************************
;;;This section sets up the dialogue box default settings.
(if (not lngth)
;if no default
(setq lngth "50.0")
;set a default value
);if
;slider and slider edit box value
(if (not letters)
;if no default
(setq letters "ABC")
;set default value
);if
(if (not toggle1)
;if no default
(setq toggle1 "1")
;set default value
);if
(if (not toggle2)
;if no default
(setq toggle2 "0")
;set default value
);if
;;;**********************************************************
(setq dcl_id (load_dialog "test1.dcl"))
;load dialog
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (2 of 9) [23/03/2005 05:54:47 p.m.]
(if (not (new_dialog "test1" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;******************************************************************
;;;This section sets the dialogue box default values
(set_tile "tog1" toggle1)
;set toggle
(set_tile "tog2" toggle2)
;set toggle
(set_tile "eb2" letters)
;put data into edit box
(set_tile "eb1" lngth)
;put data into edit box
(set_tile "myslider" lngth)
;set the slider
;;;*********************************************************************
;;;This section retrieves the dialogue box values
(action_tile "myslider"
;if user moves slider
"(slider_action $value $reason)")
;pass arguments to slider_action
(action_tile "eb1"
;if user enters slot length
"(ebox_action $value $reason)")
;pass arguments to ebox_action
(defun slider_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "eb1" val)))
;update edit box
(defun ebox_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "myslider" val)))
;update slider
(action_tile "tog1"
;if toggle 1 selected
"(setq toggle1 $value)"
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (3 of 9) [23/03/2005 05:54:47 p.m.]
;get the value
);action_tile
(action_tile "tog2"
;if toggle 2 selected
"(setq toggle2 $value)"
;get the value
);action_tile
(action_tile
"accept"
;if O.K. pressed
"(progn
;do the following
(setq lngth (get_tile \"eb1\"))
;get the edit box value
(setq letters (get_tile \"eb2\"))
;get the slider value
(done_dialog) (setq userclick T))"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog and clear flag
);action_tile
;;********************************************************************
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected: " lngth " and " letters))
;display the Data
);if userclick
(princ)
);defun
(princ)
Now load and run this application in AutoCAD. Enter some new data and exit the dialogue box. Run the
application again. You will find that the dialogue box
has 'remembered' your entries.
Now this is fine, but if you start a new drawing, or exit AutoCAD these values will be lost. Let's re-write this
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (4 of 9) [23/03/2005 05:54:47 p.m.]
routine to "permanently" remember these values.
To do this we will make use of Application Data. Here's how :
DCL Coding:
test2 : dialog { //dialog name
label = "Dialogue Defaults" ; //give it a label
: row { //define row
: toggle { //define toggle
key = "tog1"; //give it a name
label = "On or Off"; //give it a label
} //end toggle
: toggle { //define toggle
key = "tog2"; //give it a name
label = "Left or Right"; //give it a label
} //end toggle
} //end row
spacer; //put in a space
: edit_box { //define edit box
key = "eb2" ; //give it a name
label = "&Enter a couple of Letters" ; //give it a label
} //end edit box
spacer; //put in a space
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "&Value of Slider" ; //give it a label
edit_width = 6 ; //6 characters only
} //end edit box
: slider { //define slider
key = "myslider" ; //give it a name
max_value = 100; //upper value
min_value = 0; //lower value
value = "50"; //initial value
small_increment = 2; //define small increment
big_increment = 5; //define big increment
} //end slider
spacer; //put in a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog
AutoLISP Coding:
(defun C:test2 ()
;define function
;;;*****************************************************
;;;This section retrieves the default data from the
;;;ACADR14.CFG file.
(setq lngth (getcfg "AppData/CadKen/default1"))
;get the apllication data
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (5 of 9) [23/03/2005 05:54:47 p.m.]
(if (= lngth nil)
;if it is nil
(progn
;do the following

(setcfg "AppData/CadKen/default1" "50.0")
;set the default data
(setq lngth (getcfg "AppData/CadKen/default1"))
;retrieve the default data
);progn
);if
(setq letters (getcfg "AppData/CadKen/default2"))
;get the aplication data
(if (= letters nil)
;if it is nil
(progn
;do the following

(setcfg "AppData/CadKen/default2" "ABC")
;set the default data
(setq letters (getcfg "AppData/CadKen/default2"))
;retrieve the default data
);progn
);if

(setq toggle1 (getcfg "AppData/CadKen/default3"))
;get the apllication data
(if (= toggle1 nil)
;if it is nil
(progn
;do the following

(setcfg "AppData/CadKen/default3" "1")
;set the default data
(setq toggle1 (getcfg "AppData/CadKen/default3"))
;retrieve the default data
);progn
);if
(setq toggle2 (getcfg "AppData/CadKen/default4"))
;get the apllication data
(if (= toggle2 nil)
;if it is nil
(progn
;do the following

Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (6 of 9) [23/03/2005 05:54:47 p.m.]
(setcfg "AppData/CadKen/default4" "0")
;set the default data
(setq toggle2 (getcfg "AppData/CadKen/default4"))
;retrieve the default data
);progn
);if
;;;**********************************************************
(setq dcl_id (load_dialog "test2.dcl"))
;load dialog
(if (not (new_dialog "test2" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;******************************************************************
;;;This section sets the dialogue box default values
(set_tile "tog1" toggle1)
;set toggle
(set_tile "tog2" toggle2)
;set toggle
(set_tile "eb2" letters)
;put data into edit box
(set_tile "eb1" lngth)
;put data into edit box
(set_tile "myslider" lngth)
;set the slider
;;;*********************************************************************
;;;This section retrieves the dialogue box values
(action_tile "myslider"
;if user moves slider
"(slider_action $value $reason)")
;pass arguments to slider_action
(action_tile "eb1"
;if user enters slot length
"(ebox_action $value $reason)")
;pass arguments to ebox_action
(defun slider_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "eb1" val)))
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (7 of 9) [23/03/2005 05:54:47 p.m.]
;update edit box
(defun ebox_action (val why)
;define function
(if (or (= why 2) (= why 1))
;check values
(set_tile "myslider" val)))
;update slider
(action_tile "tog1"
;if toggle 1 selected
"(setq toggle1 $value)"
;get the value
);action_tile
(action_tile "tog2"
;if toggle 2 selected
"(setq toggle2 $value)"
;get the value
);action_tile
(action_tile
"accept"
;if O.K. pressed
"(progn
;do the following
(setq lngth (get_tile \"eb1\"))
;get the slider value
(setq letters (get_tile \"eb2\"))
;get the edit box value
(done_dialog) (setq userclick T))"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog and clear flag
);action_tile
;;********************************************************************
(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
;;;*******************************************************************
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (8 of 9) [23/03/2005 05:54:47 p.m.]
;;;This section stores the data into the AACDR14.CFG file and displays
;;;them to the user.
(progn
(setcfg "AppData/CadKen/default1" lngth)
;store the data
(setcfg "AppData/CadKen/default2" letters)
;store the data
(setcfg "AppData/CadKen/default3" toggle1)
;store the data
(setcfg "AppData/CadKen/default4" toggle2)
;store the data
(alert (strcat "You Entered: " lngth " and " letters))
;display the Data
);progn
);if userclick
(princ)
);defun
(princ)
Now load and run this application. Again, add some new values and exit the dialogue.
Now exit AutoCAD. Re-enter AutoCAD and load and run the application again.
Your values have been retained....
To download the source coding for this tutorial click here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Dialog Box Default Data
http://www.afralisp.com/lispa/lisp50.htm (9 of 9) [23/03/2005 05:54:47 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Application Data.
Have you ever looked at the ACAD14.CFG file? (Autocad Configuration File)
This is simply a text file divided into sections.
The only section that you have control over is the [AppData] section.
Let's do something with it.
Say you wanted to store 2 bits of information that you use in one of your
AutoLisp routines. You would store them like this :
(setcfg "appdata/test/bolt" "M24")
(setcfg "appdata/test/length "90")
After (setcfg must come "appdata" followed by your application name,
which must be unique. Following this is the variable tag and then the
information you wish to store. If you open the ACAD14.CFG file, this is
what the [AppData] section will look like :
[AppData/test]
bolt=4
length=90
To retrieve this data you would use the following syntax :
(setq a (getcfg "appdata/test/bolt"))
(setq b (getcfg "appdata/test/length"))
This would set a to "M24" and b to "90".
Now this is great, I hear you say, but were would you use it.
Here's a good example for you :
Say you've written a routine that you would like other people to use on a trial basis, say 5 times. After
the 5 times they either pay up, or the routine ceases to work.
What we are going to do is first write a simple routine.
Then we will write a sub-routine that stores the number of times the routine is run in the [AppData]
section. Next, we will check the number of times it has been run and then decide whether the limit has
expired or not. Have a look :
;Main function
(defun c:test8 ()
(register)
(if flagset
(alert "\nThe programme will now run.")
);if
(princ)
)defun
;Sub-function
(defun register ()
(setq v1 (getcfg "AppData/CadKen/test"))
(if (= v1 nil)
Application Data
http://www.afralisp.com/lispa/lisp12.htm (1 of 2) [23/03/2005 05:54:48 p.m.]
(progn
(setcfg "AppData/CadKen/test" "1")
(setq v1 (getcfg "AppData/CadKen/test"))
);progn
);if
(setq v2 5)
(setq v1 (atoi v1))
(if (< v1 v2)
(progn
(setq v1 (+ v1 1))
(cond
((= v1 1) (setcfg "AppData/CadKen/test" "1"))
((= v1 2) (setcfg "AppData/CadKen/test" "2"))
((= v1 3) (setcfg "AppData/CadKen/test" "3"))
((= v1 4) (setcfg "AppData/CadKen/test" "4"))
((= v1 5) (setcfg "AppData/CadKen/test" "5"))
);cond
(setq v3 v1)
(setq v3 (rtos (- v2 v1)))
(alert (strcat "\n You Have " v3 " more Loadings Left"))
(setq flagset T)
);progn
(progn
(alert "\nEvalution Period has Expired
\n Contact Kenny Ramage
\n ndbe51d1@db.za
\n For Licensed Copy")
(setq flagset nil)
);progn
);if
(princ)
);defun
(princ)
This is a very simple but usefull routine that demonstrates the use of [AppData]. You would still, of
course, have to encrypt or compile your routine to stop the user simply changing the variable that
contains the usage control number. If you would like the source code, I have included it here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Application Data
http://www.afralisp.com/lispa/lisp12.htm (2 of 2) [23/03/2005 05:54:48 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DCL Model
**Click on Relevant Image for Coding**
This model lays out the function
sequence required to design a
dialogue box using AutoLisp and
Dialogue Control Language. (DCL)
To download source coding for this tutorial
Click Here. (61 kB)

DCL Model.
http://www.afralisp.com/lispa/lisp51.htm (1 of 2) [23/03/2005 05:54:52 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51.htm (2 of 2) [23/03/2005 05:54:52 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
-
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51b.htm (1 of 4) [23/03/2005 05:54:53 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51b.htm (2 of 4) [23/03/2005 05:54:53 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51b.htm (3 of 4) [23/03/2005 05:54:53 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51b.htm (4 of 4) [23/03/2005 05:54:53 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
-
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
DCL Model.
http://www.afralisp.com/lispa/lisp51c.htm (1 of 4) [23/03/2005 05:54:54 p.m.]
;;;list box, switches on the default radio button and
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
DCL Model.
http://www.afralisp.com/lispa/lisp51c.htm (2 of 4) [23/03/2005 05:54:54 p.m.]
);action_tile
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51c.htm (3 of 4) [23/03/2005 05:54:54 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51c.htm (4 of 4) [23/03/2005 05:54:54 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
-
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
DCL Model.
http://www.afralisp.com/lispa/lisp51d.htm (1 of 4) [23/03/2005 05:54:55 p.m.]
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
DCL Model.
http://www.afralisp.com/lispa/lisp51d.htm (2 of 4) [23/03/2005 05:54:55 p.m.]
);action_tile
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
DCL Model.
http://www.afralisp.com/lispa/lisp51d.htm (3 of 4) [23/03/2005 05:54:55 p.m.]
);progn
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51d.htm (4 of 4) [23/03/2005 05:54:55 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
-
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51e.htm (1 of 4) [23/03/2005 05:54:56 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51e.htm (2 of 4) [23/03/2005 05:54:56 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51e.htm (3 of 4) [23/03/2005 05:54:56 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51e.htm (4 of 4) [23/03/2005 05:54:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51f.htm (1 of 4) [23/03/2005 05:54:57 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
-
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51f.htm (2 of 4) [23/03/2005 05:54:57 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51f.htm (3 of 4) [23/03/2005 05:54:57 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51f.htm (4 of 4) [23/03/2005 05:54:57 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51g.htm (1 of 4) [23/03/2005 05:54:58 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51g.htm (2 of 4) [23/03/2005 05:54:58 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
-
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51g.htm (3 of 4) [23/03/2005 05:54:58 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51g.htm (4 of 4) [23/03/2005 05:54:58 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51h.htm (1 of 4) [23/03/2005 05:54:59 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51h.htm (2 of 4) [23/03/2005 05:54:59 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
-
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51h.htm (3 of 4) [23/03/2005 05:54:59 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51h.htm (4 of 4) [23/03/2005 05:54:59 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - AutoLisp Coding
(defun C:lisp51 ()
;define function - variables have been left as local
;for inspection purposes.
;;;**************************************************************
;;;This section assigns all the default values of the dialogue
;;;box into their relevant variables.
(setq names '("50 NB" "60 NB" "70 NB" "80 NB" "90 NB"
"100 NB" "125 NB" "150 NB" "200 NB" "250 NB"))
;default list for pipe diameter list box
(setq rad "Long")
;set default for radius radio buttons
(setq schedule "40")
;set default pipe schedule for edit box
(setq index "3")
;set default pipe size index
;;;**************************************************************
;;;This section loads the relevant DCL file containing the
;;;dialogue box definition.
(setq dcl_id (load_dialog "lisp51.dcl"))
;load dialog
;;;**************************************************************
;;;This section loads the particular dialogue box definition
;;;contained within the DCL file. It first checks that the
;;;DCL file has been loaded.
(if (not (new_dialog "lisp51" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
;;;**************************************************************
;;;This section initializes the dialogue box tiles.
;;;It fills the list box, pre-selects an item in the
;;;list box, switches on the default radio button and
DCL Model.
http://www.afralisp.com/lispa/lisp51i.htm (1 of 4) [23/03/2005 05:55:00 p.m.]
;;;puts a default value into the edit box.
(start_list "lb1")
;open the list box
(mapcar 'add_list names)
;add the names to the list box
(end_list)
;end the list box
(set_tile "lb1" "3")
;select 4th item in list box
(set_tile "rb1" "1")
;switch on radio button No 1
(set_tile "eb1" "40")
;set default pipe schedule
;;;***************************************************************
;;;This section retrieves the values that the user selects
;;;or inputs. In effect, what we are saying here is :
;;;"Remember the coding that is in this section. When start_dialog
;;;is called, and a tile is selected, proceed with the relevant
;;;coding.
(action_tile "rb1"
;if radio button No 1 selected
"(setq rad \"Long\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb2"
;if radio button No 2 selected
"(setq rad \"Medium\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
(action_tile "rb3"
;if radio button No 3 selected
"(setq rad \"Short\")
;store radius
(mode_tile \"eb1\" 2)"
;set focus to edit box
);action_tile
DCL Model.
http://www.afralisp.com/lispa/lisp51i.htm (2 of 4) [23/03/2005 05:55:00 p.m.]
(action_tile
"accept"
;if O.K. pressed
"(setq schedule (get_tile \"eb1\"))
;get the schedule entered

(setq index (atof (get_tile \"lb1\")))
;get the index of the pipe diameter entered

(done_dialog) (setq userclick T)"
;close dialog, set flag

);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, lower flag
);action_tile
;;;*******************************************************************
;;;This section displays the dialogue box and waits for user input
(start_dialog)
;start dialog
;;;*******************************************************************
;;;done_dialogue has been called, so the dialogue can be unloaded

(unload_dialog dcl_id)
;unload
-
;;;********************************************************************
;;;If the O.K. tile was selected, process the users input values.
(if userclick
;if OK selected
(progn
;do the following
(setq index (fix index))
;convert index to integer
(setq size (nth index names))
;get the pipe size from the list
(alert (strcat "You Choose a : " size"\n"
rad " : Radius" "\n"
"Sched : " schedule " Pipe Bend"))
;string the results together and display them to the user
);progn
DCL Model.
http://www.afralisp.com/lispa/lisp51i.htm (3 of 4) [23/03/2005 05:55:00 p.m.]
);if
;;;*******************************************************************
(princ)
;finish clean
);defun
(princ)
;load clean
;;;********************************************************************

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51i.htm (4 of 4) [23/03/2005 05:55:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Back to Model....
DCL Model - DCL Coding
lisp51 : dialog { //dialog name
label = "Pipe Bends" ; //give it a label
: row { //define a row
children_alignment = top ; //align to top
: popup_list { //define list box
key = "lb1" ; //give it a name
} //end list box
: radio_column { //define radio column
label = "Radius :"; //give it a label
: radio_button { //define radio button
label = "Long" ; //give it a label
key = "rb1" ; //give it a name
} //end radio button
: radio_button { //define radio button
label = "Medium"; //give it a label
key = "rb2" ; //give it a name
} //end radio button
: radio_button { //define radio button
label = "Short"; //give it a label
key = "rb3" ; //give it a name
} //end radio button
} //end radio column
} //end row
spacer ; //add a space
: edit_box { //define edit box
key = "eb1" ; //give it a name
label = "Pipe Schedule :" ; //give it a label
} //end edit box
spacer ; //add a space
ok_cancel ; //predefined OK/Cancel button
} //end dialog

DCL Model.
http://www.afralisp.com/lispa/lisp51j.htm (1 of 2) [23/03/2005 05:55:01 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Model.
http://www.afralisp.com/lispa/lisp51j.htm (2 of 2) [23/03/2005 05:55:01 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
A DCL Progress Bar Tutorial
(C) 1999 by Nir sullam & anySOFT

Download the code for this example


This short tutorial will teach you how to create a nifty little Progress Bar in your dialog
box. (such as the one in the PLOT dialog box).
This is needed when your program reports the user about its operation and progress
when it usually takes some time.
One example is when you select a large amount of objects and the program makes some
changes to them. If the process consumes time - the program needs to inform the user in
percentage or in numbers.
First we create the DCL box for this example: It will have an EDIT_BOX to enter the MAX
number, and also a "Start" BUTTON to start the loop function. The IMAGE tile is the tile
where the progress bar will show.
dcltut : dialog {
fixed_width = true;
label = "DCL Progress Bar Tutorial 1.0";
key = "br-label";
: row {
: button {
key = "start";
label = "Start";
mnemonic = "S";
}
: edit_box {
key = "max";
label = "Max:";
mnemonic = "M";
}
}
: image {
key = "progbar";
fixed_width = 50;
height = 1;
}
/// This Tile may also be put below the OK_Cancel buttons
: row {
: button {
label = "OK";
mnemonic = "O";
key = "ok";
}
: button {
label = "Cancel";
mnemonic = "C";
key = "cancel";
is_cancel = true;
DCL Progress Bar
http://www.afralisp.com/lispa/lisp53.htm (1 of 3) [23/03/2005 05:55:04 p.m.]
}
}
: row {
: errtile {
label = "";
key = "error";
width = 26;
}
}
}

The resulting DCL is as below: ( the screenshot was taken while running)
The LISP file code is as follows:
;;; DCL Tutorial
;;; Subject: Creating a ProgressBar in DCL.
;;; This Tutorial is CopyRighted by Nir sullam and anySOFT 1999.
;;; It is free to use and free for distrubution

(defun C:PROGRESS (/ loopmax dcltut_dat)


(setq dcltut_dat (load_dialog "c:\\dcltut.dcl")) ;; Put the DCL file where you want but make sure it
is found by AutoCAD!!
(new_dialog "dcltut" dcltut_dat)
;; if no maximum is set -Set the default to 100.
(if (null loopmax)(setq loopmax 100))
;; color the image tile with the background color
(setq fillx (dimx_tile "progbar"))
(setq filly (dimy_tile "progbar"))
(start_image "progbar")
(fill_image 0 0 fillx filly -15)
(end_image)
;; Set the edit_box tile to its value
(set_tile "max" (itoa loopmax))
;; Assign the loopfunc to the start button
(action_tile "start" "(loopfunc)")
(action_tile "ok" "(done_dialog)")
(action_tile "cnacel" "(done_dialog)")
(start_dialog)
(UNLOAD_DIALOG dcltut_dat)
)

;----------------------------------------------
(defun loopfunc (/ fillx filly loopfunc loopmax loop-counter)
DCL Progress Bar
http://www.afralisp.com/lispa/lisp53.htm (2 of 3) [23/03/2005 05:55:04 p.m.]
;; Get the Horizontal length of the "progbar" tile
(setq fillx (dimx_tile "progbar"))
;; Get the Vertical length of the "progbar" tile
(setq filly (dimy_tile "progbar"))
;; Start the tile
(start_image "progbar")
;; Initiate the -15 color as a background (-15 = Dialog Background color)
(fill_image 0 0 fillx filly -15)
;; end the initializing
(end_image)
;; rewind the counter to 0
(setq loop-counter 0)
;; get the value that is used as the maximum limit for the progress bar
;; in your application you may use it to show the progressing of a function that
;; processes a selction set so if your selection set length is 544 - the loopmax will have to
;; be assigned the value 544.(instead of using an edit_box tile as I did in this example.)
(setq loopmax (atoi (get_tile "max")))
;; As long as the counter is smaller than the maximum - fill the tile
(while (<= loop-counter loopmax)
(start_image "progbar")
;; The horizontal length is divided to "loopmax" times slices
;; It is the same as calculating a percent :
;; To get the 115% of 1250 you would do: (/ (* 115 1250) 100) but in this case, the 100% is
;; the MAXIMUM so we use a value other than 100.
(fill_image 0 0 (/ (* loop-counter fillx) loopmax) filly 5)
(end_image)
;; print the advance in the error tile
(set_tile "error" (rtos loop-counter))
;; increment the counter
(setq loop-counter (1+ loop-counter))
)
)

One last note: To create a vertical Progress Bar just modify the FILLY instead of the
FILLX !

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Progress Bar
http://www.afralisp.com/lispa/lisp53.htm (3 of 3) [23/03/2005 05:55:04 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
DCL without the DCL File
Have you ever wanted to load and run a DCL file without having a DCL file?
"What are you talking about Kenny?"
Easy, let's take a simple AutoLisp dialog example and tweek the coding a little bit so that our program "writes"
the DCL file for us. Copy and paste the following and save it as "TEST_DCL3.LSP".
;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL3 to run.....")
(defun C:TEST_DCL3 ( / dcl_id fn fname)
(vl-load-com)
(create_dialog)
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "temp" dcl_id))
(exit )
);if
(set_tile "name" "Enter Name Here")
(mode_tile "name" 2)
(action_tile "name" "(setq name $value)")
(action_tile "age" "(setq age $value)")
(action_tile "accept" "(val1)")
(start_dialog)
(unload_dialog dcl_id)
(alert (strcat "Your name is " name
"\nand you are " age " years of age."))
(vl-file-delete fname)
(princ)
);defun
-----------------------
(defun val1 ()
(if (= (get_tile "name") "Enter Name Here")
(progn
(set_tile "error" "You must enter a name!")
(mode_tile "name" 2)
);progn
DCL Without the DCL File
http://www.afralisp.com/lisp/dclatt.htm (1 of 3) [23/03/2005 05:55:05 p.m.]
(val2)
);if
);defun
-------------------
(defun val2 ()
(if (< (atoi (get_tile "age")) 1)
(progn
(set_tile "error" "Invalid Age - Please Try Again!!")
(mode_tile "age" 2)
);progn
(done_dialog)
);if
);defun
-------------------
(defun create_dialog ()
(setq fname (vl-filename-mktemp "dcl.dcl"))
(setq fn (open fname "w"))
(write-line "temp : dialog { label = \"Test Dialog No 3\";
: edit_box { label = \"Enter Your Name :\"; mnemonic = \"N\";
key = \"name\"; alignment = centered; edit_limit = 30;
edit_width = 30; } : edit_box { label = \"Enter Your Age :\";
mnemonic = \"A\"; key =\"age\"; alignment = centered;
edit_limit = 3; edit_width = 3; value = \"22\";
} : button { key = \"accept\"; label = \"OK\";
is_default = true; fixed_width = true; alignment = centered;
} : errtile { width = 34; } }" fn)
(close fn)
);defun
(princ)
;AUTOLISP CODING ENDS HERE

Notice that there is no DCL file this time. Now load and run it.
See, what did I tell you? We've just loaded and ran a DCL file even though we haven't got one!!!
You could now compile this into a FAS file if you wished. (Hey, a FAS file with DCL - cool!)
DCL Without the DCL File
http://www.afralisp.com/lisp/dclatt.htm (2 of 3) [23/03/2005 05:55:05 p.m.]
On the next page, we'll have a closer look at this truly amazing phenomenon and have a closer look at
the coding. At the same time, we'll get really clever and design ourselves a
"Variable-auto-self-sizing-Dialog-Box-without-a-DCL-file".
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Without the DCL File
http://www.afralisp.com/lisp/dclatt.htm (3 of 3) [23/03/2005 05:55:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Variable-auto-self-sizing-Dialog-Box-without-a-DCL-file
In this tutorial we're going to create an application that extracts attributes from a block and displays these
attributes within a dialog box. The dialog will be created "on-the-fly" and the number of attribute edit boxes will
be determined by the number of attributes.
We will be using a lot of Visual Lisp coding within this routine as I also want to demonstrate one method of
extracting and updating attributes using Visual Lisp.
No further explanation is necessary as the coding is well commented :
;;;DCLATT.LSP
;This program is for demonstration and tutorial purposes only.
--------------------------------------------
;This program, using Visual Lisp will extract attributes from
;a block and display them in a dialog box.
;The dialog box will be created "on the fly" with the relevant
;number of edit boxes ;to suit the number of attributes within
;the block.
;The new attribute data will then be retrieved from the dialog
;and the block updated.
;Written by Kenny Ramage - May 2002
;afralisp@mweb.com.na
;http://www.afralisp.com
-------------------------------------------
;Usage :
;Load by typing (load "DCLATT") at the command prompt.
;Type DCLATT at the command prompt to run.
;Select any block containing attributes.
;Replace any of the values in the text boxes to updated
;the attributes.
---------------------------------------------
;Dependencies : None that I know of.
;Not much in the way of error checking I'm afraid.
---------------------------------------------
;Limitations : Will only edit a certain number of attributes.
;System dependent.
;I don't recommend more than 10.
;I've had up to 14 on my display.
----------------------------------------------
----------------------------------------------
(prompt "\nType DCLATT to run.....")
(defun c:dclatt ( / theblock thelist n taglist
txtlist lg fname fn nu dcl_id l relist)
;load the visual lisp extensions
(vl-load-com)
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (1 of 6) [23/03/2005 05:55:08 p.m.]
;get the entity and entity name
(setq theblock (car (entsel)))
;convert to vl object
(setq theblock (vlax-ename->vla-object theblock))
;check if it's a block
(if (= (vlax-get-property theblock 'ObjectName)
"AcDbBlockReference")
;if it is, do the following
(progn
;check if it has attributes
(if (= (vlax-get-property theblock
'HasAttributes) :vlax-true)
;if it has attributes, do the following
(progn
;get the attributes
(getatt theblock)
;create the dialog
(create_dialog)
;run the dialog
(run_the_dialog)
;update the attributes
(upatt)
);progn
;No attributes, inform the user
(alert "This Block has No Attributes!!
- Please try again.")
);if
);progn
;it's not a block, inform the user
(alert "This is not a Block!! - Please try again.")
);if
(princ)
);defun
------------------------
(defun getatt (enam)
;retrieve the attributes
(setq thelist (vlax-safearray->list
(variant-value
(vla-getattributes enam))))
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (2 of 6) [23/03/2005 05:55:08 p.m.]
;process each attribute
(foreach n thelist
;get the tag attribute data
(setq taglist (cons (vla-get-tagString n) taglist)
;get the text attribute data
txtlist (cons (vla-get-textString n) txtlist)
;how many attributes?
lg (length taglist)
);setq
);foreach
;reverse the lists
(setq taglist (reverse taglist)
txtlist (reverse txtlist))
);defun
-------------------------
(defun create_dialog ()
;create a temp DCL file
(setq fname (vl-filename-mktemp "dcl.dcl"))
;open it to write
(setq fn (open fname "w"))
;write the dialog header coding
(write-line "temp : dialog { label = \"Edit Attributes\";" fn)
;reset the incremental control number
(setq nu 0)
;start the loop to create the edit boxes
(repeat lg
;create the edit boxes
(write-line ": edit_box {" fn)
(setq l (strcat "\"" "eb" (itoa nu) "\"" ";"))
(write-line (strcat "key = " l) fn)
(setq l (nth nu taglist))
(write-line (strcat "label = " "\"" l "\"" ";") fn)
(setq l (nth nu txtlist))
(write-line (strcat "value = " "\"" l "\"" ";") fn)
(write-line "alignment = centered; edit_width = 20; }" fn)
;increment the counter
(setq nu (1+ nu))
);repeat
;ok and cancel button
(write-line "ok_only; }" fn)
;close the temp DCL file
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (3 of 6) [23/03/2005 05:55:08 p.m.]
(close fn)
);defun
------------------------------
(defun run_the_dialog ()
;load the dialog file and definition
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "temp" dcl_id))
(exit )
);if
(mode_tile "eb0" 2)
;if the OK button is selected
(action_tile "accept" "(retatt)")
;start the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;delete the temp DCL file
(vl-file-delete fname)
);defun
---------------------------
(defun retatt ()
;reset the increment counter
(setq nu 0)
start the loop
(repeat lg
;retrieve the tile value
(setq l (get_tile (strcat "eb" (itoa nu))))
;add it to the list
(setq relist (cons l relist))
;increment the counter
(setq nu (1+ nu))
);repeat
(setq relist (reverse relist))
;close the dialog
(done_dialog)
);defun
-----------------------------------------
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (4 of 6) [23/03/2005 05:55:08 p.m.]
(defun upatt ()
;reset the increment counter
(setq nu 0)
;start the loop
(repeat lg
;update the attribute
(vla-put-textstring (nth nu thelist) (nth nu relist))
;increment the counter
(setq nu (1+ nu))
);repeat
;update the block
(vla-update theblock)
);defun
---------------------------
;clean loading
(princ)
---------------------------
;End of ATTDCL.LSP
---------------------------

Now you need to create 2 or three blocks containing a varying number of attributes.
Here's what mine look like :
Load and run "DCLATT.LSP" and select "Attribute No 1".
You dialog should appear looking like this with three attribute edit boxes :
Now run the program again, but this time select "Attribute No 2".
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (5 of 6) [23/03/2005 05:55:08 p.m.]
The dialog will appear, but this time with four attribute edit boxes.
Clever hey?
A big thanks to Stig Madsen for the help with the coding in this project.
Just click here if you would like the source coding and sample drawing files for this tutorial.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DCL Without the DCL File - Page II
http://www.afralisp.com/lisp/dclatt2.htm (6 of 6) [23/03/2005 05:55:08 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Entering Edit Boxes
Dialog boxes have many different kinds of visual means of showing and/or editing information. These
are called tiles. Tiles, in effect, have attributes (properties). The tile attributes define the way tiles might
react or may be shown by default. Some attributes can be defined in the driving source code (AutoLisp)
and others in the dialog source code (DCL).
Attributes can also define the size or shape of tiles. The attribute that we will discuss to allow the enter
key to act as the "OK" button is the allow_accept attribute. This particular tile attribute is always defined
in the DCL file.
The DCL Coding shown below is the typical syntax for an edit box :
: edit_box {
label = "some_label";
allow_accept = true_or_false;
width = tile_width;
edit_width = length_of_edit_box;
edit_limit = edit_limit_of_edit_box;
key = "key_name_for_driving_source_access";
mnemonic = "alt_key_for_easy_jump";
}
Everything in between the braces { } is the edit box attributes. The allow_accept attribute shown above
shows true_or_false. To set an edit box to allow the enter key to act as the "OK" button set the
allow_accept attribute to be equal to true. If the attribute does not exist it may be added to the DCL file.
Note: Omitting the allow_accept attribute in dialog control syntax will leave the tile at allow_accept =
false by default.
Here's a practical example.
TRAJ2 : dialog {
label = "Conveyor Trajectory";
: edit_box {
label = "&Velocity (m/s)";
key = "VEL";
edit_width = 5;
allow_accept = true;
}
: edit_box {
label = "&Radius of Pulley (m)";
key = "RA";
edit_width = 5;
allow_accept = true;
}
: edit_box {
label = "&Angle of Incline";
key = "INC";
edit_width = 5;
allow_accept = true;
}
: edit_box {
Entering Edit Boxes
http://www.afralisp.com/lisp/editbox.htm (1 of 3) [23/03/2005 05:55:10 p.m.]
label = "&Depth of Material (mm)";
key = "DEP";
edit_width = 5;
allow_accept = true;
}
ok_cancel ;
:text_part {
label = "Designed and Created";
}
:text_part {
label = "by Kenny Ramage";
}
}
Save this as TRAJ2.DCL. Now for the AutoLisp coding :
;CODING BEGINS HERE
(defun C:TRAJ2 ()
(setq V 1.5
R 0.3
ang 8.0
MD 75.0
);setq
(setq dcl_id (load_dialog "TRAJ2.dcl"))
(if (not (new_dialog "TRAJ2" dcl_id))
(exit)
);if
(set_tile "VEL" "1.5")
(set_tile "RA" "0.3")
(set_tile "INC" "8.0")
(set_tile "DEP" "75.0")
(mode_tile "VEL" 2)
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
(action_tile
"accept"
(strcat
"(progn (setq V (get_tile \"VEL\"))"
"(setq R (get_tile \"RA\"))"
"(setq ang (get_tile \"INC\"))"
"(setq MD (get_tile \"DEP\"))"
" (done_dialog)(setq userclick T))"
)
)
(start_dialog)
(unload_dialog dcl_id)
(if userclick
(alert (strcat "Velcocity = " V "\n"
"Radius = " R "\n"
"Angle = " ang "\n"
"Material Depth = " MD))

);if
Entering Edit Boxes
http://www.afralisp.com/lisp/editbox.htm (2 of 3) [23/03/2005 05:55:10 p.m.]

(princ)
);defun
(princ)
;CODING ENDS HERE
Save this as TRAJ2.LSP. Now load and run it. A dialog like this should appear :

Change any of the values in the edit boxes. Now, whilst still in the edit box, press your "Enter" key. The
dialog closes and the rest of the program runs.
When you press the "Enter" key, because the edit box tiles attribute "allow_accept" is set to "true", the
coding for the tile which has the attribute "is_default" (the "OK" tile) is triggered.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Entering Edit Boxes
http://www.afralisp.com/lisp/editbox.htm (3 of 3) [23/03/2005 05:55:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
Drawing Setup Tutorial
This to me, is the one area that all AutoLispers, especially AutoLisp beginners, should be
spending their time and energy.
A good, well written setup routine can saves hours of draughting time, as well as enforcing
drawing office standards.
This tutorial will take you step by step through a simple drawing setup routine which, I hope, you will be
able to build on to suit your requirements.
We will start by designing a dialogue interface to choose the type of drawing sheet the draughtsman
would like to use.
Let's look at the coding for the dialogue box :
setup1 : dialog { //dialogue name
label = "Initial Drawing Setup"; //label
: boxed_radio_column { //start radio column
label = "Choose Sheet"; //label
: radio_button { //radio button
label = "&Engineering Sheets"; //label
key = "rb1"; //key
value = "1"; //make it default
} //end radio button
: radio_button { //another radio button
label = "&Architectural Sheets"; //label
key = "rb2"; //key
} //end radio button
: radio_button { //another radio button
label = "&Civil Sheets"; //label
key = "rb3"; //key
} //end radio button
: radio_button { //another radio button
label = "&Electrical Sheets"; //label
key = "rb4"; //key
} //end radio button
: radio_button { //another radio button
label = "&Blank Sheets"; //label
key = "rb5"; //key
} //end radio button
} //end radio column
ok_cancel ; //OK/Cancel Tile
: paragraph { //begin paragraph
: text_part { //a bit of text
label = "Designed and Created"; //text
} //end text
: text_part { //another bit of text
label = "by Kenny Ramage"; //Credits
} //end text
} //end paragraph
} //end dialogue
Now, let's write some lisp to display the dialogue box :
Drawing Setup
http://www.afralisp.com/lispa/lisp8.htm (1 of 5) [23/03/2005 05:55:12 p.m.]
(defun C:SETUP1 () ;define function
(setvar "BLIPMODE" 0) ;switch off variables
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq typ "e") ;set default
(setq dcl_id (load_dialog "setup1.dcl")) ;load dialogue
(if (not ;test if loaded
(new_dialog "setup1" dcl_id) ;new dialogue
) ;end not
(exit) ;if not loaded, exit
) ;end if
(set_tile "rb1" "1") ;switch on radio button
(action_tile "rb1" ;if button selected
"(setq typ \"e\")") ;store sheet type
(action_tile "rb2" ;if button selected
"(setq typ \"a\")") ;store sheet type
(action_tile "rb3" ;if button selected
"(setq typ \"c\")") ;store sheet type
(action_tile "rb4" ;if button selected
"(setq typ \"el\")") ;store sheet type
(action_tile "rb5" ;if button selected
"(setq typ \"b\")") ;store sheet type
(action_tile "cancel" ;if Cancel selected
"(done_dialog)(setq userclick nil)") ;close dialogue, clear flag
(action_tile "accept" ;if OK selected
"(done_dialog) (setq userclick T)") ;close dialogue, set flag
(start_dialog) ;start dialogue
(unload_dialog dcl_id) ;unload dialogue
(princ) ;finish clean
) ;end function
(princ)
Your dialogue box should look like this :
We've now designed a dialogue box that enables us to choose the type of drawing sheet that we would like
to use.
But, we still need to be able to choose the size of sheet and the scale that we would like to draw with.
Let's modify our dialogue box and add these functions :
Please Note : Comments preceded by '*' are new lines.
setup2 : dialog { //dialogue name
label = "Initial Drawing Setup"; //label
: row { //*start row
: boxed_radio_column { //start radio column
label = "Choose Sheet"; //label
: radio_button { //radio button
Drawing Setup
http://www.afralisp.com/lispa/lisp8.htm (2 of 5) [23/03/2005 05:55:12 p.m.]
label = "&Engineering Sheets"; //label
key = "rb1"; //key
value = "1"; //make it default
} //end radio button
: radio_button { //another radio button
label = "&Architectural Sheets"; //label
key = "rb2"; //key
} //end radio button
: radio_button { //another radio button
label = "&Civil Sheets"; //label
key = "rb3"; //key
} //end radio button
: radio_button { //another radio button
label = "&Electrical Sheets"; //label
key = "rb4"; //key
} //end radio button
: radio_button { //another radio button
label = "&Blank Sheets"; //label
key = "rb5"; //key
} //end radio button
} //end radio column
: boxed_radio_column { //*start radio column
label = "Choose Size :"; //*label
: radio_button { //*radio button
label = "A&0 - 1189 x 841"; //*label
key = "rb6"; //*key
value = "1"; //*make it default
} //*end radio button
: radio_button { //*radio button
label = "A&1 - 841 x 594"; //*label
key = "rb7"; //*key
} //*end radio button
: radio_button { //*radio button
label = "A&2 - 594 x 420"; //*label
key = "rb8"; //*key
} //*end radio button
: radio_button { //*radio button
label = "A&3 - 420 x 297"; //*label
key = "rb9"; //*key
} //*end radio button
: radio_button { //*radio button
label = "A&4 - 297 x 210"; //*label
key = "rb10"; //*key
} //*end radio button
} //*end radio column
} //*end row
: edit_box { //*start edit box
label = "&Enter Drawing Scale :" ; //*label
key = "eb1" ; //*key
edit_width = 8 ; //*width of box
} //*end edit box
:spacer { width = 1;} //*spacer
ok_cancel ; //OK/Cancel Tile
: paragraph { //begin paragraph
: text_part { //a bit of text
label = "Designed and Created"; //text
} //end text
: text_part { //another bit of text
label = "by Kenny Ramage"; //Credits
} //end text
} //end paragraph
Drawing Setup
http://www.afralisp.com/lispa/lisp8.htm (3 of 5) [23/03/2005 05:55:12 p.m.]
} //end dialogue
And now the Autolisp Coding :
(defun C:SETUP2 () ;define function
(setvar "BLIPMODE" 0) ;switch off variables
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq typ "e") ;set default
(setq dcl_id (load_dialog "setup2.dcl")) ;load dialogue
(if (not ;test if loaded
(new_dialog "setup2" dcl_id) ;new dialogue
) ;end not
(exit) ;if not loaded, exit
) ;end if
(set_tile "rb1" "1") ;switch on radio button
(action_tile "rb1" ;if button selected
"(setq typ \"e\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb2" ;if button selected
"(setq typ \"a\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb3" ;if button selected
"(setq typ \"c\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb4" ;if button selected
"(setq typ \"el\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb5" ;if button selected
"(setq typ \"b\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(set_tile "rb6" "1") ;*make default
(set_tile "eb1" "1") ;*initial edit box value
(mode_tile "eb1" 2) ;*set focus to edit box
(action_tile "rb6" ;*if button selected
"(setq siz \"A0\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb7" ;*if button selected
"(setq siz \"A1\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb8" ;*if button selected
"(setq siz \"A2\") ;store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb9" ;*if button selected
"(setq siz \"A3\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb10" ;*if button selected
"(setq siz \"A4\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "cancel" ;if Cancel selected
"(done_dialog)(setq userclick nil)") ;close dialogue, clear flag
(action_tile "accept" ;if OK selected
(strcat ;*string 'em together
"(progn (setq #dwgsc ;*store value
(atof (get_tile \"eb1\")))" ;*get edit box value
"(done_dialog) (setq userclick T))" ;*close dialogue, set flag
) ;*end progn
) ;*end action_tile
(start_dialog) ;start dialogue
Drawing Setup
http://www.afralisp.com/lispa/lisp8.htm (4 of 5) [23/03/2005 05:55:12 p.m.]
(unload_dialog dcl_id) ;unload dialogue
(princ) ;finish clean
) ;end function
(princ)
Here's what your dialogue should look like :
We've now completed our dialogue box. On the next page we'll try and get it to do something. See you
there......
Home. Page II. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Setup
http://www.afralisp.com/lispa/lisp8.htm (5 of 5) [23/03/2005 05:55:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Home. Page III.
Drawing Setup Tutorial - Page II.
As you can see from the dialogue box, we have 5 different types of drawing sheets and 5 sizes.
Because of space constraints, I cannot post all 25 template drawings.
Therefore, I will only supply the 5 Blank drawing templates.
All of the template drawings should be named thus :
Engineering Drawings
EA0.DWG G
EA1.DWG G
EA2.DWG G
EA3.DWG G
EA4.DWG G
Architectural Drawings
AA0.DWG G
AA1.DWG G
AA2.DWG G
AA3.DWG G
AA4.DWG G
Civil
CA0.DWG G
CA1.DWG G
CA2.DWG G
CA3.DWG G
CA4.DWG G
Electrical Drawings
ELA0.DWG G
ELA1.DWG G
ELA2.DWG G
ELA3.DWG G
ELA4.DWG G
Blank Drawings
BA0.DWG G
BA1.DWG G
BA2.DWG G
BA3.DWG G
BA4.DWG G
I will leave it up to you to produce the rest of the template drawings.
For your information, here is the dimensions of the most common Metric Drawing Sheets :
A0 - 1189 mm x 841 mm
A1 - 841 mm x 594 mm
A2 - 594 mm x 420 mm
A3 - 420 mm x 297 mm
A4 - 297 mm x 210 mm
Right, let's get down to writing some more code.
Drawing Setup II
http://www.afralisp.com/lispa/lisp81.htm (1 of 4) [23/03/2005 05:55:14 p.m.]
The dialogue box we have designed will return 3 values :
TYP - Type of Sheet (eg. EL for Electrical)
SIZ - Size of Sheet (eg. A3 for A3 size sheet)
#DWGSC - Drawing Scale (eg. 25 for 1 in 25)
We can now use these values to set up our drawing sheet.
Have a look at the following coding :
(defun C:SETUP3 () ;define function
(setvar "BLIPMODE" 0) ;switch off variables
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq typ "e") ;set default
(setq dcl_id (load_dialog "setup3.dcl")) ;load dialogue
(if (not ;test if loaded
(new_dialog "setup3" dcl_id) ;new dialogue
) ;end not
(exit) ;if not loaded, exit
) ;end if
(set_tile "rb1" "1") ;switch on radio button
(action_tile "rb1" ;if button selected
"(setq typ \"e\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb2" ;if button selected
"(setq typ \"a\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb3" ;if button selected
"(setq typ \"c\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb4" ;if button selected
"(setq typ \"el\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb5" ;if button selected
"(setq typ \"b\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(set_tile "rb6" "1") ;*make default
(setq SIZ "A0") ;*Default sheet size
(set_tile "eb1" "1") ;*initial edit box value
(mode_tile "eb1" 2) ;*set focus to edit box
(action_tile "rb6" ;*if button selected
"(setq siz \"A0\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb7" ;*if button selected
"(setq siz \"A1\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb8" ;*if button selected
"(setq siz \"A2\") ;store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb9" ;*if button selected
"(setq siz \"A3\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb10" ;*if button selected
"(setq siz \"A4\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "cancel" ;if Cancel selected
"(done_dialog)(setq userclick nil)") ;close dialogue, clear flag
(action_tile "accept" ;if OK selected
(strcat ;*string 'em together
"(progn (setq #dwgsc ;*store value
(atof (get_tile \"eb1\")))" ;*get edit box value
"(done_dialog) (setq userclick T))" ;*close dialogue, set flag
) ;*end progn
) ;*end action_tile
Drawing Setup II
http://www.afralisp.com/lispa/lisp81.htm (2 of 4) [23/03/2005 05:55:14 p.m.]
(start_dialog) ;start dialogue
(unload_dialog dcl_id) ;unload dialogue
(if userclick ;*if flag is true
(progn ;*do the following
(if (eq siz "A0") ;*If size is A0
(progn ;*Do the following
(setq x 1189.0 ;*Set x limits
y 841.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A1") ;*If size is A1
(progn ;*Do the following
(setq x 841.0 ;*Set x limits
y 594.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A2") ;*If size is A2
(progn ;*Do the following
(setq x 594.0 ;*Set x limits
y 420.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A3") ;*If size is A3
(progn ;*Do the following
(setq x 420.0 ;*Set x limits
y 297.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A4") ;*If size is A4
(progn ;*Do the following
(setq x 297.0 ;*Set x limits
y 210.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(setq SIZE (strcat TYP SIZ)) ;*Construct name of Template
(if (eq typ "e") (eng)) ;*Run Engineering Setup
(if (eq typ "a") (arch)) ;*Run Architectural Setup
(if (eq typ "c") (civil)) ;*Run Civil Setup
(if (eq typ "el") (elec)) ;*Run Electrical Setup
(if (eq typ "b") (blank)) ;*Run Blank Setup

) ;*End progn
) ;*End If
(princ) ;finish clean
) ;end function
;;;----------------------------------------------------------------------------
(defun blank () ;*Define function
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
Drawing Setup II
http://www.afralisp.com/lispa/lisp81.htm (3 of 4) [23/03/2005 05:55:14 p.m.]
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(princ) ;*Clean Loading
;;;-----------------------------------------------------------------------------
First of all, we check that the O.K. button has been selected.
If the user Cancels, nothing happens and we quietly exit the routine.
If O.K. has been selected, we first check the size of sheet chosen then, set our x and y limits depending on what
size sheet was chosen.
Next, we take the type and size of sheet and string them together.
This gives us the name of the Template Drawing that we need to insert.
Clever, Hey....
Following this, we test to see what type of sheet was chosen.
Depending on the type, we run a sub-routine to set up our drawing.
I have deliberate allowed different setup routines for each type of drawing. This makes the program fully
customisable and flexible.
Please note that these setup routines are set to my standards and may not suit the way you want to setup a
drawing.
Did you notice how I stored the scale factor into USERR1?
This allows you to retrieve the scale factor for later use.
(The value in USERR1 is saved with the drawing.)
On the next page I will list the complete coding for all Sheet Types.
Page I. Home. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Setup II
http://www.afralisp.com/lispa/lisp81.htm (4 of 4) [23/03/2005 05:55:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Page I. Page II. Home.
Drawing Setup Tutorial - Page III.
Here is the complete AutoLisp Coding :
(defun C:SETUP () ;define function
(setvar "BLIPMODE" 0) ;switch off variables
(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)
(setq typ "e") ;set default
(setq dcl_id (load_dialog "setup.dcl")) ;load dialogue
(if (not ;test if loaded
(new_dialog "setup" dcl_id) ;new dialogue
) ;end not
(exit) ;if not loaded, exit
) ;end if
(set_tile "rb1" "1") ;switch on radio button
(action_tile "rb1" ;if button selected
"(setq typ \"e\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb2" ;if button selected
"(setq typ \"a\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb3" ;if button selected
"(setq typ \"c\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb4" ;if button selected
"(setq typ \"el\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb5" ;if button selected
"(setq typ \"b\") ;store sheet type
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(set_tile "rb6" "1") ;*make default
(setq SIZ "A0") ;*Default sheet size
(set_tile "eb1" "1") ;*initial edit box value
(mode_tile "eb1" 2) ;*set focus to edit box
(action_tile "rb6" ;*if button selected
"(setq siz \"A0\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb7" ;*if button selected
"(setq siz \"A1\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb8" ;*if button selected
"(setq siz \"A2\") ;store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb9" ;*if button selected
"(setq siz \"A3\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "rb10" ;*if button selected
"(setq siz \"A4\") ;*store sheet size
(mode_tile \"eb1\" 2)") ;*set focus to edit box
(action_tile "cancel" ;if Cancel selected
"(done_dialog)(setq userclick nil)") ;close dialogue, clear flag
Drawing Setup III
http://www.afralisp.com/lispa/lisp82.htm (1 of 5) [23/03/2005 05:55:15 p.m.]
(action_tile "accept" ;if OK selected
(strcat ;*string 'em together
"(progn (setq #dwgsc ;*store value
(atof (get_tile \"eb1\")))" ;*get edit box value
"(done_dialog) (setq userclick T))" ;*close dialogue, set flag
) ;*end progn
) ;*end action_tile
(start_dialog) ;start dialogue
(unload_dialog dcl_id) ;unload dialogue
(if userclick ;*if flag is true
(progn ;*do the following
(if (eq siz "A0") ;*If size is A0
(progn ;*Do the following
(setq x 1189.0 ;*Set x limits
y 841.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A1") ;*If size is A1
(progn ;*Do the following
(setq x 841.0 ;*Set x limits
y 594.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A2") ;*If size is A2
(progn ;*Do the following
(setq x 594.0 ;*Set x limits
y 420.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A3") ;*If size is A3
(progn ;*Do the following
(setq x 420.0 ;*Set x limits
y 297.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(if (eq siz "A4") ;*If size is A4
(progn ;*Do the following
(setq x 297.0 ;*Set x limits
y 210.0 ;*Set y limits
) ;*End setq
) ;*End progn
) ;*End If
(setq SIZE (strcat TYP SIZ)) ;*Construct name of Template
(if (eq typ "e") (eng)) ;*Run Engineering Setup
(if (eq typ "a") (arch)) ;*Run Architectural Setup
(if (eq typ "c") (civil)) ;*Run Civil Setup
(if (eq typ "el") (elec)) ;*Run Electrical Setup
(if (eq typ "b") (blank)) ;*Run Blank Setup

) ;*End progn
) ;*End If
(princ) ;finish clean
) ;end function
;;;----------------------------------------------------------------------------
(defun blank () ;*Define function
Drawing Setup III
http://www.afralisp.com/lispa/lisp82.htm (2 of 5) [23/03/2005 05:55:15 p.m.]
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(defun eng () ;*Define function
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(defun arch () ;*Define function
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
Drawing Setup III
http://www.afralisp.com/lispa/lisp82.htm (3 of 5) [23/03/2005 05:55:15 p.m.]
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(defun civil () ;*Define function
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(defun elec () ;*Define function
(setvar "DIMSCALE" #DWGSC) ;*Set Dimscale
(setvar "USERR1" #DWGSC) ;*Store Scale for future
(setvar "LTSCALE" (* #DWGSC 10)) ;*Set Ltscale
(setvar "REGENMODE" 1) ;*Regen ON
(setvar "TILEMODE" 1) ;*Tilemode ON
(setq n (* 3.5 #DWGSC)) ;*Store Text Height
(setq L (list (* X #DWGSC) (* Y #DWGSC)) ;*Calculate Limits
)
(command "LIMITS" "0,0" L
"ZOOM" "W" "0,0" L
"STYLE" "italict"
"italict" N "" "" "" "" ""
"INSERT" SIZE "0,0" #DWGSC "" ""
) ;*Set Up Drawing
(prompt "\n ") ;*Blank Line
(prompt "\nO.K Setup Routine Complete") ;*Inform User
(princ) ;*Exit Quietly
) ;*End Function
;;;----------------------------------------------------------------------------
(princ) ;*Clean Loading
;;;-----------------------------------------------------------------------------
To download source coding and template files Click Here.
Please remember that you will need to create some of the template files yourself.
Drawing Setup III
http://www.afralisp.com/lispa/lisp82.htm (4 of 5) [23/03/2005 05:55:15 p.m.]
Page I. Page II. Home.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Drawing Setup III
http://www.afralisp.com/lispa/lisp82.htm (5 of 5) [23/03/2005 05:55:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Date and Time Stamping.
When you plot a drawing (or insert an Xref, etc), it's nice to have the Date and Time of the
plot stamped on the plotted drawing. This is easily done manually, but wouldn't it be nice
to use AutoLisp and have the Time and Date automatically added to your plots? Here's
how you would go about it.
First, we need to write a few functions that will calculate the Date and Time and then format them
into readable text. Try out the following functions :
(defun TODAY ( / d yr mo day)
;define the function and declare all variabled local
(setq d (rtos (getvar "CDATE") 2 6)
;get the date and time and convert to text
yr (substr d 3 2)
;extract the year
mo (substr d 5 2)
;extract the month
day (substr d 7 2)
;extract the day
);setq
(strcat day "/" mo "/" yr)
;string 'em together
(princ)
);defun
;;;*-------------------------------------------
(defun TIME ( / d hr m s)
;define the function and declare all variables as local
(setq d (rtos (getvar "CDATE") 2 6)
;get the date and time and convert to text
hr (substr d 10 2)
;extract the hour
m (substr d 12 2)
;extract the minute
s (substr d 14 2)
;extract the second
);setq
Date and Time Stamping
http://www.afralisp.com/lispa/lisp40a.htm (1 of 5) [23/03/2005 05:55:17 p.m.]
(strcat hr ":" m ":" s)
;string 'em together
(princ)
);defun
;;;*-------------------------------------------
Try the two functions out. Load the functions and type:
(today)
Lisp should return today's date :
"23/03/99"
Now try the next function. Type :
(time)
AutoLisp should return something like :
"11:36:21"
O.K. great, we've got the date and time but now we need to add it to our drawing. The simplest way
of doing this is by making use of attributes.
First we need to create a block containing 3 attributes, namely Date, Time and Who By. (If you
don't know how to create a block with attributes, please refer to the AutoCad Reference Manual.)
Once you have created your attribute block, it is very easy to write an AutoLisp routine that inserts
the block and automatically calculates and fills in the attribute data. The following example does
just that.
(defun C:TIMESTAMP (/ ss1 count emax en ed blkn found
thedate thetime plotby)
;define function and declare variables as local
(setvar "HIGHLIGHT" 0)
;switch off highlight
(setvar "CMDECHO" 0)
;switch off command echo
(setq ss1 (ssget "X" '((0 . "INSERT")(66 . 1))))
;filter for all blocks with attributes
(if ss1
;if any are found
(progn
;do the following
(setq count 0
;set the counter to zero
emax (sslength ss1)
;get the number of blocks
);setq
(while (< count emax)
;while the counter is less than the
;number of blocks
Date and Time Stamping
http://www.afralisp.com/lispa/lisp40a.htm (2 of 5) [23/03/2005 05:55:17 p.m.]
(setq en (ssname ss1 count)
;get the entity name
ed (entget en)
;get the entity list
blkn (dxf 2 ed)
;get the block name
);setq
(if (= "STAMP")
;if the block name is "STAMP"
(setq count emax
;stop the loop
found T
;set the flag
);setq
(setq count (1+ count))
;if not increment the counter
);end if
);while & if
(if found
;if the flag is set
(command "ERASE" en "")
;erase the block
);if
);progn
);if
(setvar "ATTDIA" 0)
;switch off dialogue boxes
(setq thedate (today))
;calculate and format date
(setq thetime (time))
;calculate and format time
(setq plotby (getvar "LOGINNAME"))
;get the users name

(command "Insert" "Stamp" "0,0" "" "" ""
thedate thetime plotby)
;insert the block and fill in the attribute data
(setvar "ATTDIA" 1)
Date and Time Stamping
http://www.afralisp.com/lispa/lisp40a.htm (3 of 5) [23/03/2005 05:55:17 p.m.]
;switch the dialogues back on
(setvar "HIGHLIGHT" 1)
;switch Highlight On
(setvar "CMDECHO" 1)
;switch Cmdecho On
(princ)
);defun
;===============================================================
(defun dxf(code elist)
(cdr (assoc code elist))
;finds the association pair, strips 1st element
);defun
;===============================================================
(defun TODAY ( / d yr mo day)
(setq d (rtos (getvar "CDATE") 2 6)
yr (substr d 3 2)
mo (substr d 5 2)
day (substr d 7 2)
);setq
(strcat day "/" mo "/" yr)
);defun
;;;*-----------------------------------------------------------
(defun TIME ( / d hr m s)
(setq d (rtos (getvar "CDATE") 2 6)
hr (substr d 10 2)
m (substr d 12 2)
s (substr d 14 2)
);setq
(strcat hr ":" m ":" s)
);defun
;;;*------------------------------------------------------------
(princ)
This routine basically does the following :
First of all, it checks if there are any blocks in the drawing that contain attributes. If there are, it
loops through each block checking if it has the name "STAMP". If it has, it deletes the block. The
routine then inserts a new "STAMP" block with the updated attribute data.
After running this routine, you should have a block similar to this in the lower
left hand corner of your drawing.
You can now plot your drawing with the new or updated Date and Time stamp.
You should find it relatively easy to modify this routine to suit any kind of Date/Time stamp that
you would wish to add to a drawing. You could add a stamp that places the name and path of all
Date and Time Stamping
http://www.afralisp.com/lispa/lisp40a.htm (4 of 5) [23/03/2005 05:55:17 p.m.]
Xrefs attached to the drawing, along with, the date they where added and who added them.
If you would like the source coding for the the Timestamp routine, just place your mouse here, say
a prayer, and click....Enjoy.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Date and Time Stamping
http://www.afralisp.com/lispa/lisp40a.htm (5 of 5) [23/03/2005 05:55:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Macro Recorder.
Another useful aspect to programs such as AutoLISP is their ability to perform
repetitive tasks. For example, suppose you want to be able to record a series of keyboard entries as
a macro. One way to do this would be to use a series of Getstring functions as in the following:
(Setq str1 (getstring "\nEnter macro: "))

(Setq str2 (getstring "\nEnter macro: "))

(Setq str3 (getstring "\nEnter macro: "))

(Setq str4 (getstring "\nEnter macro: "))
Each of the str variables would then be combined to form a variable storing the keystrokes.
Unfortunately, this method is inflexible. It requires that the user input a fixed number of entries, no
more and no less. Also, this method would use memory storing each keyboard entry as a single
variable.
It would be better if you had some facility to continually read keyboard input regardless of how few
or how many different keyboard entries are supplied. The While function can be used to repeat a
prompt and obtain data from the user until some test condition is met.
Here is the coding for our Macro Recorder:
(defun C:MACRO (/ str1 macro macname)
(setq macro '(command))
;start list with command
(setq macname (getstring "\nEnter name of macro: "))
;get name of macro
(while (/= str1 "/")
;do while str1 not equal to /
(setq str1 (getstring "\nEnter macro or / to exit: " ))
;get keystrokes
(if (= str1 "/")
(princ "\nEnd of macro ")
;if / then print message
(Setq macro (append macro (list str1)))
;else append keystrokes to list
)
;end if macro list
);end while
(eval (list 'defun (read macname) '() macro))
;create function
Macro Recorder.
http://www.afralisp.com/lispa/lisp45.htm (1 of 4) [23/03/2005 05:55:19 p.m.]
(princ)
);end macro
(princ)
Now we will use the macro program to create a keyboard macro that changes
the last object drawn to layer 3. Do the following:
1. Draw a diagonal line from the lower left corner of the drawing area
to the upper right corner.
2. Load the Macro.lsp file
3. Enter Macro at the command prompt.
4. At the following prompt:
Enter name of macro:
5. Enter the word 'CHLA'.
6. At the prompt:
Enter macro or / to exit:

Enter the word
CHANGE
The Enter macro prompt appears again. Enter the following series of
words at each Enter macro prompt:
Enter macro or / to exit: L

Enter macro or / to exit: press return

Enter macro or / to exit: P

Enter macro or / to exit: LA

Enter macro or / to exit: 3

Enter macro or / to exit: press return
Enter macro or / to exit: press return

Enter macro or / to exit: /
This is where the 'while' function takes action. As you enter each response to the Enter macro
prompt, 'while' tests to see if you entered a forward slash.
If not, it evaluates the expressions included as its arguments. Once you enter the backslash, 'while'
stops its repetition. You get the prompt:
End of macro
The input you gave to the Enter macro prompt is exactly what you would enter
if you had used the change command normally. Now run your macro by entering:
(chla)
Macro Recorder.
http://www.afralisp.com/lispa/lisp45.htm (2 of 4) [23/03/2005 05:55:19 p.m.]
The line you drew should change to layer 3.
When Macro starts, it first defines two variables def and macro.
(setq def "defun ")

(setq macro '(command))
Def is a string variable that is used later to define the macro. Macro is the beginning of a list
variable which is used to store the keystrokes of the macro. The next line prompts the user to enter
a name for the macro.
(setq macname (getstring "\nEnter name of macro: "))
The entered name is then stored with the variable macname.
Finally, we come to the 'while' function.
(while (/= str1 "/")
The 'while' expression is broken into several lines. The first line contains the actual while function
along with the test expression.
In this case, the test compares the variable str1 with the string "/" to see if they are not equal. So
long as str1 is not equal to "/", 'while' will execute the arguments that follow the test. The next four
lines are the expressions to be evaluated. The first of these lines prompts the user to enter the text
that compose the macro.
(setq str1 (getstring "\nEnter macro or / to exit: " ))
When the user enters a value at this prompt, it is assigned to the variable str1.
The next line uses an if function to test if str1 is equal to "/".
(if (= str1 "/")
If the test results in T, the next line prints the string :
End of macro
(princ "\nEnd of macro ")
This expression prints the prompt End of macro to the prompt line.
If the test results in nil, the following line appends the value of str1 to the existing list macro.
(Setq macro (append macro (list str1)))
The 'append' function takes one list and appends its contents to the end of another list. In this case,
whatever is entered at the Enter macro prompt is appended to the variable macro. Each time a new
value is entered at the Enter macro prompt, it is appended to the variable macro creating a list of
keyboard entries to be saved.
The next two lines close the if and while expressions.
);end if

);end while
The last line combines all the elements of the program into an expression that,
when evaluated, creates a new macro program.
(eval (list (read def) (read macname) '() macro))
The read function used in this expression is a special function that converts a string value into a
symbol. If a string argument to read contains spaces, read will convert the first part of the string
and ignore everything after the space.

Macro Recorder.
http://www.afralisp.com/lispa/lisp45.htm (3 of 4) [23/03/2005 05:55:19 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Macro Recorder.
http://www.afralisp.com/lispa/lisp45.htm (4 of 4) [23/03/2005 05:55:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Auto-Breaking Blocks
I've had a lot of request to write a tutorial on creating Auto-Breaking blocks.
These are very handy little objects and can save a draughtsman a lot of time and effort. The only
drawback to them is that they initially take a bit of time to prepare. Let's have a look at what we need
to do to go about creating Auto-Breaking
blocks.
Firstly, we need to find some way of "storing" the break point data within the block.
For this tutorial we are going to use attributes. Fire up AutoCAD and draw a valve similar to the one shown
here.
Now type in "DDATTDEF" at the command prompt. The Attribute definition dialogue box will appear.
In the mode section, switch on the "Invisible" toggle, name the Attribute Tag "BP1" and select Break Point 1 as
the insertion point. Then select O.K.
Repeat the process for Break Point 2 and your valve is ready to be saved as a Wblock. Your valve should look
something like this :
Auto-Breaking Blocks.
http://www.afralisp.com/lispa/lisp52.htm (1 of 4) [23/03/2005 05:55:21 p.m.]
Now WBlock the valve to your hardrive.
O.K. Now we've stored the Break Point values as attributes within our block.
Now comes the difficult part!! How do we retrieve this information? Easy....
First, open a new drawing and insert the Valve drawing. Just select "O.K." when the attribute dialog appears.
Now type this at the command line:
(setq edata (entget (setq en (entlast))))
Lisp should return something like this :
((-1 . ) (0 . "INSERT") (5 . "7AE") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "VALVE") (10
508.26 476.045 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 .0)
(44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))
O.K. we've got the entity data list, but now we need the attribute data. Type this:
(setq edata (entget (entnext (cdr (assoc -1 edata)))))
You should get something like this:
((-1 . ) (0 . "ATTRIB") (5 . "7AF") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbText") (10 518.26 476.045 0.0) (40 . 3.5) (1 ."")
(50 . 0.0) (41 . 1.0) (51 . 0.0872665) (7 . "ITALICT") (71 . 0) (72 . 0)
(11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "IP2") (70 . 1)
(73 . 0) (74 . 0))
Voila, the attribute data list. Now, I just happen to know that the DXF group code for the attribute insertion
point is Code 10. So let's extract it :
(setq ip1 (cdr (assoc 10 edata)))
Lisp should return the attribute insertion point and it should look something like this:
(518.26 476.045 0.0)
We would now simply repeat the process for the second break point.
Well that, is basically the heart of the program. We've inserted our block and we've established our break
points. All we need to do now is break our line.
Here's the full AutoLISP coding for our Auto-Breaking Block:
(defun c:abreak ( / oldsnap bname ip ent1 ent2 ep1 ep2 ang edata ip1 ip2)
(setq oldsnap (getvar "OSMODE"))
;get the current snap
(setvar "OSMODE" 544)
;set snap to intersection and nearest
(setvar "BLIPMODE" 0)
;switch blips off
(setvar "CMDECHO" 0)
;switch command echo off
(setq bname (getfiled "Select Auto-Breaking Block" "" "dwg" 8))
;get the block to insert
Auto-Breaking Blocks.
http://www.afralisp.com/lispa/lisp52.htm (2 of 4) [23/03/2005 05:55:21 p.m.]
(while
;while an insertion point is selected
(setq ip (getpoint "\nInsertion Point: "))
;get the insertion point
(setq ent1 (entsel "\nSelect Line to AutoBreak: "))
;get the line to break
(setvar "OSMODE" 0)
;switch the snap off
(setq ent2 (entget (car ent1)))
;get the entity data of the line
(setq ep1 (cdr (assoc 10 ent2)))
;get the first end point
(setq ep2 (cdr (assoc 11 ent2)))
;get the second end point
(setq ang (angle ep1 ep2))
;get the angle of the line
(setq ang (/ (* ang 180.0) pi))
;convert it to degrees
(setvar "ATTDIA" 0)
;switch off the attribute dialog box
(command "Insert" bname ip "" "" ang "" "")
;insert the block
(setq edata (entget (setq en (entlast))))
;get the block entity data
(setq edata (entget (entnext (dxf -1 edata))))
;get the attribute entity list
(setq ip1 (dxf 10 edata))
;extract the first attribute insertion point
(setq edata (entget (entnext (dxf -1 edata))))
;get the next attribute entity list
(setq ip2 (dxf 10 edata))
;extract the second attribute insertion point
(command "Break" ent1 "f" ip1 ip2)
;break the line
(setvar "OSMODE" 544)
;switch snap back on
);while
(setvar "OSMODE" oldsnap)
;reset snap
(setvar "BLIPMODE" 1)
;switch blips back on
(setvar "CMDECHO" 1)
;switch command echo back on
Auto-Breaking Blocks.
http://www.afralisp.com/lispa/lisp52.htm (3 of 4) [23/03/2005 05:55:21 p.m.]
(setvar "ATTDIA" 1)
;switch attribute dialog boc back on
(princ)
;finish clean
);defun
;;;**********************************************************

(defun dxf (code elist)
(cdr (assoc code elist))
);defun
(princ)

I have created a special folder called "Autobreak" were I store all my Auto-Breaking blocks. I also include this
folder as my default directory in the 'getfiled' function.
If you would like the source coding for this application plus the sample Valve drawing, then just click here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Auto-Breaking Blocks.
http://www.afralisp.com/lispa/lisp52.htm (4 of 4) [23/03/2005 05:55:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
List Variables/Functions.
It is very important when writing AutoLISP routines to declare all your Local Variables.
This prevents your variables stepping on other variables of the same name defined from
other routines.
It often happens though, that on completion of your application, it can be quite difficult to
remember and locate all the variables that you have used. This application will list all the
un-declared variables and all functions used within your routine.
If you need help with Functions and Local/Global Variables, then refer to
the DEFUN Function Tutorial.
Usage
I have included two sample AutoLISP files with this application, to demonstrate
how to run and use 'ListVar.Lsp.
First of all, ensure that ListVar.Lsp and ListVar.Dcl are in your AutoCAD
support path.
Now type (load "ListVar") at the command prompt.
A message will appear prompting you to type INIT to run the application.
Do just that. A dialogue box will appear that looks like this :
Read the instructions carefully.
Now load and run Sample.Lsp. The AutoLisp coding is as follows :
(defun c:sample ()
(setq l1 10.0
l2 20.0
l3 30.0
l4 40.0
l5 50.0
l6 (fDTR 45)
g1 "Global1"
List Variables/Functions
http://www.afralisp.com/lispa/lisp57.htm (1 of 4) [23/03/2005 05:55:24 p.m.]
g2 "Global2"
);setq

(princ)
);defun
(defun fDTR (x)
(* PI (/ x 180.0))
);defun
(princ)
This is a very simple routine that basically defines 8 variables, 6 of which we want to declare Local
and 2 of which we would like to declare as Global. We have also defined a sub-function that
converts degrees to radians.
After running this routine type 'ListVar' at the command line.
Another dialogue will appear that looks like this :
As you can see, all the functions and variables used within the routine are listed in the list box.
To keep a permanent record of the list, select the 'Print to File' button.
This will print the list to the file 'ListVar.Txt :
C:SAMPLE
FDTR
G1
G2
L1
L2
L3
L4
L5
L6

You can use this file to cut and paste the variables that you want to declare as Local into your
AutoLisp file.
Now, re-run 'INIT' then load and run Sample1.Lsp.
List Variables/Functions
http://www.afralisp.com/lispa/lisp57.htm (2 of 4) [23/03/2005 05:55:24 p.m.]
Here is the coding for Sample1.Lsp.
(defun c:sample1 ( / L1 L2 L3 L4 L5 L6)
(setq l1 10.0
l2 20.0
l3 30.0
l4 40.0
l5 50.0
l6 (fDTR 45)
g1 "Global1"
g2 "Global2"
);setq

(princ)
);defun
(defun fDTR (x)
(* PI (/ x 180.0))
);defun
(princ)

As you can see, we have declared all the Local Variables.


Now run 'ListVar' again. The dialogue should now look like this.
Do you see that the Local Variables that we declared are now not listed.
Using this application you can produce a list of all local variables that need to be declared when you
have written a new AutoLisp routine or, you can check your existing routines for variables that you
may have missed.
To download this application including the sample AutoLisp files, then just Click Here. (30 Kb)

List Variables/Functions
http://www.afralisp.com/lispa/lisp57.htm (3 of 4) [23/03/2005 05:55:24 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
List Variables/Functions
http://www.afralisp.com/lispa/lisp57.htm (4 of 4) [23/03/2005 05:55:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Lisp Help.
When writing any sort of AutoLisp routine, one should supply some kind of Help. An
Information box is also a handy thing to include as it allows you to inform the user of
what version of the routine he is using, as well as giving you a chance to advertise
yourself and your applications.
You can access and integrate custom Help into the Windows Help Files, but this is quite
an involved process and you need the brains of a rocket scientist to accomplish this.
A much simpler way is to call an external Help or Info file from your AutoLisp routine. Using the
following routine, if you click on the Help button, your default browser will open, displaying an
HTML Help file.
Clicking on the Info button, will open Notepad and display an Info Text file.
Note: Please ensure that all files are in your AutoCad search path.
Here's the DCL Coding :
lisphelp : dialog {
label = "Lisp Help Tutorial" ;
ok_cancel_help_info ;
}
And now the AutoLisp Coding :
;;; ----------------------------------------------------------------
(prompt "\n Type LISPHELP to run....")
;;; ----------------------------------------------------------------
(defun C:LISPHELP (/ USERFLAG1 USERFLAG2 USERFLAG3 HE INF DCL_ID)
(setq DCL_ID (load_dialog "lisphelp.dcl")
) ;_ end of setq
(if (not (new_dialog "lisphelp" DCL_ID)
) ;_ end of not
(exit)
) ;_ end of if
HTML Help
http://www.afralisp.com/lispa/lisp58.htm (1 of 4) [23/03/2005 05:55:25 p.m.]
(action_tile
"accept"
"(done_dialog) (setq userflag T)"
) ;_ end of action_tile
(action_tile
"cancel"
"(done_dialog) (setq userflag nil)"
) ;_ end of action_tile
(action_tile
"help"
"(done_dialog) (setq userflag1 T)"
) ;_ end of action_tile
(action_tile
"info"
"(done_dialog) (setq userflag2 T)"
) ;_ end of action_tile
(start_dialog)
(unload_dialog DCL_ID)
(if USERFLAG
(alert "You selected O.K.")
) ;_ end of if
(if USERFLAG1
(HEL)
) ;_ end of if
(IF USERFLAG2
(IN)
) ;_ end of IF
(princ)
) ;_ end of defun
;;; ----------------------------------------------------------------
HTML Help
http://www.afralisp.com/lispa/lisp58.htm (2 of 4) [23/03/2005 05:55:25 p.m.]
(defun hel ()
(if (not
(setq HE (findfile "Help.htm")
) ;_ end of setq
) ;_ end of not
(alert "Sorry - Help File Missing")
(command "Browser" HE)
) ;_ end of if
(princ)
) ;_ end of defun
(defun in ()
(if (not
(setq INF (findfile "Info.txt")
) ;_ end of setq
) ;_ end of not
(alert "Sorry - Info File Missing")
(startapp "notepad.exe" INF)
) ;_ end of if
(princ)
) ;_ end of defun
(princ)
;;;EOF
;;; ----------------------------------------------------------------
To download this Tutorial just Click Here. (16 Kb)

HTML Help
http://www.afralisp.com/lispa/lisp58.htm (3 of 4) [23/03/2005 05:55:25 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
HTML Help
http://www.afralisp.com/lispa/lisp58.htm (4 of 4) [23/03/2005 05:55:25 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DOSLib - DOS Library Programmers Reference
I don't know if you are aware, but there is an application included with AutoCAD that
makes dealing with the operating system a breeze when working with AutoLisp. This is
DOSLib.Arx, designed and distributed by Robert Mcneel and Associates.
DOSLib, or DOS Library, is a library of LISP-callable functions that provide Windows operating
system and DOS command-line functionality to various CAD applications, including AutoCAD and
IntelliCAD.
DOSLib extends their LISP programming languages by providing the following
functionality:

Drive handling functions to change between drives and check disk space. G
Path handling functions to manipulate path specifications. G
Directory handling functions to create, rename, remove, select and change directories. G
File handling functions to copy, delete, move, rename, and select files. Functions for getting
directory listings, searching and finding multiple instances of files, and changing attributes
are provided.
G
Print handling function to get and set default printers, and spool files. G
Initialization file handling functions to manipulate Windows-style initialization (INI) files,
and Windows Registry access functions.
G
Process handling functions to run internal DOS commands or other programs. G
Miscellaneous functions, like changing the system date and time, and displaying Windows
message boxes.
G
In this Tutorial we will have a quick look at how to use some of the various functions available
within DOSLib.
Creating a "Splash Screen"
This is a great way to promote yourself or your company.
DOSLib Function : dos_splash
Syntax : (dos_splash filename duration)
Arguments :
filename - A 256-colour Windows BMP File. G
duration - Duration Time in Seconds. G
DosLib
http://www.afralisp.com/lispa/lisp59.htm (1 of 5) [23/03/2005 05:55:28 p.m.]
Returns : nil if successful or on error.
Example :
(dos_splash "afralisp.bmp" 5)
Getting a Directory Path
This will display a Windows Browse for Folder Dialogue box and will return
a fully qualified path to the selected directory.
DOSLib Function : dos_getdir
Syntax : (dos_getdir title [path])
Arguments :
title - A dialogue box title. G
Options :
path - An existing directory. G
Returns : A qualified path to the current directory selected by the user. nil on cancel or error.
Example :
(setq udir (dos_getdir "Select a Directory" "c:\\"))
Multiple File Selection
DosLib
http://www.afralisp.com/lispa/lisp59.htm (2 of 5) [23/03/2005 05:55:28 p.m.]
Displays a Windows common file open dialogue box that will allow you to select
multiple files.
DOSLib Function : dos_getfilem
Syntax : (dos_getfilem title path filter)
Arguments :
title - A dialogue box title. G
path - An existing directory. G
filter - A filename filter string. The filter string consists of two components: a description (for
example, "Text File"), and a filter pattern (for example, "*.txt"). Multiple filter patterns can
be specified for a single item by separating the filter-pattern strings with a semi-colon (for
example, "*.TXT;*.DOC;*.BAK"). The components must be separated by a pipe character
("|"). The filename filter string can consist of one or more filter strings, each separated by a
pipe character.
G
Returns : A list of filenames. The first element of the list is a qualified path to
the selected directory. nil on cancel or error
Example :
(setq ufiles (dos_getfilem "Select Drawings" "c:\\drawings\\"
"Drawing Files (*.DWG)|*.DWG"))
AutoCAD Message Box
This displays a Windows Message Box. Much more flexible than the standard
AutLisp "Alert" function. Very similar to the VBA Message Box function.
DOSLib Function : dos_msgbox
Syntax : (dos_getfilem text title button icon)
Arguments :
text - The message to be displayed. G
DosLib
http://www.afralisp.com/lispa/lisp59.htm (3 of 5) [23/03/2005 05:55:28 p.m.]
title - The message box title. G
button - The push button format.
The allowable values are :
0 - Abort, Retry and Ignore. H
1 - OK. H
2 - OK and Cancel. H
3 - Retry and Cancel. H
4 - Yes and No. H
5 - Yes, No and Cancel. H
G
icon - The icon.
The allowable values are :
0 - Asterisk. H
1 - Exclamation. H
2 - Hand. H
3 - Information. H
4 - Question. H
5 - Stop. H
G
Returns : The return values of dos_msgbox are as follows :
0 - Abort G
1 - Cancel G
2 - Ignore G
3 - No G
4 - OK G
5 - Retry G
6 - Yes G
nil on error.
Example
(dos_msgbox "Continue Batch Process?" "Batch Purge" 5 4)
These are just a couple of examples of some of the functions available within DOSLib. There are 72
callable functions covering all areas of DOS usage. On the next page we'll have a look at an
AutoLisp application designed using the DOSLib. See you there......
Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
DosLib
http://www.afralisp.com/lispa/lisp59.htm (4 of 5) [23/03/2005 05:55:28 p.m.]
Search
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DosLib
http://www.afralisp.com/lispa/lisp59.htm (5 of 5) [23/03/2005 05:55:28 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DOSLib - Batch Slide Application
In this application we are going to use some of the DOSLib functions to Convert a
selection of drawings to slides. I've explained the program within the coding by including
comments for each line. Good luck and here we go...
(defun c:batchslide ( / CNTR DPATH DWGPATH FILE1 FLAG FLEN FNAME
FNAME1 LEN1 MESSAGE NFILES NFILES1 SCRFILE
UFILES)
;;;Firstly we need to check if DOSLib is loaded.
(cond
((= (atoi (substr (getvar "acadver") 1 2)) 13)
(if (not (member "doslib13.arx" (arx)))
(arxload (findfile "doslib13.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 14)
(if (not (member "doslib14.arx" (arx)))
(arxload (findfile "doslib14.arx"))))
((= (atoi (substr (getvar "acadver") 1 2)) 15)
(if (not (member "doslib2k.arx" (arx)))
(arxload (findfile "doslib2k.arx"))))
);cond
;;;This, first checks the version of AutoCAD in use.
;;;It then checks to see if that version of Doslib is loaded.
;;;If it is not, it searches the AutoCAD search path for the
;;;relevant version, and then loads it.
;;;We must now check that, if we are using A2K, Single Document
;;;Mode is switched OFF.
(if (= (atoi (substr (getvar "acadver") 1 2)) 15)
;if A2K
(setvar "sdi" 0)
;switch off single document interface
);if
;;;Now we are going to do a bit of advertising and display a
;;; Splash Screen for about 5 seconds.
(dos_splash "afralisp.bmp" 5)
;display the splash screen
;;;Now, we need to retrieve the names of the files that we would
;;;like to make slides from.
(setq dwgpath (getvar "dwgprefix"))
;get the path to the current directory
(setq ufiles (dos_getfilem "Select Drawings"
dwgpath "Drawing Files (*.DWG)|*.DWG"))
DosLib II
http://www.afralisp.com/lispa/lisp59a.htm (1 of 4) [23/03/2005 05:55:29 p.m.]
;display the file dialogue box
(if (not ufiles)
;if no files selected or Cancel

(exit)
;exit the application
);
;;;The first item in the list "ufiles" is the directory path
;;;The remaining items are the file names.
;;;First, let's retrieve the directory path.
(setq dpath (nth 0 ufiles))
;retrieve the directory path - the first item.
;;;Next, let's get the number of items in the list,
;;;and make sure that the user wants to continue.
(setq nfiles (length ufiles))
;get the length of the list
(setq nfiles1 (itoa (- nfiles 1)))
;count only the file names and convert to a string
(setq message (strcat "You have choosen " nfiles1 " files.
\nDo you want to continue?"))
;set up the message
(setq flag (dos_msgbox message "AfraLisp Batch Slides" 4 4))
;display the message box
(if (= flag 6)
;if Yes selected
(progn
;do the following
;;;We'll now open an external file to write our script to.
(setq scrfile (strcat dpath "batdir.scr"))
;add the path to the script file name
(setq file1 (open scrfile "w"))
;open the file to write
(setq cntr 1)
;set the counter
;;;We'll now start the loop, format the file names, and add
;;;the commands to the script file.
(repeat (- nfiles 1)
;start the loop
(setq fname (nth cntr ufiles))
;get the file name
DosLib II
http://www.afralisp.com/lispa/lisp59a.htm (2 of 4) [23/03/2005 05:55:29 p.m.]
(setq fname (strcat dpath fname))
;add the path to the file name.
;"fname" will be used to open each
;drawing.
(setq flen (strlen fname))
;get the length of file name
(setq len1 (- flen 4))
;take away the last 4 characters (.DWG)
(setq fname1 (substr fname 1 len1))
;get just the filename without the extension.
;"fname1" will be used as our slide file name.
;;;write the commands to the script file
(write-line (strcat "open " fname) file1)
;open the drawing
;write it to the script file
(write-line (strcat ".zoom" " e") file1)
;zoom to extents
;write it to the script file
(write-line (strcat "filedia" " 0") file1)
;switch off dialogues
;write it to the script file
(write-line (strcat "mslide " fname1) file1)
;make the slide
;write it to the script file
(write-line (strcat "filedia" " 1") file1)
;switch on dialogues
;write it to the script file
(write-line "qsave" file1)
;save the drawing
;write it to the script file
(if (= (atoi (substr (getvar "acadver") 1 2)) 15)
;if A2K

(write-line "close" file1)
;close the drawing
;write it to the script file
);if
(setq cntr (1+ cntr))
;increment the counter
);repeat
;;;now that we've finished writing the commands to the script
;;;file, we must remember to close it.
DosLib II
http://www.afralisp.com/lispa/lisp59a.htm (3 of 4) [23/03/2005 05:55:29 p.m.]
(close file1)
;close the script file
(command "script" scrfile)
;run the script file and sit back and have a beer.
);progn
);if
(princ)
);defun
(princ)
The script file, batdir.scr should look something like this :
open O:\E51D\E51D1\temp\L102.dwg
.zoom e
filedia 0
mslide O:\E51D\E51D1\temp\L102
filedia 1
qsave
close (A2K Only)
open O:\E51D\E51D1\temp\L101.dwg
.zoom e
filedia 0
mslide O:\E51D\E51D1\temp\L101
filedia 1
qsave
close (A2K Only)
To download this application, Click Here.
Click here to download the latest version of DOSLib.
Click here to visit Robert Mcneel and Associates.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DosLib II
http://www.afralisp.com/lispa/lisp59a.htm (4 of 4) [23/03/2005 05:55:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AfraLisp Slide Manager
Creating Icon menus's in AutoCAD can be quite tedious. First you need to create slides of all your
drawings that you want to include in your menu. Secondly, you need to create a text file with the
names of all the slides. Thirdly you need to run "Slidelib.exe" to create your slide menu. And last
but not least, you need to add all the menu items and macros to your menu. A lot of work hey!
Then, 2 months later you want to add something to the menu and you have to go through the whole
process again.
This is where the "AfraLisp Slide Manager" comes in. This application will allow you to create
Slide Libraries without the overhead of having to create slide libraries or modify your menu files.
Usage :
Create a root directory (eg. C:/Slidemanager) ensuring that Slideman.Lsp, Slideman.Dcl and
Filepath.Dat are within this directory.
Important : This directory MUST be added to your AutoCAD Support Path.
Next, create as many sub-directories as you wish, placing your drawing files and slide files within
these directories. (eg. C:/Slidemanager/Architecural; C:/Slidemanager/Chains;
C:/Slidemanager/NorthSigns; etc.)
Now, load and run "Slideman.Lsp"
The first dialogue is where you choose which library you wish to open.
AfraLisp Slide Manager
The next dialogue is where you choose which block to insert.
AfraLisp Slide Manager
http://www.afralisp.com/lispa/slideman.htm (1 of 2) [23/03/2005 05:55:33 p.m.]
Anytime you wish to add new drawings to the slide library, just add them to an existing library, or
create a new one.
The only restriction is that only 75 drawings are allowed in any one library. (This excludes the
slides.)
To download the "AfraLisp Slide Manager," just click here.
If you would like an application that creates slides from a directory of drawings, visit this page.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AfraLisp Slide Manager
http://www.afralisp.com/lispa/slideman.htm (2 of 2) [23/03/2005 05:55:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Working With Areas
The easiest way of calculating areas in AutoCAD is to simply use the "Area" command. This
command though, leaves a lot to be desired when in comes to usage. And the resulting format? Well
I'm not going to even mention that. (Hang on, you've got to. That's what this tutorial is all about.)
Oop's, silly me.
As you have probably noticed, when you use the "Area" command, it returns the result in the
square units of whatever units you are drawing in. eg. If you are drawing in millimeters, it returns
the result in square millimeters. No more, and no less.
Now this may suit some folk, but me, no way. Even though I work in millimeters, I want the result
returned in square meters AND I want to be able to place the area as text, anywhere in the drawing
that suits me AND nicely formatted with a little square meter thingymebob at the end .
So, what do we do? Easy, we open notepad and start banging away on the keyboard.
;;;M2 Lisp - Version 1.0 - 2nd August 2001
;;;=============================================================
;;;This function will calculate the area (m2) from
;;;points input by the user. The user then has the
;;;option of placing a text label into the drawing using
;;;the current text style/height at a user defined
;;;insertion point.
;;;=============================================================
;;;Written by Kenny Ramage August 2001
;;;=============================================================
;;;=============================================================
;;;Define Main Function
;;;=============================================================
(defun C:M2 ( / os oom laag oec oudosmode p q opp oppm oppma oppmat
tekst pos pos2 flag1 antw lw)
(setvar "cmdecho" 0)
(command "undo" "m")
(setq oom (getvar "orthomode")
laag (getvar "clayer")
oudosmode (getvar "osmode")
olderr *error*
*error* opperr
);setq
(setvar "orthomode" 0)
(print)
(prompt "\nArea Lisp V-1.0 Written by Kenny Ramage
- kramage@mweb.com.na") (prompt "\nPick the corners of the area you want to calculate : ")
(initget 1) (setq p (getpoint "\nFrom point : ") q (list (car p)(cadr p)) );setq (command "layer" "m"
Working with Areas
http://www.afralisp.com/lisp/area.htm (1 of 3) [23/03/2005 05:55:35 p.m.]
"5" "" "pline" q "w" "0" "" );command (while (= (getvar "cmdnames") "PLINE") (redraw
(entlast) 3) (prompt "\nTo point [Close/Undo] : ") (command pause) );while (command "area" "e"
"l") (setq opp (getvar "area") oppm (/ opp 1000000.0) oppma (rtos oppm 2 3) oppmat (strcat
oppma "m") tekst (strcat "\nArea = " oppmat "2") );setq (setq lw (entlast)) (command "layer"
"m" laag "") (prompt tekst) (setq flag1 T) (while flag1 (setq antw (getstring "\nInsert Area Label?
[y/n] : ")) (setq antw (strcase antw)) (if (or (= antw "Y")(= antw "")) (progn (if (not (tblsearch
"layer" "4")) (command "layer" "m" "4" "c" "4" "4" "") (command "layer" "t" "4" "on" "4"
"u" "4" "s" "4" "") );if (setvar "osmode" 0) (setq pos (getpoint "\nInsertion Point : ")) (if (= (cdr
(assoc 40 (tblsearch "style" (getvar "textstyle")))) 0) (command "text" "j" "c" pos "" "0" oppmat)
(command "text" "j" "c" pos "0" oppmat) );if (setq pos2 (cadr (textbox (entget (entlast)))) pos2
(list (+ (car pos)(/ (car pos2) 2.0))
(+ (cadr pos)(cadr pos2)))
);setq
(if (= (cdr (assoc 40 (tblsearch "style"
(getvar "textstyle")))) 0)
(command "text" "j" "tl" pos2 "" "0" "2")
(command "text" "j" "tl" pos2 "0" "2")
);if
(command "scale" "l" "" pos2 ".5")
);progn
);if
(if (or (or (= antw "Y")(= antw "N")(= antw "")))

(setq flag1 nil)
);if
);while
(command "erase" lw ""
"redrawall"
);command
;;;==================================================
;;;Reset System Variables and Restore Error Handler
;;;=================================================
(setq *error* olderror)
(command "layer" "m" laag "")
(setvar "osmode" oudosmode)
(setvar "orthomode" oom)
(princ)
);defun C:M2
;;;===================================================
;;;Define Error Trap
;;;===================================================
(defun opperr (s)
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
);if
Working with Areas
http://www.afralisp.com/lisp/area.htm (2 of 3) [23/03/2005 05:55:35 p.m.]
(setq *error* olderr)
(setvar "osmode" oudosmode)
(setvar "orthomode" oom)
(command "undo" "b"
"layer" "m" laag ""
"redrawall"
);command
);defun opperr
;;;===================================================
(princ)
;;;End Area Lisp
;;;===================================================
;;;==================================================
Load the application and then type "M2" to run. Select the area that you would like to calculate by
picking selected points. A polyline will be traced from each point that you have selected. When you
have finished, select "C." (Close.)
The area will now be displayed at the command line. You will now be given the option to add a
label to your drawing if you so wish.
But now we'll get really clever and try and fool AutoCAD into working out the area that we want
automatically. Interested? Read on............
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Working with Areas
http://www.afralisp.com/lisp/area.htm (3 of 3) [23/03/2005 05:55:35 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Working With Areas (Cont.)
Nice to see you back and glad that you could make it.
Where were we? Oh yes. We were going to try and make AutoCAD determine the area to be
calculated. Let's see! We could try bribes! We could threaten!
Naaw, back to the keyboard.......
;;;M2 Lisp - Version 1.0 - 17th October 2001
;;;=============================================================
;;;This function will calculate an irregular area (m2)
;;;using boundary detection. The user then has the
;;;option of placing a text label into the drawing using
;;;the current text style/height at a user defined
;;;insertion point.
;;;=============================================================
;;;Written by Kenny Ramage October 2001
;;;=============================================================
;;;=============================================================
;;;Define Main Function
;;;=============================================================
(defun C:M2A ( / os oom laag oec oudosmode p q opp opp1 oppm
oppma oppmat tekst pos pos2 flag1 antw lw a b) (setvar "cmdecho" 0) (command "undo" "m")
(setq oom (getvar "orthomode") laag (getvar "clayer") oudosmode (getvar "osmode") olderr
*error* *error* opperr );setq (setvar "orthomode" 0) (print) (prompt "\nIrregular Area Lisp V-1.0
Written by Kenny Ramage - kramage@mweb.com.na") (setq opp 0.0) (command "Layer" "m"
"2" "") (while (setq a (getpoint "\nSelect Internal Point: ")) (command "-Boundary" a "") (setq b
(entlast)) (redraw b 1) (command "area" "O" "L") (setq opp1 (getvar "area")) (setq opp (+ opp
opp1)) ;(redraw b 4) );while (setq oppm (/ opp 1000000.0) oppma (rtos oppm 2 3) oppmat (strcat
oppma "m") tekst (strcat "\nArea = " oppmat "2") );setq (command "layer" "m" laag "")
(prompt tekst) (setq flag1 T) (while flag1 (setq antw (getstring "\nInsert Area Label? [y/n] : "))
(setq antw (strcase antw)) (if (or (= antw "Y")(= antw "")) (progn (if (not (tblsearch "layer" "4"))
(command "layer" "m" "4" "c" "4" "4" "") (command "layer" "t" "4" "on" "4" "u" "4" "s"
"4" "") );if (setvar "osmode" 0) (setq pos (getpoint "\nInsertion Point : ")) (if (= (cdr (assoc 40
(tblsearch "style" (getvar "textstyle")))) 0) (command "text" "j" "c" pos "" "0" oppmat)
(command "text" "j" "c" pos "0" oppmat) );if (setq pos2 (cadr (textbox (entget (entlast)))) pos2
(list (+ (car pos)(/ (car pos2) 2.0)) (+ (cadr pos)(cadr pos2))) );setq (if (= (cdr (assoc 40 (tblsearch
"style" (getvar "textstyle")))) 0) (command "text" "j" "tl" pos2 "" "0" "2") (command "text" "j"
"tl" pos2 "0" "2") );if (command "scale" "l" "" pos2 ".5") );progn );if (if (or (or (= antw "Y")(=
antw "N")(= antw ""))) (setq flag1 nil) );if );while
;;;======================================================== ;;;Reset System
Variables and Restore Error Handler
;;;======================================================= (setq *error* olderror)
(command "layer" "m" laag "") (setvar "osmode" oudosmode) (setvar "orthomode" oom) (princ)
);defun C:M2A ;;;========================================================
;;;Define Error Trap ;;;========================================================
(defun opperr (s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) );if (setq *error*
olderr) (setvar "osmode" oudosmode) (setvar "orthomode" oom) (command "undo" "b" "layer"
Working with Areas II
http://www.afralisp.com/lisp/area2.htm (1 of 2) [23/03/2005 05:55:36 p.m.]
"m" laag "" "redrawall" );command );defun opperr
;;;======================================================== (princ) ;;;End Area
Lisp ;;;=======================================================
;;;======================================================= This time, select a
point within the area that you would like to calculate. A boundary box will be drawn around the
area you have chosen. You can add to the area if you wish by selecting more points resulting in an
accumulation of areas. Again, you have the option of a label being added.
Would you like the source coding for both of these applications?
Go on, I bet you do? O.K. then, position you mouse here and go for it.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Working with Areas II
http://www.afralisp.com/lisp/area2.htm (2 of 2) [23/03/2005 05:55:36 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and HTML - Revisited
I received this from Andy Canfield :
Kenny,
Since you are so nice I am attaching my super cool version of your function which allows an onclick
event. Switches the direction of the slashes and produces a formatted link. Very cool.
Andy.

(defun C:Dwf-Html ( / flag thelist thedir nfiles


thefile fn ctr dname flen
len1 shortdname revSlash
f_oldstr f_newstr f_string)

;set the flag
(setq flag T)

;check Doslib is loaded
(if (not (member "doslib2k.arx" (arx)))

(progn

(if (findfile "doslib2k.arx")

(arxload "doslib2k")

(progn

(alert "DosLib not installed")

(setq flag nil)

);progn

);if

);progn

);if

;if DosLib is installed and loaded
(if flag

;do the following
(progn

;select the DWF files
(setq thelist (dos_getfilem "Select Drawings"
"C:\\" "DWF Files (*.dwf)|*.dwf"))

AutoCAD and HTML - Revisited
http://www.afralisp.com/lisp/html5.htm (1 of 4) [23/03/2005 05:55:38 p.m.]
;retrieve the directory
(setq thedir (car thelist))

;need to reverse the slashes
(setq f_oldstr "\\")
(setq f_newstr "\/")
(setq f_string thedir)
(setq revSlash (replace f_oldstr
f_newstr f_string))

;retrieve the file names
(setq thelist (cdr thelist))

;get the number of files
(setq nfiles (length thelist))

;create the HTML file
(setq thefile (strcat thedir
"Dwf-Html.html"))

;open the HTML file
(setq fn (open thefile "w"))

;set the counter
(setq ctr 0)

;start the loop
(repeat nfiles

;get the drawing name
(setq dname (nth ctr thelist))

;get the length of the drawing name
(setq flen (strlen dname))

;length of drawing name minus .dwf
(setq len1 (- flen 4))

;the drawing name minus .dwf
(setq shortdname (substr dname 1 len1))

;create the HTML link
(write-line (strcat "<a href=# onClick=" "\""
"window.open(" "'" "file:" revSlash dname "'" ",
'modifications','toolbar=no,menubar=no,
status=yes,resizable=yes,scrollbars=yes,
width=800,height=600'); return false;
" "\"" ">" shortdname "</a><br>") fn)

;increment the counter
(setq ctr (1+ ctr))

);end repeat

;close the file
(close fn)

;inform the user
AutoCAD and HTML - Revisited
http://www.afralisp.com/lisp/html5.htm (2 of 4) [23/03/2005 05:55:38 p.m.]
(alert (strcat "File saved as" "\n"
thedir "Dwf-Html.html"))

);progn

);if flag

;finish clean
(princ)

);defun
;load clean
(princ)
;the following function was Written By Michel Loftus
(defun replace (f_oldstr f_newstr
f_string / f_cur f_loop)
;like subst but with strings not lists
(if (null (and (stringp f_oldstr)
(stringp f_newstr)
(stringp f_string)
)
)
(exit)
)
(if (> (strlen f_oldstr) (strlen f_string))
(exit)
)
(setq f_loop 1)
(repeat (strlen f_string)
(progn
(setq f_cur (substr f_string f_loop
(strlen f_oldstr)))
(if (= f_cur f_oldstr)
(setq f_string (strcat (substr f_string 1 (- f_loop 1))
f_newstr
(substr f_string
(+ f_loop (strlen f_oldstr))
(strlen f_string)
)
)
)
)
(setq f_loop (1+ f_loop))
)
)
f_string
)
;eg (replace "\t" " " "Line one\tLine two") = "Line one Line two"
;the following function was Written By Michel Loftus
(defun stringp (f_val) ;test if a string
(if (= (type f_val) 'STR)
t
nil
)
)
AutoCAD and HTML - Revisited
http://www.afralisp.com/lisp/html5.htm (3 of 4) [23/03/2005 05:55:38 p.m.]
;eg (stringp "Hello") = true
Download Source Coding Here

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and HTML - Revisited
http://www.afralisp.com/lisp/html5.htm (4 of 4) [23/03/2005 05:55:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Environmental Issues
Setting up Support Paths within AutoCAD can be a real pain in the proverbial backside especially, if
you've got a whole stack of workstations to deal with. It's even worse, if like my office, each user has
different menu settings and support files.
The following coding shows you how you can automate this process by making use of the AutoCAD
(getenv) and (setenv) functions.
Firstly we need to set up our Support Path directories. Mine looks like this :
C:/NDBE51D1
|
|
|------------ LISP
|------------ VBA
|------------ BLOCKS
|------------ DRAWINGS
|------------ MENU
|------------ TEMPLATES
NDBE51D1 is my login name.By incorporating the users login name into the support path,
we know who we are dealing with and can set up our Support Paths to suit.
;CODING STARTS HERE
(defun C:SETNEWPATH ( / netpath defpath)
;define the network path - replace this with your
;network path
(setq netname "C:\\")
;define the user directory path
(setq netpath (strcat netname (getvar "LOGINNAME")))
;set to AutoCAD default
(setenv "ACAD" "")
;store the default paths
(setq defpath (getenv "ACAD"))
;set up the custom paths
(setenv "ACAD" (strcat
defpath ";"
netpath ";"
netpath "\\" "lisp;"
netpath "\\" "vba;"
netpath "\\" "blocks;"
netpath "\\" "drawings;"
netpath "\\" "menu;"
))
;set up the custom template path
(setenv "TemplatePath" (strcat netpath "\\" "Templates"))
;set up the custom temp directory path
Environmental Issues
http://www.afralisp.com/lisp/environ.htm (1 of 2) [23/03/2005 05:55:39 p.m.]
(setenv "Temp" "C:\\temp")
;inform the user
(alert "Custom Support Paths Defined")
(princ)
);defun
(princ)
;CODING ENDS HERE

You could incorporate this into your Acad.lsp file to ensure that all your Support Paths are set correctly.
Irrespective of the user, the correct Support Path will be defined.
Also, to ensure that the correct menu is loaded, have a look at the Acad.lsp Tip found on AfraLisps Tips
'n Tricks page.
Hey, come to think of it, you could also use this in conjunction with Profiles to make life even easier.
Oh, by the way, if you'd like a listing of Environment Variables, pop along here.
(Listing kindly donated by Stig Madsen.)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Environmental Issues
http://www.afralisp.com/lisp/environ.htm (2 of 2) [23/03/2005 05:55:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and Profiles
Profiles are a great way of quickly loading your standard settings and ensuring that drawing office
standards are adhered too.
To get to the Profiles in Visual Lisp, we need to reference the PreferencesProfiles Object. Here's an
extract from the AutoCAD Object Model :
Application (Object)
|
|
|----- Preferences
| (Object)
| |
| |
| |
| |----- PreferencesProfiles
| | (Object)
| |
| |
| |
Firstly, we need a reference to the Application Object :
_$ (vl-load-com)
_$ (setq acadobject (vlax-get-Acad-Object))
#<VLA-OBJ ECT IAcadApplication 00adc088>
And next the Preferences Object :
_$ (setq acadprefs (vla-get-preferences acadobject))
#<VLA-OBJ ECT IAcadPreferences 02d003cc>
And now a reference to the PreferencesProfiles Object :
$ (setq acadprofiles (vla-get-profiles acadprefs))
#<VLA-OBJ ECT IAcadPreferencesProfiles 02d003bc>
Let's run a dump on the PreferencesProfile Object :
_$ (vlax-dump-object acadprofiles T)
; IAcadPreferencesProfiles: This object contains the options from the Profiles tab on the Options dialog
; Property values:
; ActiveProfile ="<<Unnamed Profile>>"
; Application (RO) =#<VLA-OBJ ECT IAcadApplication 00adc088>
; Methods supported:
; CopyProfile (2)
; DeleteProfile (1)
; ExportProfile (2)
; GetAllProfileNames (1)
; ImportProfile (3)
; RenameProfile (2)
; ResetProfile (1)
T
As you can see, this Object has only one Property that really interests us, the Active Profile, but seven
Methods that look quite interesting
Let's have a look at the Active Profile Property first :
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (1 of 6) [23/03/2005 05:55:41 p.m.]
_$ (setq actprofile (vla-get-ActiveProfile acadprofiles))
"Admin"
This tells us quite clearly that the Active Profile on my system is a profile named "Admin".
But, we would like to have a list of all profile names. For this we would need to use the
GetAllProfilesNames Method :
(vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
nil
Let's have a look at "thelist" "
_$ thelist
#<safearray...>
Oh, oh, it's a safearray. We need to convert it :
_$ (vlax-safearray->list thelist)
("Admin" "Eric")
That's better, now we've got a list of all presently loaded profiles.
Let's load a new one :
_$ (setq NewProfile (vlax-invoke-method acadprofiles 'ImportProfile "NDBE51D1"
"c:/Profiles/NDBE51D1.arg" :vlax-true))
nil
Have a look at your "Profiles" under "Options". A new profile should have been Imported.
Let's check that it's there programmically :
_$ (vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
nil
_$ (vlax-safearray->list thelist)
("Admin" "Eric" "NDBE51D1")
OK, I'm happy now, I know it's there.
We still though, need to make it the Active Profile :
_$ (vla-put-ActiveProfile acadProfiles "NDBE51D1")
nil
Let's Export a profile :
_$ (vlax-invoke-method acadProfiles 'ExportProfile "Eric" "c:/profiles/eric.arg")
nil
Have a look in your Profiles directory. You should have a new arg file.
Right, now let's be nasty and delete a profile :
_$ (vlax-invoke-method acadProfiles 'DeleteProfile "NDBE51D1")
; error: Automation Error. Cannot delete a profile that is in use.
Ha, ha, of course we can't delete that profile 'cos it's the Active Profile.
OK, let's try another one :
_$ (vlax-invoke-method acadProfiles 'DeleteProfile "Admin")
nil
Bye, bye, Mr Admin profile.
Let's reset a profile :
_$ (vlax-invoke-method acadProfiles 'ResetProfile "Eric")
nil
Hey, nothing happened! That's because the profile "Eric" is not the Active Profile.
Let's try again :
_$ (vlax-invoke-method acadProfiles 'ResetProfile "NDBE51D1")
nil
That's better, the profile is reloaded.
Let's copy an existing profile to a new profile :
_$ (vlax-invoke-method acadProfiles 'CopyProfile "NDBE51D1" "CopiedProfile")
nil
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (2 of 6) [23/03/2005 05:55:41 p.m.]
We now have a new profile named "CopiedProfile". Let's rename it :
_$ (vlax-invoke-method acadProfiles 'RenameProfile "CopiedProfile" "RenamedProfile")
nil
Let's list them again :
_$ (vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
nil
_$ (vlax-safearray->list thelist)
("Eric" "NDBE51D1" "RenamedProfile")
Here's a little application that you may find interesting. It will check the Login Name of
the user and automatically load the relevant Profile for that user.
Firstly you need to name your Profiles the same as your Login Name. e.g. if your Login
Name is NDBE51D1, your Profile must be named NDBE51D1.ARG. Then you need to
store all your user Profiles in the same folder. (This example uses "c:/profiles/").
Irrespective of which user logs in, the specific Profile for that user will be loaded if
necessary, and made Active.
Not much in the way of error checking at the moment I'm afraid.....
;CODING STARTS HERE
(prompt "\nType LoginProfile to run......")
(vl-load-com)
(defun C:LoginProfile (/ profilename acadprofiles actprofile
thelist profilepath)
;retrieve the users login name
(setq profilename (strcase (getvar "LOGINNAME")))
;retrieve a reference to the Profiles
(setq acadprofiles (vla-get-profiles
(vla-get-preferences (vlax-get-Acad-Object))))
;retrieve the Active Profile
(setq actprofile (strcase (vla-get-ActiveProfile acadprofiles)))
;if they are not the same
(if (/=profilename actprofile)
;do the following
(progn
;get a list of the loaded profiles
(vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
;convert to a list
(setq thelist (vlax-safearray->list thelist))
;if the profile is not in the list
(if (not (member profilename thelist))
;do the following
(progn
;store the profile file
(setq profilepath
(strcat "c:/profiles/" profilename ".arg"))
;if the profile is found
(if (findfile profilepath)
;do the following
(progn
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (3 of 6) [23/03/2005 05:55:41 p.m.]
;load the profile
(setq NewProfile (vlax-invoke-method
acadprofiles 'ImportProfile
profilename profilepath :vlax-true))
;make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);progn
;profile file cannot be found - exit
(prompt (strcat "\nCannot find profile " profilepath))
);if
);progn
;it is loaded but make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);if
);progn

;We could reload the Profile if we wish.


;J ust uncomment the next line.
;(vlax-invoke-method acadProfiles 'ResetProfile profilename)
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
And here's a fewmiscellaneous Profile Functions :
;;; profiles.lsp
;;; miscellaneous profile commands
;;; by Jimmy B
;;; 2000-01-25
;;;----------------
(defun getActiveProfile ()
(vla-get-activeprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
)
)
(defun putActiveProfile (profilename)
(vla-put-activeprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename
)
)
(defun getAllProfileNames(/ allprofiles)
(vla-getallprofilenames
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
'allprofiles
)
(vlax-safearray->list allprofiles)
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (4 of 6) [23/03/2005 05:55:41 p.m.]
)
(defun existProfile (profilename)
(not (not (member
(strcase profilename)
(mapcar '(lambda (x) (strcase x)) (getallprofilenames))
)))
)
(defun c:listProfileNames(/ nr profnames)
(setq nr 0)
(setq profnames (getAllProfileNames))
(repeat (length profnames)
(princ (nth nr profnames))
(print)
(setq nr (1+ nr))
)
(princ)
)
; return T if profile is deleted and nil if not
(defun deleteProfile (profilename)
(if (and
(/= (strcase profilename) (strcase (getActiveProfile)))
(existProfile profilename))
(not (vla-deleteprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename
))
)
)
; return T if profile is reseted and nil if not
(defun resetProfile (profilename)
(if (existProfile profilename)
(not (vla-resetprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename
))
)
)
; return T if profile is renamed and nil if not
; if profilenameNew exist it's substituded with profilenameOld
(defun renameProfile (profilenameOld profilenameNew)
(if (existProfile profilenameOld)
(not (vla-renameprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilenameOld
profilenameNew
))
)
)
; return T if profile is copied and nil if not
; if profilename2 exists it's copied
(defun copyProfile (profilename1 profilename2)
(if (existProfile profilename1)
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (5 of 6) [23/03/2005 05:55:41 p.m.]
(not (vla-copyprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename1
profilename2
))
)
)
; (exportProfile "profilename" "C:\\TEMP\\profilename.arg")
; if path is omitted profile is saved in active directory
; overwrites argname if it exists
; return T if profile is exported
(defun exportProfile (profilename argname)
(if (existProfile profilename)
(not (vla-exportprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename
argname
))
)
)
; (importProfile "profilename" "C:\\TEMP\\profilename.arg" 1)
; overwrites profilename if it exists
; if path is omitted profile is imported from active directory
; inclpathinfo=1 The path information in the registry file
; will be preserved.
; inclpathinfo=0 The path information in the registry file
;will not be preserved.
; return T if profile is imported
(defun importProfile (profilename argname inclpathinfo)
(not (vla-importprofile
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
profilename
argname
inclpathinfo
))
)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Profiles
http://www.afralisp.com/vl/profiles.htm (6 of 6) [23/03/2005 05:55:41 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Quick Plot
Plotting in AutoCAD can be quite a time consuming and sometimes confusing exercise. In most drawing
offices, there are normally not more than two plotters/printers, and if you look at things carefully, you will
find that that the majority of the plots are produced using the same plot settings. As well, plotters only
change at somewhat long intervals, therefore a wee bit of hard coding in regards to Plotter Configuration
and Plot Styles is really neither here nor there.
That's where Quick Plot comes in. Quick Plot can be set up to use your more common plot
configurations, plot styles and plot sheets, drastically cutting down on the time needed to plot.
Quick Plot is simple to use. Window the section of the drawing you want plotted - we use crop marks to
ensure true scaling - select the plotter you want to plot too, select the size of sheet you would like to use,
and away you go.
To customise this routine, all you have to do is create a Plot Configuration file (PC3) to suit your plotter,
create a Plot Style file (CTB) and then replace the names of these files with the names of the Plotters and
Plot Styles within the coding.
First the DCL coding. Save this as "Q-Plot.dcl."
qplot : dialog {
label = "Quick Plot 2002";
: boxed_radio_column {
label = "Choose Plotter :";
//change the plotter name to suit your own
: radio_button {
label = "Plotter No &1";
key = "rb1";
}
//change the plotter name to suit your own
: radio_button {
Quick Plot
http://www.afralisp.com/lisp/quick_plot.htm (1 of 5) [23/03/2005 05:55:43 p.m.]
label = "Plotter No &2";
key = "rb2";
}
}
: boxed_radio_column {
label = "Plot Size :";
: radio_button {
label = "A&0 - 1189 x 841";
key = "rb5";
}
: radio_button {
label = "A&1 - 841 x 594";
key = "rb6";
}
: radio_button {
label = "A&2 - 594 x 420";
key = "rb7";
}
: radio_button {
label = "A&3 - 420 x 297";
key = "rb8";
}
: radio_button {
label = "A&4 - 297 x 210";
key = "rb9";
}
}

ok_cancel ;
: paragraph {
: text_part {
label = "Designed and Created";
}
: text_part {
label = "by CAD Encoding";
}
}
}
choose : dialog {
label = "Quick Plot 2002";

: text {
label = "Continue with Plot?";
alignment = centered;
}
ok_cancel ;

}

And Now the AutoLisp coding. Save this as "Q-Plot.lsp."


Quick Plot
http://www.afralisp.com/lisp/quick_plot.htm (2 of 5) [23/03/2005 05:55:43 p.m.]
;;;CODING STARTS HERE
;|To customise this to suit your plotters, you need to do 3 things :
Create a PC3 plot configuration file and replace the value of the
variable "pltyp" with the name of your PC3 file.
eg. Replace "RW-470 PLOTBASE.pc3" with "YOURPLOTTER.pc3"
Create a CTB plot style and replace the value of the variable "plstyle"
with the name of your CTB file.
eg. Replace "acad.ctb" with "your.ctb"
Replace all the "plsize" variables with your sheet sizes.
==============================================|;
(defun C:Q-PLOT ( / userclick userclick1 pltyp plstyle plsize
oldblip oldecho oldsnap dcl_id)
;preset the flags
(setq userclick T)
(setq userclick1 T)
;store system settings
(setq oldblip (getvar "BLIPMODE")
oldecho (getvar "CMDECHO")
oldsnap (getvar "OSMODE"))
;set system variables
(setvar "BLIPMODE" 0)
(setvar "CMDECHO" 0)
(setvar "OSMODE" 32)
;store the default plotter, plot style and plot size
;replace this with your pc3 file
(setq pltyp "RW-470 PLOTBASE.pc3")
;replace this with your ctb file
(setq plstyle "acad.ctb")
;replace this with your default sheet size
(setq plsize "ISO A0 (1189.00 x 841.00 MM)")
;get the plotting area
(setq pt1 (getpoint "\nSelect Lower Left Hand Corner
of Plotting Area: "))
(setq pt2 (getcorner pt1 "\nSelect Upper Right Hand
Corner of Plotting Area: "))
;remember your manners
(prompt "\nThanks.......")

;load the dialog
(setq dcl_id (load_dialog "q-plot.dcl"))
(if (not (new_dialog "qplot" dcl_id) ) (exit))
(set_tile "rb1" "1")
(set_tile "rb5" "1")
; set the tiles
Quick Plot
http://www.afralisp.com/lisp/quick_plot.htm (3 of 5) [23/03/2005 05:55:43 p.m.]
;replace this with your first pc3 file
(action_tile "rb1"
"(setq pltyp \"RW-470.pc3\")")
;replace this with your second pc3 file
(action_tile "rb2"
"(setq pltyp \"DesignJet 700.pc3\")")
;replace all sheet sizes to match yours
(action_tile "rb5"
"(setq plsize \"ISO A0 (1189.00 x 841.00 MM)\")")
(action_tile "rb6"
"(setq plsize \"ISO A1 (841.00 x 594.00 MM)\")")
(action_tile "rb7"
"(setq plsize \"ISO A2 (594.00 x 420.00 MM)\")")
(action_tile "rb8"
"(setq plsize \"ISO A3 (420.00 x 297.00 MM)\")")
(action_tile "rb9"
"(setq plsize \"ISO A4 (297.00 x 210.00 MM)\")")
(action_tile "cancel"
"(done_dialog)(setq userclick nil)")
(action_tile "accept"
"(done_dialog) (setq userclick T)")
;start the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;if OK is selected
(if userclick
;do the following
(progn
;preview the plot
(command "Preview")
;load the "Continue" dialog
(setq dcl_id (load_dialog "q-plot.dcl"))
(if (not (new_dialog "choose" dcl_id) ) (exit))
;set up the tiles
(action_tile "cancel"
"(done_dialog)(setq userclick1 nil)")
(action_tile "accept"
"(done_dialog) (setq userclick1 T)")
(start_dialog)
(unload_dialog dcl_id)
;if it's OK to continue
(if userclick1
;plot the drawing
(command "-plot" "Yes" "Model" pltyp plsize "Millimeters"
"Landscape" "No" "Window" pt1 pt2 "Fit" "Center"
"Yes" plstyle "Yes" "No" "No" "Yes" "Yes")
Quick Plot
http://www.afralisp.com/lisp/quick_plot.htm (4 of 5) [23/03/2005 05:55:43 p.m.]
;the plot was Cancelled
;return to the main dialog
(c:autoplot)
);if userclick1

);progn
);if userclick
;reset system variables
(setvar "BLIPMODE" oldblip)
(setvar "CMDECHO" oldecho)
(setvar "OSMODE" oldsnap)
(princ)
);defun c:q-plot
;;;*======================================================
(princ)
;CODING ENDS HERE
If you like, you can download the source coding here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Quick Plot
http://www.afralisp.com/lisp/quick_plot.htm (5 of 5) [23/03/2005 05:55:43 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
DC Tools
Here is a collection of some of my lisp routines that I use very frequently on a daily basis and are also
often used by others in the office. They are very rough and ready, but they do the job quite nicely. I have
quite a few ideas to beef them up, but I'm sure there are many other coders out there that will also enjoy
toying around with them and tidying them up.
Dave Corral
Addcnst.lsp
Add or subtract a constant from a selection set of text.
This routine will automatically screen out non text entities and text entities that are not numerical and
then apply the constant (+ve or -ve) to the remaining numerical text entities.
Cnvrt.lsp
Units Conversion Calculator v2.0 2002
This lisp routine will convert most units in the following categories:
Linear G
Area G
Volume G
Time G
Mass G
Circular G
The first dialog requests that you choose which category of units you wish to convert.
The second dialog requests that you choose the units to convert from and to. You can type in a value
for the measurement of the convert from units in the space provided, then click convert, and the
calculation is done. The default conversion value is 1. Accepting this when clicking convert will give
you the actual conversion factor.
Coordtbl.lsp
Co-ordinate Table Generator
Important: Your UCS must be set to read the correct coordinates
First prompt "Write co-ordinates to file y/N:". If you reply YES, you will be prompted for output filename
and then "Format for file (C)omma delimited <(S)paced>:". The default extension for the file will be .DAT.
Comma delimited, Label Y-coord X-coord and Level will be separated by commas.
Space delimited, Label Y-coord X-coord and Level will be separated by spaces (same as TAB delimited).
You will then be prompted for the table insertion point, then the rotation angle for the table followed by
the scale of the drawing (this is the scale that you intend to plot the drawing at).
A dialog box will come up asking if you want to include labels, if yes, then if you wish to type them in or
pick them as text entities from the drawing. The same for the levels, with added option to automatically
read levels from 3D node points. Remember if you choose to type in the values, all of the values have to
be typed, similarly if you choose to pick values all of the values have to be picked. As you pick the
points you will see that the table starts taking shape.
When you are finished picking points press enter. You will then be prompted for the table heading.
DC_3dpi.lsp
Import Co-ordinates from file
DC Tools
http://www.afralisp.com/lisp/dctools.htm (1 of 5) [23/03/2005 05:55:45 p.m.]
You will be prompted for a file to read coordinates from file. The file can be Comma delimited or Space
delimited. The comma delimited file must be in the format :
Y-coord,X-coord,Level,Label.
The space delimited file must be formatted as :
Label Y-Coord X-Coord Level
The file can be manually typed with at least 6 spaces between each column. If all the Labels are of the
same length eg 3 digits and the other columns also the same length then the spaces may be changed
for tab spacing.
After you have selected the file, you will be prompted as follows :
Scale of drawing, number of decimals and rotation angle for text.
Then you will be asked what format the file is in Comma or Space delimited.
The points will then be read in from the file and placed as follows :
a point will be drawn on POINTS layer, the level will be placed on ELEVATIONS layer and the label will
be placed on CODES layer. Point size and shape can be controlled with PDMODE and PDSIZE. Colors
are all BYLAYER.
DC_Bank.lsp
Embankment Line Generator
DC_Chains.lsp
Chainages Lisp Routine
This lisp routine will draw chainages at user defined intervals along a 2D polyline. It use a block called
"sv.dwg" which contains a single attribute for the chainage text. IMPORTANT: the chainages will go
from the start of the polyline in the direction that it was drawn.
As a bonus you can also number bend points or PI's (points of intersection of curves) by typing BENDS
(currently this only numbers the ends of the polyline segments, it does not number the intersection of
straights at bends).
DC_Cords.lsp
Label Co-ordinates
This routine will label the northing(X-coord) and easting(Y-coord) of a picked point.
Important : UCS must be set to read correct co-ordinates.
You will be prompted for scale of drawing, number of decimals for coordinates, rotation angle for text
and then to pick points or enter to end.
DC_Lsec.lsp
Create Longsection from 2D Contours DC_LSEC.lsp v1.0
Operation of the routine :
1. Type DC_LSEC at the command prompt.
2. You will be prompted as follows :
Horizontal scale: This is the horizontal scale you wish for the longsection
(it is assumed that your contour drawing is full scale ie 1:1)
Vertical scale: This is the vertical scale for the longsection.
Datum: This is the datum level for the longsection.
Start of longsection: This is an arbitrary point near to where you would like your longsection to start
The chainage 0 will be you first point or contour picked.
End of longsection: This again is an arbitrary point near the end of your longsection.
The end chainage will be the final point that you pick.
You are then prompted to pick points along the line drawn for your longsection. At each pick you are
prompted for a level of contour. The routine will automatically snap to intersection of the line and
contour but you may pick a point (spot height) anywhere in between the contours.
DC Tools
http://www.afralisp.com/lisp/dctools.htm (2 of 5) [23/03/2005 05:55:45 p.m.]
Upon completion of picking points press enter and then you will be prompted to pick insertion point of
longsection. This is the intersection point of the Datum and chainage 0.
3. The longsection will now be drawn and upon completion you will be prompted as follows:
Horizontal grid spacing: This is the distance between the vertical lines that will be drawn as a grid over
the longsection.
Vertical grid spacing: This is the distance between the horizontal lines of the grid. Each of these lines
will be labelled with a level relative to the datum.
DC_Sect2.lsp
Section Arrow Lisp Routine
This routine will automatically insert, align and label section indication arrows. If ortho mode is off, the
arrows will be aligned with the points picked. If ortho mode is on, the arrows will align with the UCS.
User input required is to pick the two points on either side of the "section", you will then be prompted
for the section label.
DC_Slope.lsp
Slope Annotation Lisp routine
DC_Num.lsp
Incremental Numbering
This routine will prompt for (in order) text height, text angle, prefix (enter for none), start number, final
number and increment. Then simply pick the position of each consecutive number in order from start to
end. This is useful for numbering erven or town plot layouts.
GetCords.lsp
Create a file of co-ordinates by picking points from the drawing.
You will be prompted for the file name and then a dialog box will come up asking if you want to include
labels, if yes, then if you wish to type them in or pick them as text entities from the drawing. The same
for the levels. Remember if you choose to type in the values, all of the values have to be typed, similarly
if you choose to pick values all of the values have to be picked (MTEXT and attributes are not
recognised).
When complete press enter and the file will be closed.
RotBlok.lsp
Rotate Blocks
This routine does just that ! It takes each selected block entity and adds the angle input by you to each
block entities current rotation angle, i.e. the blocks in your selection set need not all have the same
rotation angle. Positive angles are measured counter clockwise and negative angles are measured
clockwise.
RotTxt.lsp
Rotate text
This routine does just that ! It takes each selected text entity and adds the angle input by you to each
text entities current rotation angle, ie the text in your selection set need not all have the same rotation
angle. Positive angles are measured counter clockwise and negative angles are measured clockwise.
SclTxt.lsp
Scale Text
Use this routine if you are changing the scale of a drawing, or, if you wish to change the size of text
within a drawing. This is very useful if you have various text heights and you do not want to lose the
proportions of these heights.
You will be prompted for the old scale of the drawing and then the new scale for the drawing. A scale
factor is then calculated.
You are then prompted to select the text. You can use "ALL" as your selection set as non text entities
will be ignored. The scale factor is then applied to all text entities found.
SGrid.lsp
Survey Co-ordinate Grid SGRID.lsp version 3.1
DC Tools
http://www.afralisp.com/lisp/dctools.htm (3 of 5) [23/03/2005 05:55:45 p.m.]
Explanation of Dialog Control Box:
Northing: This is the notation for the axis (latitude) that you wish to use. In the southern hemisphere
this will normally be X. If you select X here your easting axis will automatically be labelled Y
Text Orientation: This determines whether the text will be written Upright or Inverted. This will depend
on the orientation of your UCS. Normally we orientate our drawings so that North points towards he top
of the screen but in order to read correct co-ordinates our UCSICON is rotated so that it points to the
bottom of the screen. In this case to get your text written so that it is correct on screen you select the
text to be inverted.
Text Alignment: This determines whether the text will be Aligned (parallel) with the axes or Horizontal.
Again this would depend on your current UCS. Horizontal will align the text to the x-axis of your UCS.
Cross Length: This will determine the size of the cross at each co-ordinate point. The length that you
input here will be scaled according to the Drawing Scale as discussed later. I have found that a good
size to use would be 20.
Grid Style: This determines the style of grid you wish to use. If you choose Full you will be prompted for
the lower left point of the grid and then the upper right point of the grid. The routine will then draw in all
the grid crosses and co-ordinates that will fit between these two points based on the Grid Interval that
you have selected. If you choose Partial you will be prompted to pick points for each grid cross where
you want each of them to be.
Grid Interval: This will determine the spacing of the crosses. You will notice that the grid snap is set to
this spacing that you choose, this is to make it easier for picking the points as discussed in Grid Style.
Drawing Scale: This will scale the cross length and the text height. The text height is programmed such
that when plotted out the text height will be 2.5mm.
XYZtbl.lsp
3D Node Ordinate Table
----------------------------
This routine is used for creating a table of X, Y and Z ordinates of 3D objects by picking the points to be
co-ordinated. It will also give the option to add a label to each set of ordinates.
Once the 3D object has been set up in the 3D view that you wish and the UCS is set to view. Load the
lisp routine XYZTBL.LSP and type "3DTABLE" at the command prompt. You will be prompted for
insertion point of table, then rotation angle, scale and number of decimals. The dialog box will then be
shown, asking whether or not you wish to label points. If you choose to label points you are further
prompted to opt to enter or pick labels. Enter labels requires keyboard input when requested and pick
labels requires you to pick text entities that were put in prior to running the lisp routine using normal
drafting methods. (NOTE this pick label routine does not recognise MTEXT entities). The table of
ordinates will be created as you pick the points. When finished picking points, press enter and you will
be prompted for the table heading. All of the above will be placed on a layer COORD_TBL which is
automatically created and made current by the routine.
About the table:
------------------
The layer coord_tbl will have a colour assignment of yellow and linetype continuous.
The text style will be the current style and colour yellow as well, and height 2.5mm x the scale specified.
The table heading will be color red and height 3mm x scale specified.
The columns will be as follows: Node 15mm wide
X,Y,Z 25mm wide.
You can download DC-Tools here. ( 98kb )

DC Tools
http://www.afralisp.com/lisp/dctools.htm (4 of 5) [23/03/2005 05:55:45 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DC Tools
http://www.afralisp.com/lisp/dctools.htm (5 of 5) [23/03/2005 05:55:45 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD Setup
Let's imagine this scenario.
You've created a complex menu application complete with AutoLisp functions, Library files, Help files,
Hatches, etc, etc. To load it yourself on your system is no problem. You know exactly which support
paths need to be added, and exactly what menu file and pull down menu's need to be defined.
But now, you have 20 machines to load it on, or even worse, you need to send it to a third party to
install on their system and you are not available. Now what? You could try and type the installation
instructions out for them, but the users who will be installing your menu system don't even know where
to find the "Options" dialog, never mind set support paths. This is where the following application will
come in very handy.
It basically sets up a custom profile, adds your support paths, and then finds and loads your custom
pull down menu.
Firstly the program creates a profile called "AfraLisp".
(That is if "AfraLisp" is not already the active profile.)
Don't worry, it retains your current profile so that you can re-set if necessary.
Secondly, it adds your support paths. I have used the following:
"C:/AfraLisp2002"
"C:/AfraLisp2002/Menu"
"C:/AfraLisp2002/CadLisp2k"
"C:/AfraLisp2002/CadLib2k"
"C:/AfraLisp2002/CadMech"
"C:/AfraLisp2002/Hatching"
"C:/AfraLisp2002/Help"
"C:/AfraLisp2002/Profiles"
Just replace the paths with your own. You will need to have these created and populated with your files
on your hard drive.
Lastly, it locates and loads the "AfraLisp" menu file which is stored in "C:/AfraLisp2002/Menu" and
places a pull down menu into the menu bar.
You will need to replace the "AfraLisp" with the name of your own partial menu.
;CODING STARTS HERE
(prompt "\nType \"AfraLisp-Install\" to run......")
(defun C:AfraLisp-Install ( / netpath defpath acadprofiles actprofile temp flag1)
(vl-load-com)
;retrieve the profiles collection
(setq acadprofiles
(vla-get-profiles
(vla-get-preferences
(vlax-get-Acad-Object))))
;get the active profile
(setq actprofile
(vla-get-ActiveProfile acadprofiles))
;check "AfraLisp" is the active profile
(if (not (= actProfile "AfraLisp"))
(progn
;if it's not, copy the existing profile, renaming it "AfraLisp".
(vlax-invoke-method acadProfiles 'CopyProfile actProfile "AfraLisp")
AutoCAD Setup
http://www.afralisp.com/vl/acadset.htm (1 of 3) [23/03/2005 05:55:47 p.m.]
;then make it the active profile
(vla-put-ActiveProfile acadProfiles "AfraLisp")
);progn
);if
;;;=================================
;;;Set up the AfraLisp Support Paths
;set the path to the AfraLisp subdirectory.
(setq netpath "C:\\AfraLisp2002")
;set the support paths to the AutoCAD default
(setenv "ACAD" "")
;store the default paths
(setq defpath (getenv "ACAD"))
;set up the AfraLisp paths
(setenv "ACAD" (strcat
defpath ";"
netpath ";"
netpath "\\" "Menu;"
netpath "\\" "CadLisp2k;"
netpath "\\" "CadLib2k;"
netpath "\\" "CadMech;"
netpath "\\" "Hatching;"
netpath "\\" "Help;"
netpath "\\" "Profiles;"
))
;set up the custom template path
(setenv "TemplatePath" (strcat netpath "\\" "Templates"))
;inform the user
(prompt "\nAfraLisp Support Paths Defined\n")
;;;================
;;;Now load the AfraLisp Menu
;set the flag
(setq flag1 T)
;check if the "AfraLisp" menu is loaded
(setq loaded (menugroup "AFRALISP"))
;if it's not
(if (= loaded nil)
(progn
;find the menu file
(setq temp (findfile "AFRALISP.MNU"))
;if it's found
(if temp
(progn
(setvar "FILEDIA" 0)
;load the "AfraLisp" menu
(command "menuload" "AFRALISP")
(setvar "FILEDIA" 1)
;load the pulldown menu
(menucmd "P11=+AFRALISP.POP1")
;Inform the user
AutoCAD Setup
http://www.afralisp.com/vl/acadset.htm (2 of 3) [23/03/2005 05:55:47 p.m.]
(prompt "\nLoading AfraLisp Custom Menu....\n")
);progn
(progn
;if it's NOT found, inform the user
(alert "Cannot Locate AfraLisp Menu.")

;then clear the flag
(setq flag1 nil)
);progn
);if
);progn
);if
;if the menu is loaded
(if flag1
;inform the user
(prompt "\nAfraLisp Custom Menu Loaded....")
);if
(princ)
);defun
(princ)
;CODING ENDS HERE

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD Setup
http://www.afralisp.com/vl/acadset.htm (3 of 3) [23/03/2005 05:55:47 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
An Introduction to 'acetutil' Functions
The acetutil modules (acetutil.arx, acetutil*.fas) provide a number of utility functions which can be called
from LISP.
This documentation covers all functionality present in version 1.37 of acetutil.arx, along with a few
functions provided in acetutil.fas. Functions that do not have a specific library designation appear in
acetutil.arx.
Entity Functions
acet-ent-geomextents ename)
Returns the geometric extents of the given object.
Arguments
ename
The entity name of an object.
Return Values
A list containing two points (such as ((1.0 1.0 0.0) (2.0 2.0 0.0))) describing the geometric extents.
Error Handling Functions
(acet-error-init args)
Error handler.
Note:
This function should be paired with (acet-error-restore) below to encapsulate error handling for LISP
functions or commands that may be aborted by the user.
Arguments
args
A list containing up to three elements (described below).
Arguments are provided in a list to allow for future enhancements. The list can currently be nil or can
contain up to three elements:
A list containing pairs of system variable names along with an initial value for each variable, in the
form:
("sysvar" value "sysvar" value ...)
The (acet-error-init) function will preserve the initial value of these variables (see (acet-error-restore)
below) and then set the new values.
A flag value indicating whether UNDO should be used as part of the error handling operation. This value
can be one of:
nil Do not use undo. G
0 Enable Undo and place begin and end marks, but do not issue the UNDO command in the event
of an error.
G
1 Enable Undo and use the UNDO command in the event of an error. G
A quoted function call that will be executed as part of the error handling operation. A nil argument
indicates that no additional error handling is required.

Return Values
nil
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (1 of 12) [23/03/2005 05:55:49 p.m.]
Example
(acet-error-init '(("CMDECHO" 0) 1 (if ename (redraw ename 4)) ) )
(acet-error-restore)
Reset error handling.
This function restores the values saved by the matching call to (acet-error-init). It should be called after
all user input has been completed. This function ends with a (princ) call for a quiet finish.
Return Values
nil
Library: acetutil.fas
File Functions
(acet-file-attr filename [attr])
Gets or sets the protection attributes of a specified file or directory.
Arguments
filename: Name of the file or directory.
attr: If provided, a combination of one or more attribute flags.
Return Values
Returns the new or existing attributes, or -1 on error.
Note:
The following pre-defined constants are provided:
1 = Acet:READONLY
2 = Acet:HIDDEN
4 = Acet:SYSTEM
16 = Acet:DIRECTORY
32 = Acet:ARCHIVE
Library: acetutil.arx
(acet-file-chdir directory)
Changes the current working directory.
Arguments
directory: New directory name.
Return Values
Returns a string containing the expanded name of the new current working directory.
Library: acetutil.arx
(acet-file-copy from to [force])
Copy a file.
Arguments
from: Name of file to copy.
to: Name of new file.
force: If provided and non-nil, forces any existing file to be overwritten.
Return Values
Returns T on success.
Note:
This function will not overwrite read-only files. The read-only flag can be cleared with (acet-file-attr).
Library: acetutil.arx
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (2 of 12) [23/03/2005 05:55:49 p.m.]
(acet-file-cwd)
Returns the current working directory.
Return Values
A string containing the current working directory name.
Library: acetutil.arx
(acet-file-dir pattern [attributes] [starting-directory])
Locate files.
Arguments
pattern: A file specification, which may include wildcards and/or a directory name.
attributes: If provided, contains a bitmap of file attributes to match (see (acet-file-attr).
starting-directory: If provided, this function will also search subdirectories for files that match pattern:
(which can also contain a directory name). Uses the current working directory (see (acet-file-cwd)) if a
relative path is provided.
Return Values
A list of matching file names, or nil if no matching files are found.
Library: acetutil.arx
(acet-file-mkdir directory)
Creates a new directory.
Arguments
directory: New directory name.
Return Values
Returns T on success.
Library: acetutil.arx
(acet-file-move from to)
Moves or renames files.
Arguments
from: Original file name or location.
to: New file name or location.
Return Values
Returns T on success.
Library: acetutil.arx
(acet-file-remove filespec [force])
Deletes one or more files.
Arguments
filespec: File specification, which may include wildcards.
force: If provided and non-nil, indicates that even read-only files should be deleted.
Return Values
The number of files removed.
Library: acetutil.arx
(acet-file-rmdir directory)
Changes the current working directory.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (3 of 12) [23/03/2005 05:55:49 p.m.]
Arguments
directory: Name of directory to remove.
Return Values
Returns T on success.
Library: acetutil.arx
Help Functions
(acet-help [topic])
Display a help page.
Arguments
topic: A keyword that identifies the help page to display. If not supplied, the Table of Contents will be
displayed.
Return Values
nil
(acet-help-trap command [topic [file]])
Install a F1 key monitor.
Arguments
command: The name of the command to monitor, as would be passed to (setfunhelp).
topic: The topic name in the help file. If this argument is nil or not supplied, any help trap attached to
command will be released.
file: The name of the help file to use. If not provided, acet.chm is used.
Return Values
T if successful.
Initialization File Functions
(acet-ini-get inifile [section [key [default]]])
Retrieve data from INI file.
Arguments
inifile: Name of the INI file to search.
section: Section name within the INI file.
key: Key name within the section.
default: Default value to return if key cannot be located.
Return Values
The return value depends on the parameters provided. If only inifile is given, this function returns a list
of section names (or nil if inifile cannot be opened). If a section name is given, a list of key names will be
returned. If a key is given, returns the value associated with the key (or default, if the key cannot be
located). Returns nil if no information can be found.
(acet-ini-set inifile section [key [value]])
Write data to INI file.
Arguments
inifile: Name of the INI file to modify.
section: A string containing the name of the section for the given data. If the section does not exist, it
will be created.
key: A string containing the name of the key to be associated with a value. If the key does not exist in
the given section, it will be created. If this parameter is not given, the entire section (including all entries
within the section) will be deleted.
value: A string to be assigned to key. If this parameter is not given, the key will be deleted.
Return Values
T on success.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (4 of 12) [23/03/2005 05:55:49 p.m.]
Registry Functions
(acet-reg-del key [name])
Delete key or value from Registry.
Arguments
key: Key name to delete. Will not delete subkeys.
name: If given, value name to delete.
Return Values
T on success.
(acet-reg-get key [name])
Return value from Registry.
Arguments
key: Key name to retrieve.
name: If given, value name to retrieve.
Return Values
The selected value, or nil if the entry cannot be located.
(acet-reg-prodkey)
Return current product key.
Return Values
The current product key (Registry path for the current installation).
(acet-reg-put key [name value])
Write a Registry key or value.
Arguments
key: Key name to use.
name: If given, value name to write.
value: If given, value to assign to name.
Return Values
T on success.
Selection Set Functions
(acet-ss-drag-move ss pt [prompt] [highlight [cursor]])
Drag a selection set to change location.
Arguments
ss: The selection set to drag.
pt: The base point.
prompt: A message to display before dragging is started.
highlight: If given, causes a rubber-band line to be drawn from pt to the current cursor position while
dragging; this parameter can be nil to draw a rubber-band line in the inverse of the screen color, or
non-nil to draw a highlighted line.
cursor: The cursor form to display while dragging (0=crosshairs, 1=no cursor, 2=target).
Return Values
Normally returns the selected point, but will honor initget settings and can return arbitrary text or
keywords. Returns nil if the dragging operation is aborted.
Note:
The acet-ss-drag-move function does not move the selection set, but allows selection of a new position
while showing how the result will appear.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (5 of 12) [23/03/2005 05:55:49 p.m.]
(acet-ss-drag-rotate ss pt [prompt] [highlight [cursor]])
Drag a selection set to change rotation.
Arguments
ss: The selection set to drag.
pt: The base point.
prompt: A message to display before dragging is started.
highlight: If given, causes a rubber-band line to be drawn from pt to the current cursor position while
dragging; this parameter can be nil to draw a rubber-band line in the inverse of the screen color, or
non-nil to draw a highlighted line.
cursor: Gives the cursor form to display while dragging (0=crosshairs, 1=no cursor, 2=target).
Return Values
The selected rotation value, or nil if dragging is aborted.
Note:
The acet-ss-drag-rotate function does not rotate the selection set, but allows selection of a rotation
value while showing how the result will appear.
(acet-ss-drag-scale ss pt [prompt] [highlight [cursor]])
Drag a selection set to change scale.
Arguments
ss: The selection set to drag.
pt: The base point.
prompt: A message to display before dragging is started.
highlight: If given, causes a rubber-band line to be drawn from pt to the current cursor position while
dragging; this parameter can be nil to draw a rubber-band line in the inverse of the screen color, or
non-nil to draw a highlighted line.
cursor: Gives the cursor form to display while dragging (0=crosshairs, 1=no cursor, 2=target).
Return Values
The selected scale factor, or nil if dragging is aborted.
Note:
The acet-ss-drag-scale function does not scale the selection set, but allows selection of a scaling factor
while showing how the result will appear.
String Functions
acet-str-collate left right [matchCase])
Compare for sort order.
Arguments
left, right: The two strings to compare.
matchCase: If provided and non-nil, indicates that case sensitive comparison should be used. Normally
case is ignored.
Return Values
Returns -1, 0 or 1 to indicate relative sorting order (left < right, left == right and left > right, respectively).
Displays a usage message if either of the first two arguments are not strings.
Note:
The acet-str-collate function uses multibyte comparison appropriate for the current codepage.
(acet-str-equal left right [matchCase])
Compare strings for equality.
Arguments
left, right: The two strings to compare.
matchCase: If provided and non-nil, indicates that case sensitive comparison should be used. Normally
case is ignored.
Return Values
Returns T if the strings are identical, otherwise nil. Also returns nil if either of the first two arguments
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (6 of 12) [23/03/2005 05:55:49 p.m.]
are not strings. Displays a usage message if less than two arguments are supplied.
Note:
The acet-str-equal function uses multibyte comparison appropriate for the current codepage.
(acet-str-find find string [ignoreCase [useRegExp]])
Find substring in string.
Arguments
find: The substring to locate.
string: The string to search.
ignoreCase: If provided and non-nil, indicates that case insensitive comparisons should be performed.
useRegExp: If provided and non-nil, indicates that regular expressions should be used for searching.
This function uses the following definitions for regular expressions:
. Matches any single character.
* Postfix. Preceeding item 0 or more times.
+ Postfix. Preceeding item 1 or more times.
^ Matches empty string at beginning of text.
$ Matches empty string at end of text.
[chars] Matches any character in the given class. If the first character is ^, match any character not in
the given class. A range of character may be specified by first-last, as in [A-Z] to specify upper case
alphabetic characters.
\( Mark the beginning of a subexpression.
\) Mark the end of a subexpression.
\digit Matches a repeat of the text matched earlier by the subexpression inside the nth opening
parenthesis. Subexpressions may also be referenced in replace strings.
Return Values
The 1-based index if found, or nil if not found.
(acet-str-format format [arg ...])
Format a message with embedded arguments.
Arguments
format: A string containing plain text and argument specifiers. Argument insertions appear in the format
string as the percent (%) character followed by an argument number.
arg ...: A list of argument values to be converted and inserted. Only INT, REAL and STR arguments can
be converted. Other argument types must be converted to one of these three. REAL arguments are
converted using the current LUNITS and LUPREC values; you may wish to first use the (angtos) or (rtos)
functions for proper display.
Return Values
A string with appropriate substitutions.
Example
The call:
(acet-str-format "%1/%2 or %2/%1." "one" "two")
will return the string:
"one/two or two/one."
(acet-str-replace find replace string [ignoreCase [useRegExp [count]]])
Replace one substring with another.
Arguments
find: The substring to locate.
replace: The replacement substring.
string: The string to search.
ignoreCase: If provided and non-nil, indicates that case insensitive comparisons should be performed.
useRegExp: If provided and non-nil, indicates that regular expressions should be used for searching.
count: The number of times to perform the replacement in string. If count is zero or not supplied then all
occurrences are replaced.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (7 of 12) [23/03/2005 05:55:49 p.m.]
This function uses the following definitions for regular expressions:
. Matches any single character.
* Postfix. Preceeding item 0 or more times.
+ Postfix. Preceeding item 1 or more times.
^ Matches empty string at beginning of text.
$ Matches empty string at end of text.
[chars] Matches any character in the given class. If the first character is ^, match any character not in
the given class. A range of character may be specified by first-last, as in [A-Z] to specify upper case
alphabetic characters.
\( Mark the beginning of a subexpression.
\) Mark the end of a subexpression.
\digit Matches a repeat of the text matched earlier by the subexpression inside the nth opening
parenthesis. Subexpressions may also be referenced in replace strings.
Return Values
Returns the resultant string with replacements (if any) made.
(acet-str-wcmatch string pattern [matchCase])
Performs a wild-card match similar to (wcmatch), but allows control over case sensitivity.
Arguments
string: The string to search.
pattern: The wildcard pattern to match. See (wcmatch) for details.
matchCase: If provided and non-nil, indicates that case sensitive comparison should be used.
Return Values
T if string and pattern match.
System Functions
(acet-sys-beep sound)
Make a noise.
Arguments
sound: A sound selector value. Can be one of:
-1: Standard beep using computer speaker
0: SystemDefault
16: SystemHand
32: SystemQuestion
48: SystemExclamation
64: SystemAsterisk
Return Values
nil
(acet-sys-command shell-command)
Run a command in a shell. Waits for the shell to complete execution before returning.
Arguments
shell-command: A string containing the command to execute.
Return Values
An integer containing the exit code from the shell command, or -1 on error.
(acet-sys-foreground)
Forces AutoCAD's main window to be the topmost window and to receive focus.
Return Values
nil
(acet-sys-keystate keycode)
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (8 of 12) [23/03/2005 05:55:49 p.m.]
Check state of virtual key.
Arguments
keycode: The code for the virtual key to test.
Return Values
The status of the specified virtual key:
If the high-order bit is 1, the key is down; otherwise, it is up.
If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned
on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the
keyboard will be on when the key is toggled, and off when the key is untoggled.
(acet-sys-lasterr)
Report last error.
Return Values
Returns the error code of the last error encountered by routines in the acetutil library.
(acet-sys-procid)
Returns the current process identifier.
Return Values
The current process identifier.
(acet-sys-sleep msecs)
Delay, allowing other processes to run.
Arguments
msecs: The (minimum) number of milliseconds to release control.
Return Values
nil
Note:
The system may delay the current process for more than the requested amount of time.
(acet-sys-spawn flags command [argument ...])
Execute an external program.
Arguments
flags: A bitmap of flags indicating how the external program should be executed. Supported flags:
1 = wait for the program to complete
2 = run program minimized
command: A string containing the name of the external program.
argument ...: A set of arguments to be passed to the external program.
Return Values
If this function waits for program completion the return value is the exit code from the program,
otherwise the return value is the process ID for the new process. See (acet-sys-term) and
(acet-sys-wait).
(acet-sys-term processID)
Terminate the given process.
Arguments
processID: The process ID of the process to terminate.
Return Values
T on success.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (9 of 12) [23/03/2005 05:55:49 p.m.]
(acet-sys-wait processID [time])
Wait for a process to complete.
Arguments
processID: The process ID for the sub-process.
time If given, the number of milliseconds to wait.
Return Values
The exit code from the given process, or -1 if an error occurred or time expired.
User Interface Functions
(acet-ui-message message [caption [type]])
Displays a message box.
Arguments
message: A text string containing the message to display. Multiple lines may be separated by ' '
characters.
caption: If provided, the caption for the dialog. Defaults to "Error".
type: If provided, a bitmap of various flags used to achieve different effects.
The following type flags are available:
Base types
0 = Acet:OK
1 = Acet:OKCANCEL
2 = Acet:ABORTRETRYIGNORE
3 = Acet:YESNOCANCEL
4 = Acet:YESNO
5 = Acet:RETRYCANCEL
Icons
16 = Acet:ICONSTOP
32 = Acet:ICONQUESTION
48 = Acet:ICONWARNING
64 = Acet:ICONINFORMATION
Default buttons
0 = Acet:DEFBUTTON1
256 = Acet:DEFBUTTON2
512 = Acet:DEFBUTTON3
768 = Acet:DEFBUTTON4
Return Values
Returns one of the following values:
1 = Acet:IDOK
2 = Acet:IDCANCEL
3 = Acet:IDABORT
4 = Acet:IDRETRY
5 = Acet:IDIGNORE
6 = Acet:IDYES
7 = Acet:IDNO
8 = Acet:IDCLOSE
9 = Acet:IDHELP
Library: acetutil.arx
(acet-ui-pickdir [message [startDir [caption]]])
Displays a directory selection dialog.
Arguments
message: If provided, a message to be displayed in the space above the directory tree control.
startDir: If provided, the initial directory to be selected.
caption: If provided, the dialog caption.
Return Values
A string containing the name of the selected directory, or nil if the dialog was canceled.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (10 of 12) [23/03/2005 05:55:49 p.m.]
Library: acetutil.arx
(acet-ui-progress [label [max]])
(acet-ui-progress current)
Display progress meter.
Arguments
label: If provided, a text string that will appear as a label for the progress meter.
max: If provided, the maximum value in the range to be displayed (starting with 0).
current: If provided, gives the current value, which should be less than max; positive values are
absolute while negative values increment the current position.
If no parameters are provided, the progress meter is removed.
Return Values
The return value depends on the action performed:
Initialize: returns T if successful, otherwise NIL.
Update: returns current.
Restore: returns NIL.
Example:
;; init meter
(acet-ui-progress "Working:" (length theList))
;; process each item
(foreach item theList
;; perform action
(doSomethingTo item)
;; update meter by one item
(acet-ui-progress -1)
)
;; kill meter
(acet-ui-progress)
Library: acetutil.arx
(acet-ui-status [message [caption]])
Displays a modeless status dialog.
Arguments
message: If provided, a text string to be displayed in the dialog.
caption: If provided, a text string to be used as the dialog caption.
If no parameters are provided, the dialog is hidden.
Return Values
nil
Note:
The status dialog may be moved by the user. It will remember it's position and contents during the
current session.
Library: acetutil.arx
(acet-ui-txted [text [caption [note]]])
Display a multi-line text editing dialog.
Arguments
text: If provided, a text string to be displayed as the initial contents. Lines can be separated with "\r\n"
sequences.
caption: If provided, text to be used as the dialog caption.
note: If provided, an additional text string to be displayed above the text editing control.
Return Values
A string containing the text contents if the user presses the OK button, or nil if the user presses the
Cancel button.
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (11 of 12) [23/03/2005 05:55:49 p.m.]
Library: acetutil.arx
Utility Functions
(acet-util-ver)
Identify module version.
Return Values
Returns a REAL value containing the current version number of the acetutil.arx library.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
An Introduction to AcetUtil Functions
http://www.afralisp.com/lisp/acet-utils.htm (12 of 12) [23/03/2005 05:55:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Rtext and Drawing Setup
(This may even work with AutoCAD LT)
Note: You must have Express Tools installed within AutoCAD for the examples in this tutorial to
function correctly or to even make sense. Express Tools are installed by default in AutoCAD 2000, 2000i
and 2004 but not in 2002. If you would like Express Tools for AutoCAD 2002, you can install them from
here.
Personally, I believe that Rtext is one of the best functions within the Express Tools Suite.
In this tutorial, we are going to have a look at how Rtext can help us with our drawing setups along with
a few other little things.
Firstly, you need to download this zip file that contains a drawing named "Rtext_Setup.dwg", three
sample Xref drawing files, as well as a text file entitled "Notes.txt".
Place them all in a directory within your AutoCAD support path and then open the drawing
"Rtext_Setup.dwg.
Let's have a look at the Title Block Data. Open up the "Drawing Properties" dialog. (File -> Drawing
Properties). Choose the "Summary" tab. It should look like this :
Change the value of the "Title" edit box. Now choose the "Custom" tab.
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (1 of 6) [23/03/2005 05:55:56 p.m.]
Change a few of the entries in the "Value" edit boxes.
DO NOT change the values in the "Name" edit boxes.
Now, close the "Drawing Properties Dialog, zoom into the title block and Regen the drawing.
Did you see the values in the title block update to suit the changes you made?
Zoom into the lower right of the drawing. You should see this, although I've rotated it for clarity :
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (2 of 6) [23/03/2005 05:55:56 p.m.]
Hey thanks Kenny!!! A lovely little plot stamp. Regen the drawing after a minute or so and watch the
time update automatically.
Now zoom into the lower left corner of the drawing :

This is a list of all the Xrefs that are attached to this drawing. To test it, Detach one of the Xrefs from the
drawing and Regen the drawing. The list will update.
Now open up the text file "Notes.txt" within Notepad and make a few changes to the notes. Save the file
and return to the drawing. Again Regen your drawing, and again watch the notes automatically update.

All of these magic tricks were achieved by using the Rtext function along with a few Diesel expressions.
Let's now have a wee bit of a closer look!!
Reactive text (RText) objects are displayed the same way normal Text or MText objects are displayed,
but the source for the text is either an external text file or the value of a DIESEL expression. You can
edit an RText object with the RTEDIT command.
Command: RTEXT
Current text style: STANDARD Text height: 0.2000 Text rotation: 0
Enter an option [Style/Height/Rotation/File/Diesel] <Diesel>: Specify an option
Options
Style Select a text style.
Height Specify a text height.
Rotation Specify a rotation value.
File Use an external text file.
Diesel Use DIESEL code.
Tip:
Once you have created an RText object with the File option, you can identify the associated text file with
the LIST command.
Note:
If a drawing with an RText object is opened on a computer that does not have RTEXT installed, the
proxy object that results displays the bounding box of the RText object. If you plan to send your
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (3 of 6) [23/03/2005 05:55:56 p.m.]
drawing to someone who does not have RTEXT, you can explode the RText objects to MText objects
with the EXPLODE command.
You can use an RText object as a file reference to display text, such as a sheet note or a legal
disclaimer, that is common to several drawings. You can also use it to display larger bodies of text such
as specifications or assembly instructions.
Here are some examples of how RText objects with DIESEL expressions can be used in your drawings.
To display the drawing name:
Drawing file: $(getvar, "dwgname")
Output:
Drawing file: 102-fp12.dwg
To include the directory path with the file name:
Drawing name: $(getvar, "dwgprefix")$(getvar, "dwgname")
Output:
Drawing file: C:\Projects\97-102\Arch\102-fp12.dwg
Note:
If you reference the drawing path or name in a standard title block, it will always display the file name of
the drawing, even if the title block appears in an Xref file.
When you plot a drawing, you may want the hard copy to show the date and the time that the plot was
created. The following DIESEL expression displays this information in your drawing:
$(edtime, 0, MON DD"," YYYY - H:MMam/pm)
Output:
Mar 22, 2000 - 11:12pm
The $(getprop) DIESEL function
RText supports Drawing Properties through a locally defined $(getprop) DIESEL function. With
$(getprop), values from Drawing Properties dialog box tabs can be extracted and displayed in RText
objects.
The syntax for the $(getprop) DIESEL function is:
$(getprop, property name)
where property name; can be any of the following fields from the DWGPROPS command:
Title
Subject
Author
Comments
Keywords
LastSavedBy
Revno
Custom Property the name of a custom property
For example, if the Drawing Properties for a drawing contains the text "Excavated Site"
is the Subject, the DIESEL expression:
Subject: $(getprop, subject)
in an RText object will display as:
Subject: Excavated Site
Note:
The $(getprop) DIESEL function is supported only in RText objects. Unlike arguments supplied to other
DIESEL functions, arguments to $(getprop) cannot be quoted. Arguments are not case sensitive.
If you have a custom property named "Project Name", the following DIESEL expression will display the
value:
Project: $(getprop, %PROJECT NAME)
Note:
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (4 of 6) [23/03/2005 05:55:56 p.m.]
Errors in using $(getprop), such as improper syntax or bad arguments, will display (GETPROP ERROR).
If a nonexistent custom property name is used, $(getprop) will display an empty string.
The $(xrefs) DIESEL function
RText supports listing Xref files attached to a drawing through the $(xrefs) DIESEL function.
The syntax for the $(xrefs) DIESEL function is:
$(xrefs [, flags [, leader [, trailer]]])
flags A collection of bitflags with the following meanings:
1 = (default) include Xref file name (not exclusive with flag 2)
2 = include Xref block name (not exclusive with flag 1)
4 = don't display file name extension
8 = don't display path
16 = show nesting with additional spacing
leader A text string inserted before each Xref entry.
trailer A text string appended to each Xref entry except the last.
Example:
The RText DIESEL expression:
$(xrefs,3)
displays a list of Xrefs in the following format:
B-ELEC [c:\proj-14\b-elec.dwg]
M-ELEC [c:\proj-14\m-elec.dwg]
R-ELEC [c:\proj-14\r-elec.dwg]
F-ELEC [c:\proj-14\f-elec.dwg]
while the expression:
$(xrefs,2,Includes: )
will list the Xrefs as:
Includes: B-ELEC
Includes: M-ELEC
Includes: R-ELEC
Includes: F-ELEC
The $(images) DIESEL function
RText supports listing images attached to the drawing through the $(images) DIESEL function.
The syntax for the $(images) DIESEL function is:
$(images [, flags [, leader [, trailer]]])
flags A collection of bitflags with the following meanings:
4 = don't display file name extension
8 = don't display path
leader A text string inserted before each Image entry.
trailer A text string added each Image entry except the last one.
Behavior is similar to the $(xrefs) function.
The $(getrec) DIESEL function
RText supports displaying Xrecord data through the $(getrec) DIESEL function.
The syntax for the $(getrec) DIESEL function is:
$(getrec, key, code)
key Entry name in the Named Object Dictionary.
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (5 of 6) [23/03/2005 05:55:56 p.m.]
code Group code to extract.
The $(getrec) function extracts a value from an Xrecord by looking in the Named Object Dictionary for
key, then for a data value associated with code. Currently, only group codes in the ranges 1-9 (string),
40-59 (real), 60-79 (integer) and 300-309 (string) are supported.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Rtext and Drawing Setup
http://www.afralisp.com/lisp/rtext.htm (6 of 6) [23/03/2005 05:55:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and Binaries
By Stig Madsen, 2001
(Revised. December 2002)
This document will try to shed some light on binaries, bitcoded values in AutoCAD and the functions provided by
AutoLISP: logand, logior, lsh and boole.
If you are not familiar with the binary system and conversions between binary and decimal, it is recommended that
you read through the following section. If you don't care for lengthy explanations or are well at home with binaries,
you can skip to the section "Logical operators", and, if that doesn't capture your interest either, then at least read
the section "Masking integers with logical operators".
Decimals and binaries
In the decimal system we have 10 symbols to juggle with. We start counting from 0 to 9 and when we run out of
symbols we simply shift to the left and start all over again to the right increasing the left number whenever we run
out of symbols to the right. When the left number runs out of symbols too we simply shift one more time to the left
and so on. Fortunately this shifting can be represented mathematically by using the power of a base number, in this
case the number that presents itself when we have shifted one time, the number 10. The number of times the array
of symbols (0-9) has been shifted to the left indicates the power in which to raise the number 10. When no shifting
has occurred we are in the place of 10 raised to 0 = 1, also known as the one's place. When shifted once we are in the
place of 10 raised to 1, - known as the ten's place. Next shifting results in 10 raised to 2, which is the hundred's place
and so on. Confusing? Not really because this is the way we were taught to do number crunching from the time the
doctor said, oh look, he came out all right with 10 fingers!
Counting numbers in a decimal system can be converted into "power of base number" notation like this:
0 = 10^0*0 = 0
1 = 10^0*1 = 1
....
9 = 10^0*9 = 9
10 = 10^0*0 + 10^1*1 = 0+10 = 10
11 = 10^0*1 + 10^1*1 = 1+10 = 11
....
20 = 10^0*0 + 10^1*2 = 0+20 = 20
...
99 = 10^0*9 + 10^1*9 = 9+90 = 99
100 = 10^0*0 + 10^1*0 + 10^2*1 = 0+0+100 = 100
101 = 10^0*1 + 10^1*0 + 10^2*1 = 1+0+100 = 101
etc. etc.
It all changed sometime in the late 40's when someone began to mass-produce a number-crunching machine using
only 2 symbols, on and off - or as we like to call it 1 and 0, thereby introducing the binary system to the masses. The
same mathematics controlling the decimal system also applies to the binary system. When we run out of available
symbols we simply shift to the left until running out again, shifting once more and so on. Only difference is that the
binary system uses only 2 symbols, 0 and 1. This means that when shifting one place we have only counted 2 times
thus making our base number 2. So, one shift is 2 raised to 1, two shifts are 2 raised to 2, three shifts are 2 raised to 3
and so on. Illustrating the procedure of counting in a binary system looks like this, starting with 0, and converted
into "power of base number" notation (which, fortunately for computers of flesh and blood, can be used to convert
directly into the decimal system!) :
0 = 2^0*0 = 0
1 = 2^0*1 = 1
10 = 2^0*0 + 2^1*1 = 0+2 = 2
11 = 2^0*1 + 2^1*1 = 1+2 = 3
100 = 2^0*0 + 2^1*0 + 2^2*1 = 0+0+4 = 4
101 = 2^0*1 + 2^1*0 + 2^2*1 = 1+0+4 = 5
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (1 of 6) [23/03/2005 05:55:59 p.m.]
110 = 2^0*0 + 2^1*1 + 2^2*1 = 0+2+4 = 6
111 = 2^0*1 + 2^1*1 + 2^2*1 = 1+2+4 = 7
1000 = 2^0*1 + 2^1*0 + 2^2*0 + 2^3*1 = 0+0+0+8 = 8
1001 = 2^0*1 + 2^1*0 + 2^2*0 + 2^3*1 = 1+0+0+8 = 9
etc. etc.
To convert from decimal to binary is a bit more cumbersome affair than the binary-decimal conversion and it will
be left out here as it isn't all that needed for the purpose of looking at AutoLISP's logical functions. Many fine
books, papers and websites describe the procedure.
As computer parts only know how to deal with power off and power on they use these states for all the tasks they are
capable of doing. Electrical currents running through the circuits of a computer can be alternated and changed in
various ways. The methods of calculating which turns electrical currents shall take within various components are
known as logical operations. By that it becomes possible to apply mathematics to how electrical currents can be
redirected within our machines. The kind of mathematics performed this way is often referred to as Boolean logic or
Boolean algebra.
Each digit of a binary number is in computer-related terms called a bit. As a bit is really a switch describing the
presence or absence of an electrical current it is practical to assemble these switches (bits) into chunks, which can
then be processed as a unit and, much like a genome, can represent a unique transaction within the processing unit.
Naturally this comes in handy for the human on the other side of the output device because once processed, chunks
of these bits can also represent a color on the screen, an entity type in AutoCAD, a pen number, a character or a
number that humans can use.
Bits are assembled into chunks the size of 2^3 bits = 8 bits, also called one byte (also often called one character).
With eight bits a range of 2^8 = 256 different values can be achieved. To describe even more values bytes are joined
together to form different data types - integers ranging 2^16 values (two byte integers) and 2^32 values
(surprisingly, four byte integers), floating decimal numbers with 4 or more bytes etc. etc.
In any case, how long a data type might be, binary numbers are always forming an array of 1's and 0's on which
logical operations can be performed.
Logical operators
Some of the most important logical operators for the purpose of digging into AutoLISP's binary handling are AND,
OR, XOR, NOR and NOT.
The first four operators take as input two bits and return one resulting bit. NOT processes a single bit and returns
the "opposite value" of the bit.
Note: Don't confuse AutoLISP's NOT function with logical NOT. AutoLISP's NOT function merely inspects the
value of an item and returns T if it amounts to nil. In AutoCAD the logical NOT function is ~ .
If the value 1 is considered true and 0 is considered false then a textual description of the operators would be like
this:
AND: returns true only when both input bits are true G
OR: returns true if both or just one of the input bits are true G
XOR: returns true if only one of the input bits is true G
NOR: returns true only when both input bits are false G
NOT: returns true if the input bit is false, otherwise it returns true G
OR is known as inclusive OR (hence the "i" in AutoLISP's function LOGIOR), and XOR is known as exclusive OR.
Applied to what is commonly know as a truth table, the four operators return the values shown below. The two
rightmost columns are input bits and the last column is the output bit. Of course, in the case of NOT there is only
one input bit.
AND: OR:
0 0 = 0 0 0 = 0
0 1 = 0 0 1 = 1
1 0 = 0 1 0 = 1
1 1 = 1 1 1 = 1
XOR: NOR: NOT:
0 0 = 0 0 0 = 1 0 = 1
0 1 = 1 0 1 = 0 1 = 0
1 0 = 1 1 0 = 0
1 1 = 0 1 1 = 0
It is important to point out that these truth tables only process a single bit. While bits are actually processed one by
one in the innermost parts of a computer, it is wrong to assume that the same values will appear when using the
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (2 of 6) [23/03/2005 05:55:59 p.m.]
AutoLISP logical functions. In AutoLISP the NOT operator is in the form of the function (~ int). As seen it takes
only one argument and, more importantly, the argument is an integer - not a single bit. Fire up your AutoCAD and
try it out with a value of 0. According to the truth table it should return 1, but darn, it returns -1! What's
happening?
(~ 0)
-1
As the AutoLISP Help Reference points out, the argument is an integer and earlier we learned that integers consist
of more than one bit. But how can you really talk about true and false in relation to integers? Is 48 true, and is it
more true than 13?
The integer is a specific data type with a fixed number of bits. In AutoLISP integers are 32-bit signed numbers, so
no matter if all 32 bits in an integer are used it will always consist of 32 bits. Consequently the number 0 is also
made up of 32 bits (which all have the value of 0). When you apply a logical operator to an integer, it will run
through every single bit and process it without changing the positions of the bits. The return value will be an integer
with the same amount of bits, but with the bits changed according to the logical operation performed on each bit. In
the case of using the NOT operator on the value 0, here is what happens:
(~ 0) NOT 00000000000000000000000000000000
-1 = 11111111111111111111111111111111
and when supplying the value 1 as an argument:
(~ 1) NOT 00000000000000000000000000000001
-2 = 11111111111111111111111111111110
NOT performs on every single bit reversing their values but preserving their place in the array.
But why is the result negative? Because integers can describe both positive and negative values, the computer has to
know how to tell the difference when looking at an integer. Negative numbers are defined by setting the leftmost bit
to 1 - this bit is called the sign bit. Popular speaking, whenever the computer is given an integer it looks at the sign
bit to determine whether the value is positive (sign bit is 0) or negative (sign bit is 1). Without going deeper into how
this works and why negative numbers aren't just positive numbers with a sign bit, the computer uses a technique
called two's complement allowing it to do arithmetic with both positive and negative values.
For our particular use the most important thing to keep in mind is that AutoLISP's logical operators only work with
integers. Although it may seem that way, this text is not intended to give an in-depth knowledge of how binaries
tumble around in a computer, but solely to give enough background information on how to extract bitcoded values
in AutoLISP and AutoCAD!
Masking integers with logical operators
As seen, logical operators can be used to manipulate integers at bit levels, either investigating or changing any given
bit to suit any need.
Note: While integers are 32 bit long, in the following text every array of bits is representing an integer. For clarity,
and for the sake of my sanity while typing, they are truncated into a single byte. This means that you should pretend
the following integers to be preceded by 24 zeros, so if you see a 1 in the leftmost place it is not a negative value
unless otherwise is specifically stated. The 24 leftmost bits are just left out.
Suppose we have a byte (read: an integer) in which to figure out if a specific bit is set or not. How would we do this?
Simple: the AND operator returns 1 if and only if both input bits are 1. For instance, find out if the 2nd bit of the
number 182 is set ( 2nd bit = 1)?
182 in binary notation is 10110110. When we do an AND operation with this number and a number where only the
2nd bit is set then we will end up either with the second number itself (in case the 2nd bit is set) or with 0 (if the 2nd
bit is not set):
10110110 AND decimal: 182 AND
00000100 = 4 =
00000100 4
If any 1's in the first byte corresponds to 1's in the second byte, they are "transferred" into the return value while
forcing all other bits to 0's. This technique is known as masking. With the AND operation we simply apply an
integer with only those bits set that we want to investigate in the first integer.
Because only one bit was investigated and the resulting number is the same as the number used to mask out the
binary representation of 182 (10110110), we know that the second bit is set. By the way, for the purpose of this text,
bits are indexed from right to left starting with bit 0. In a byte the leftmost bit is therefore bit 7.
The AutoLISP function LOGAND does the logical AND operation for us:
(logior 182 8) 190
In addition to the two required inputs, LOGAND accepts numerous inputs and does an AND operation with all.
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (3 of 6) [23/03/2005 05:55:59 p.m.]
Given the truth table more inputs than 2 will still result in true if and only if all bits in the same place are 1,
example:
(logand 46 182 38 170) 34
In binary notation:
00101110 AND decimal: 46 AND 10110110 AND 182 AND 00100110 AND 38 AND 10101010 = 170 =
00100010 34 Similarly, we can set a specific bit in a number by using the OR operator with a mask containing the
specific bit with a value of 1. Again, using 182 but this time setting the 3rd bit (decimal value 8) in the returned
integer:
10110110 OR decimal: 182 OR 00001000 = 8 = 10111110 190 Corresponding bits that are both 0 are left
alone and any other bits return 1 if either or both bits are 1. In AutoLISP the LOGIOR function performs the
inclusive OR operation:
(logior 182 8) 190 Like LOGAND it can operate with numerous values. Again, according to the truth table it will
return 1 if only one of all the bits in the same place is set:
(logior 46 182 38 170) 190 In binary notation:
00101110 OR decimal: 46 OR 10110110 OR 182 OR 00100110 OR 38 OR 10101010 = 170 = 10111110 190 As stated at
the beginning of this document, AutoLISP provides more logical functions than the 3 seen above and we'll run
through them in the following as we stumble upon them.
Logical operators and AutoCAD
Now, you may think: What a lot of rubbish - good thing I didn't waste time reading all that! Well, go back and study
it, because here is how you can use all these bits and pieces in your code.
Coming across some of the flags used in AutoCAD entities and table entries as described in the DXF References, you
will notice that some of them (e.g. in many cases code 70) are stated to be bit coded, but the flags are listed as
decimal integers. How can that be? This is my best bid: Instead of supplying raw bit-handling functions which
cannot be used anywhere else in AutoLISP, it offers to manipulate the bits using integers and the bit-handling
functions themselves return integers. Because of this you don't have to convert any decimal numbers into binary or
hexadecimal numbers and convert them back again.
This is the reason that the logical operation samples listed above are also shown with decimal values.
If you have an entity in AutoCAD and want to check it for a particular bit coded flag all you have to do is to check if
the flag is "contained" within the value supplied by its entity list structure.
Suppose a bit coded value for an entity has the value of 84, which bits are set? First we need the appropriate
operator. Above we learned that AND can do this for us, that is if A AND B = B then A and B has the same bit set.
All we have to do is to make sure that B only has the bit set that we are looking for.
Because we are talking about bit coded values in AutoCAD we want it to return a list of the possible flags in
decimal: 1, 2, 4, 8, 16, 32, 64 etc. etc. Here's a shot at making a lisp routine to check all bits in a particular value:
(defun findBits (num / i a bitList) (setq i 0 a 1 ) (while (>= num a) (if (= (logand num a) a) (setq bitList (cons a bitList)) )
(setq a (expt 2 (setq i (1+ i)))) ) (reverse bitList) ) Explanation:
Variable a will be our masking number shifting 1 bit each time running through the loop (remember, shifting 1 bit
means increasing the binary number with 2 raised to the power of x, where x is the position of a specific bit (hmmm,
maybe you shouldn't have skipped the first part of this text?). The masking number will take on the value of all the
possible flags as described above while testing a different flag in every loop.
Inside the loop it performs the logical AND operation on the value (num) and the mask (a) determining if the bit in a
is also set in num . If this is true then the particular flag-value is added to a list.
All you have to do to check if a particular flag is present is to compare the flag-value to the list. Say, check for the
flag-value 32 "in" the number 182:
(setq theFlags (findBits 182)) (2 4 16 32 128) Perform the search for flag 32 in the returned list:
(if (member 32 theFlags)(princ "Flag 32 found")(princ "Bummer!")) If you read the first part of this text you will know
that shifting a bit in a binary number is the same as doubling the number each time a shift has occurred. AutoLISP
provides a function, LSH, which shifts a bit either to the left (=increasing) or to the right (=decreasing). LSH stands
for LeftSHift, but if the second argument is negative it will rightshift. The result of calling LSH numerous times
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (4 of 6) [23/03/2005 05:55:59 p.m.]
starting with 1 and shifting 1 place each time looks like this in binary and decimal notation (preceding zero's are
shown for clarity in binary notation):
(setq x 1) (setq x (lsh x 1)) ; set x to x shifted left 1 time number of times binary decimal 0 00000001 1 1 00000010 2 2
00000100 4 3 00001000 8 4 00010000 16 5 00100000 32 etc... (lsh 1 5) ; means leftshift the value 1 five times = 32 (as in
the sequence above) Notice how the bit 1 shifts place doubling the number each time it is shifted? We can use this in
the findBits routine and toss away a variable:
(defun findBits (num / a bitList) (setq a 1) (while (>= num a) (if (= (logand num a) a) (setq bitList (cons a bitList)) ) (setq a
(lsh a 1)) ; increase a with 2^(number of loops) ) bitList ) ... and at the same time we learned something about LSH.
AutoLISP's LSH operates on 32-bit integers and will continue shifting until all 32 bits have shifted. After 31
leftshifts the integer is shifted in again and on the 32nd shift the integer will reemerge - if rightshifting the bits will
fall off the right edge and be lost:
(lsh 190 32) ; returns 190, i.e. the same integer as we started out with 190 (lsh 190 57) ; results in the same number as (lsh
190 (- 57 32)) 2080374784 LSH uses two's complement, which means that if the rightmost bit in the return value is 1
it is regarded as being negative. In the case above where the number 1 is shifted to the left this happens when the bit
has reached the leftmost place in a 32-bit integer (after shifting 31 times). Although (lsh x n) is the same as (* x (expt
2 n)), and (lsh x -n) is equivalent to (fix (/ x (expt 2 n))) be careful when shifting to negative values occur and only use
LSH in well-chosen places.
Anyway, enough about shifting one way or another. We have already seen how to investigate a bit coded value, let's
sum it up with a few useful applications of LOGAND and LOGIOR:
To check if a specific flag is set in a bitcoded integer use the above function or just write a conditional function like
this one:
(defun checkFlag (num flag) (= (logand num flag) flag) ) This functions will return T if flag is set in num, otherwise it
returns nil. We have already seen during the first encounter of LOGAND that if we are masking a value with only
one bit set in the masking value and the returned value comes out as our masking value then we know that the
masked bit is set in the value:
10110110 AND decimal: 182 AND 00000100 = 4 = 00000100 There ya go, 3rd bit in the number 182 is set because
AND returned the masking value. Applied to our newly written function it will look like this:
(checkFlag 182 4) T To check a group code 70 value in e.g. a polyline we could use this sequence:
... (setq entlist (entget (car (entsel "Select a polyline: ")))) ; get the polyline ;; code to check for entity type would go here...
(setq num (cdr (assoc 70 entlist))) ; extract code 70 value (cond ((checkFlag num 1)(princ "Polyline is closed")) ; check the
flags ((checkFlag num 2)(princ "Polyline is curve-fitted)) ;; ... more options go here ((checkFlag num 64)(princ "Entity is a
polyface mesh")) (T nil) ) ... A note on this procedure, though: COND will stop after finding the first flag contained in
the value. To test for more flagvalues don't use COND!
To set a specific flag in a bit coded integer we can use logical OR to mask the bits we want to set. Given OR's truth
table LOGIOR will not affect bits that are already set:
(defun setFlag (num flag) (logior num flag) ) This function will return num with the bits specified in flag turned on, i.e.
changed to 1's. For example, to close a 3D mesh in the M direction set its group code 70 flag to 1 (supposing that
only flag 16 is set indicating the entity is in fact a 3D mesh):
(setFlag num 1) 17 LOGIOR will change all the bits where one or both are 1. This is what happens at bit-level:
00010000 OR decimal: 16 OR 00000001 1 = 00010001 17 Suppose we want to close the mesh in both M and
N direction (flag 1 and 32) and the mesh that we picked is already closed in the N direction (flag 32 is already set):
(setFlag num (+ 1 32)) 49 The following is what happens at bit-level. Notice that the 5th bit (flag 32) is already set
in num and LOGIOR leaves it unchanged because 1 OR 1 = 1:
00110000 OR decimal: 48 OR 00100001 33 = 00110001 49 Now we can use the following sequence to close a
3D mesh in both M and N direction:
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (5 of 6) [23/03/2005 05:55:59 p.m.]
... (setq entlist (entget (car (entsel "Select a 3D mesh: ")))) ;; code to check for entity type would go here...
;; now check if we have a 3D mesh (code 70 should contain the flag 16) ;; using the checkFlag function
from before: (setq num (cdr (assoc 70 entlist))) (if (checkFlag num 16) (setq ent (entmod (subst (cons 70
(setFlag num (+ 1 32))) (assoc 70 entlist) entlist) ) ) (princ "Selected entity is not a 3D mesh") ; if no flag
16 ) ... Note: Always check ENTMOD to see if the operation failed and take the proper action in your code to
ensure that ENTMOD does its job. When altering group code 70 flags like this have in mind that "incompatible"
flag values are common. As an example, a polyline can't both be a 3D mesh and a polyface - therefore the flags 16
and 64 won't show up in a polyline at the same time. Attempts on setting a group code 70 to 16+64 on a polyline with
the code above ENTMOD will not produce a nil return value, but AutoCAD will not set the flags either, so don't
assume that the procedure succeeded. Instead check for success or failure in some other ways; checking the group
code after attempting to change it would be an obvious method.
Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and Binaries - Page I
http://www.afralisp.com/lisp/binary_I.htm (6 of 6) [23/03/2005 05:55:59 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD and Binaries - Page II
Back to Page I
And now to something completely similar: BOOLE
BOOLE is AutoLISP's general function for logical bitwise operations. It can handle 16 Boolean operations for which
only a few I will live to tell about, but it is fairly easy to set up truth tables if you want to explore all the functions.
Otherwise it will be necessary to refer to more specialized literature.
All functions in BOOLE are input as an integer argument. If you don't have the AutoLISP Reference at hand the
syntax for BOOLE is as follows:
(boole operator int1 [int2 ... ]) ; my apologies to the late George Boole for not using capital B The 4 most
common logical operators AND, XOR, OR or NOR has the following integer representations. Please refer to the text
and the truth tables above for an explanation of these operators.
AND 1 XOR 6 OR 7 NOR 8 (boole 1 ...) and (boole 7 ...) performs the same operations as LOGAND and
LOGIOR. As mentioned before, beware that for example NOR does a one's complement on a 16 bit integer and the
truth table when printed out with BOOLE is not the same as making a truth table on a single bit. We can illustrate
this is if doing a NOR operation on a byte - and by the way, A NOR B is the same as NOT(A OR B):
A 00000001 NOR decimal: 1 B 00000000 => 0 A 00000001 OR 1 B 00000000 = 0 00000001 NOT 1 =
11111110 -1 Remember, binary representation of a negative integer is (in popular terms) defined by setting the
leftmost bit to 1, so AutoLISP will regard the result of this equation as being two's complement of 1 = -1.
To try and make a truth table lisp showing all different values of the different BOOLE operators, you could make a
defun like the following. If you would explore this matter even further it is possible to write a decimal-to-binary
conversion routine and really check out the binary values bit for bit (hint: use (expt 2 n) to run through all bits).
(defun nothingButTheTruth (/ a) (defun princline (b n m / x) (setq x (boole b n m)) (cond ((= x -1)(setq x
1)) ((= x -2)(setq x 0))) (princ (strcat "\n" (itoa n) " " (itoa m) " " (itoa x))) ) (setq a 0) (repeat 16 (princ
(strcat "\nOperator: " (itoa a))) (princline a 0 0) (princline a 0 1) (princline a 1 0) (princline a 1 1) (terpri)
(setq a (1+ a)) ) (princ) ) It will produce an output like this:
Operator: 0 0 0 0 0 1 0 1 0 0 1 1 0 Operator: 1 0 0 0 0 1 0 1 0 0 1 1 1 Operator: 2 0 0 0 0 1 0 1 0 1 1 1 0
...etc... Operator: 8 0 0 1 0 1 0 1 0 0 1 1 0 ...etc... ... and so on. A full list of the operators can be found at the end
of this article.
Whether you use BOOLE operators 1 and 7 or you use LOGAND and LOGIOR is indifferent. Of course, in some
specific code where it is needed to offer the operator as a variable only BOOLE will do the job.
Clearing bits in a number can be done in a number of ways. For example, clearing the 4th bit with AND in the
number 48 could be done like this:
(logand 48 -17) 32 Why exactly use -17 as the masking value?, Well, looking at it bit-wise this is what takes place:
00110000 AND decimal: 48 AND 11101111 -17 = (have in mind that integers are 32 bit and not 8 bit long) 00100000 32
We simply take advantage of the fact that AND clears all bits if they arent both 1s. Of course, this can be done in a
more obvious and especially a much more useful way when using logical NOT to inverse the flag we want to mask
with:
AutoCAD and Binaries Page II
http://www.afralisp.com/lisp/binary_II.htm (1 of 5) [23/03/2005 05:56:05 p.m.]
(logand (48 (~ 16))) 32 00010000 NOT decimal: 16 NOT 11101111 AND -17 AND (again, have in mind that
integers are 32 bit and not 8 bit long) 00110000 = 48 = 00100000 32 Does this seem confusing? You betcha. Why not take
advantage of the facts that LOGAND returns 0 if the bit value we're searching for is not present in the integer, and
it returns the bit value itself if it is present in the integer? This means we can simply subtract LOGAND's return
value from the integer itself:
(- 48 (logand 48 16))
32

For bits that are not set in the integer, LOGAND will return 0 which doesn't harm the output. For example, the 4th
bit in the integer 47 is not set (in 47 bits 0, 1, 2, 3 and 5 are all set, but not bit 4), thus LOGAND will return 0 in this
case:
(- 47 (logand 47 16)) 47 So, clearing a bit with LOGAND is easily done by subtracting (logand num bit) from num.
If clearing more than 1 bit from an integer, we can simply add together the bit values. For example, to clear the bits
0, 2 and 3 (i.e. the integer bitvalues 1, 4 and 8) from 47:
(- 47 (logand 47 (+ 1 4 8))) 34 Now we can define a simple function that clears a bit from an integer:
(defun clearBit (num flag) (- num (logand num flag)) ) If we look at the truth tables returned by BOOLE in the
function nothingButTheTruth above, it becomes obvious that BOOLEs operator number 2 also can do the job for us.
It returns true if and only if the first bit is 1 and the second bit is 0:
(defun clearBit (num flag) (boole 2 num flag) ) This function will perform exactly the way as the previous
clearBit function with LOGAND. It returns num with the flag value or values cleared indicated by argument flag.
For instance:
(clearBit 48 16) 32 00110000 BOOLE 2 decimal: 48 BOOLE 2 00010000 16 = 00100000 32 and
(clearbit 47 (+ 1 4 8)) 34 For both functions, it is important that the order of arguments be obeyed. (clearBit 16
48) is not the same as (clearBit 48 16). This may seem like a trivial point, but when dealing with LOGAND and
LOGIOR where order of arguments is as indifferent as in arithmetic addition, it should be mentioned.
By the way, to clear all bits you can use the maximum integer 2147483647, or as returned by the expression (~ (expt
2 31)). This is only superficial information, though, because it is much easier just to set the value to 0!
BOOLE operators
Not that it comes up often when programming in AutoLISP (far from it), but when wanting a particular logical
operation besides NOT (logical), LOGAND and LOGIOR it will sometimes be necessary to use BOOLE. Either in
one operation or as nested operations. In any case it would be much desired if the various operators could be
documented in a more precise way than Autodesk has done it. So heres a list of all 16 operators!
Where the operation can be expressed by logical formulas, these formulas are shown in LISP style format but with
standard operator names. These names are NOT to be confused with AutoLISP functions. Where order is essential,
the first input bit is always called A and the second is called B as shown in the truth tables.
Operator 0: NULL
A B Out
0 0 0
0 1 0
1 0 0
1 1 0
NULL operator. Also called CLEAR as it clears all inputs no matter the input bits.
Operator 1: AND
A B Out
0 0 0
AutoCAD and Binaries Page II
http://www.afralisp.com/lisp/binary_II.htm (2 of 5) [23/03/2005 05:56:05 p.m.]
0 1 0
1 0 0
1 1 1
This operator is the same as the AutoLISP function LOGAND.
Operator 2: AND-2 (in Common LISP called BOOLE-ANDC2)
A B Out
0 0 0
0 1 0
1 0 1
1 1 0
(AND A (NOT B))
Operator 3: Only A (in Common LISP called BOOLE-1)
A B Out
0 0 0
0 1 0
1 0 1
1 1 1
(OR (AND A B) (AND A (NOT B))) = A. This operator returns only first input bit.
Operator 4: AND-1 (in Common LISP called BOOLE-ANDC1)
A B Out
0 0 0
0 1 1
1 0 0
1 1 0
(AND (NOT A) B)
Operator 5: Only B (in Common LISP called BOOLE-2)
A B Out
0 0 0
0 1 1
1 0 0
1 1 1
(OR (AND A B) (AND (NOT A) B)) = B. This operator returns only second input bit.
Operator 6: XOR (also called Exclusive OR)
A B Out
0 0 0
0 1 1
1 0 1
1 1 0
Exclusive OR can be constructed with this equation: (OR (AND A (NOT B))(AND (NOT A) B))
Operator 7: OR (also called Inclusive OR)
A B Out
0 0 0
0 1 1
1 0 1
1 1 1
(OR A B). This operator is the same as the AutoLISP function LOGIOR.
Operator 8: NOR (also sometimes referred to as NOT-OR)
A B Out
0 0 1
0 1 0
AutoCAD and Binaries Page II
http://www.afralisp.com/lisp/binary_II.htm (3 of 5) [23/03/2005 05:56:05 p.m.]
1 0 0
1 1 0
(NOT (OR A B))
Operator 9: XNOR (also called Exclusive NOR)
A B Out
0 0 1
0 1 0
1 0 0
1 1 1
(OR (AND A B) (AND (NOT A)(NOT B)))
Operator 10: NOT B (also known as Inverting buffer for second bit)
A B Out
0 0 1
0 1 0
1 0 1
1 1 0
(NOT B). This operator discards first input put and only returns the inverted second input bit. In Common LISP it
is called BOOLE-C2.
Operator 11: ? (in Common LISP called BOOLE-ORC2)
A B Out
0 0 1
0 1 0
1 0 1
1 1 1
(OR A (NOT B))
Operator 12: NOT A (also known as Inverting buffer for first bit)
A B Out
0 0 1
0 1 1
1 0 0
1 1 0
(NOT A). This operator discards second input put and only returns the inverted first input bit. In Common LISP it
is called BOOLE-C1.
Operator 13: ? (in Common LISP called BOOLE-ORC1)
A B Out
0 0 1
0 1 0
1 0 1
1 1 1
(OR (NOT A) B)
Operator 14: NAND (sometimes referred to as NOT-AND)
A B Out
0 0 1
0 1 1
1 0 1
1 1 0
(NOT (AND A B))
Operator 15: SET (also known as Identity)
A B Out
0 0 1
0 1 1
AutoCAD and Binaries Page II
http://www.afralisp.com/lisp/binary_II.htm (4 of 5) [23/03/2005 05:56:05 p.m.]
1 0 1
1 1 1
This operator has no formula derived from other logical operations it merely disregards any input bits and returns
a set bit.
To wrap it up...
With this document it's my hope that the use of bit coded values in AutoCAD and to investigate, extract and alter
them with AutoLISP is somewhat covered and, more importantly, explained adequately to make use of the topics in
a practical way.
If you still want to explore and manipulate for example group code 70 values but you absolutely refuse to use logical
operators then you could begin to explore the ActiveX functionality, either in VLISP or VBA. Using ActiveX, the
properties of an entity are given by named constants, but that is the only thing said on that matter in this document.
AutoCAD & Binaries MS Word format.
AutoCAD & Binaries PDF format.
To reserve the right to use this document as it is in later context such as publications or otherwise, it is hereby copyrighted
by 2001 Stig B. Madsen
Feel absolutely free to use any part of or all of the techniques and code described in this document, unaltered or altered to
suit any need. The programmatic solutions and descriptions are by no means copyrighted by the author - only use of the
textual document as a singularity is a right hereby reserved solely by the author.
If you should happen to claim any copyright to material in this document, then by all means claim it by letting me know.
But please have in mind that the AutoLISP functions described here are as close to bare-boned AutoLISP as possible, that
the number of solutions given to each of the above discussions are limited and that they probably already are declared
copyrighted by hundreds of authors who included them in similar routines worldwide :-)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD and Binaries Page II
http://www.afralisp.com/lisp/binary_II.htm (5 of 5) [23/03/2005 05:56:05 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
A Look at Plan
by Glenn Ryan
Do not think it is used in 3d only. In fact, 99.9% of drawings are still 2d, mine included, and I use the plan command in 2d dwgs, not
3d. It's particularly useful for road layouts.
Imagine you had a road centreline that was going from bottom left of screen to top right. Now when producing road alignment
drawings, paperspace generally has a viewport showing the road in plan (just a term, not related to PLAN command at the
moment), and another viewport looking at the long section along the road centreline in modelspace. This long section is usually
spat out of a design program like Mx.
We'll concern ourselves with just the view of the road not the long section. Now, to use space efficiently in the drawing layout, you
would want to show the road going as close to horizontal across your layout (close meaning if it's curved then take best fit), so you
could fit the most amount of road metreage in the view. You can accomplish this by using the UCS and PLAN commands. What
Plan
http://www.afralisp.com/lisp/plan.htm (1 of 7) [23/03/2005 05:56:11 p.m.]
follows is what I teach in my advanced classes.
All the steps following are in metric by the way, but the principle is still the same. First of all setup a layout with title block and what
not. Then cut your main viewport that's going to show the top view of the road like so:
Notice that the coordinate system in the viewport is still WCS as denoted by the icon.
Next thing is to decide what scale you would like to show the road at - a typical scale being 1:500. Now this is where people start to
get lost in viewport scales, because what I'm doing here is not only done in mteric but also in METRES. That means paperspace
plot scale is in millimetres, but model is drawn at 1 unit = 1 metre. This is common practice in the metric system with civil. In effect
my road model is 1000 times smaller that the equivalent millimetres drawing (if a structures person had done it for instance).
If the people in the class are really with it and are advanced, not just attending the class, then I explain the next method, otherwise I
just explain UCS and PLAN command for view twisting.
I then put a rectangualr poly over the top of the viewport, then make a block of it with an insertion usually mid left or sometimes
mid left but offset towards right. This block is then measured along the centreline poly of the road at the correct scale. So, if the
drawing was in millimetres the viewport scale is a straight 1/500xp which is 0.002, but seeing as we're in METRES the scale works
out to this 1/ (500/1000) = 1/0.5 = 2xp.
Now that we have that knowledge, we can make our block at 0.5 scale (1:500m), then flip to model and use the measure command
with sub command of block, to place the block along the poly like so:
Plan
http://www.afralisp.com/lisp/plan.htm (2 of 7) [23/03/2005 05:56:11 p.m.]
Some of the blocks will need to be manually rotated but that's no big deal. Now, while still in model tab, rotate the UCS about the z
axis to match the alignment of the first block:
Plan
http://www.afralisp.com/lisp/plan.htm (3 of 7) [23/03/2005 05:56:11 p.m.]
Now that we have the UCS rotated to where we want it, just issue the PLAN command and hit enter for the default of current, so we
end up with the drawing looking like so:
Plan
http://www.afralisp.com/lisp/plan.htm (4 of 7) [23/03/2005 05:56:11 p.m.]
Now what I do is save a view of the desired block. I do this in the view command by defining a window and pick bottom left and top
right of the block. Now we flip back to paperspace, jump into our viewport and issue the VIEW command and restore our view to
the viewport and voila, the viewport is scaled correctly and rotated like so:
Plan
http://www.afralisp.com/lisp/plan.htm (5 of 7) [23/03/2005 05:56:11 p.m.]
This is the inherent beauty of using views - they preserve they're UCS (if ticked in view dialog), but more importantly their viewtwist
angle. Then you just repeat the process for as many blocks and layouts you want in this dwg. Of course I would have road model
as xref and have separate dwg file for each plan layout I wanted, but the principle is the same. When you get the hang of it, it's a
very fast way to layout a series of dwg's.
A cautionary note: If you ever want to id points in the model (as it would have been surveyed on coord system) make sure to reset
your UCS to WORLD before doing so, otherwise coords will be wrong.
if you want to reset your view to WCS plan, just enter UCS then hit enter for default of world. Next use PLAN command and hit
enter for default of current ucs (WCS in this case) and you're back to plan view WCS.
The only other command I use in this process is the view sub option of UCS. It will realign your UCS so that XY plane is perp. to
viewing direction:
View :
Establishes a new coordinate system with the XY plane perpendicular to your viewing direction (parallel to your screen). The
UCS origin remains unchanged.
G
You would typically do this if you had changed to WCS in viewport for some reason, but then wanted to put some text in
horizontally - like a note. UCS then V and you're away again.
I hope this has explained the UCS and PLAN commands a bit for you. PLAN generally sets the VIEWTWIST angle.

Plan
http://www.afralisp.com/lisp/plan.htm (6 of 7) [23/03/2005 05:56:11 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Plan
http://www.afralisp.com/lisp/plan.htm (7 of 7) [23/03/2005 05:56:11 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp Editor - The Beginning
Have you ever wondered where the Visual Lisp Editor came from?
Would you like a copy of the original standalone Visual Lisp Editor?
Are you still using R14 (or even R12 of R13) and don't have the Visual Lisp Extensions?
Then you've come to the right place.
The original Visual Lisp Editor is cracker of an application. Small in size (202KB), easy to use AND you
don't have to have AutoCAD installed to use it.
Find Closed Paren
This command will find the closing parenthesis of any statement in an AutoLISP routine. It will
also tell you if there is no closing parenthesis to the chosen statement.
G
Format Lisp
This command will format an existing document or a document you are working on according to
the depth of nesting you have written.
G
Function Master
Using this command will bring up a dialog box that allows you to have a listing of every AutoLISP
function that was currently available at the time (1993).
G
Variable Master
Using this command will bring up a dialog box that allows you to have a listing of every variable
you have used so far in a program.
G
Download "Visual Lisp - The Beginning"
Don't worry, It's FREE.

Visual Lisp Editor - The Beginning


http://www.afralisp.com/vl/vlisp.htm (1 of 2) [23/03/2005 05:56:15 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp Editor - The Beginning
http://www.afralisp.com/vl/vlisp.htm (2 of 2) [23/03/2005 05:56:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Using the Visual Lisp Editor
This tutorial is a crash course in using the Visual Lisp Editor, and is not intended to be detailed or
fully comprehensive. The aim is to show you the main functions of the Editor with the intention of
getting you up and running as quickly as possible.
Right, enough waffle, let's get started. Fire up AutoCAD and open a new drawing.
Now choose "TOOLS" - "AUTOLISP" - "VISUAL LISP EDITOR".
The Visual Lisp Editor will open and should look like this :
Let's start off by having a look at the Console Window :
The VLISP Console window is similar in some respects to the AutoCAD Command window, but
has a few extra features. You enter text into the Console window following the Console prompt
Using the Visual Lisp Editor
http://www.afralisp.com/vl/vl-edit.htm (1 of 4) [23/03/2005 05:56:21 p.m.]
which looks like this :
_$
Type this in the Console prompt and then press "Enter" :
_$ (setq a "Test")
Now type this and again press "Enter" :
_$ a
Your Console window should look like this :
To view the value of a variable at the AutoCAD Command prompt, you must precede the variable
name with an exclamation mark. ( ! ) In VLISP, you simply type the variable name.
Unlike the AutoCAD Command window, where pressing SPACEBAR causes expression
evaluation, text input at the VLISP Console prompt is not processed until you press
ENTER. This permits you to do the following in the Console window:
Continue an AutoLISP expression on a new line. To continue entering an
expression on a new line, press CTRL +ENTER at the point you want to continue.
G
Input more than one expression before pressing ENTER. VLISP evaluates each
expression before returning a value to the Console window.
G
If you select text in the Console window (for example, the result of a previous
command or a previously entered expression), then press ENTER, VLISP copies the
selected text at the Console prompt.
G
The VLISP Console window and the AutoCAD Command window differ in the way they
process the SPACEBAR and TAB keys. In the VLISP Console window, a space plays no
special role and serves only as a separator. In the AutoCAD Command window, pressing
the SPACEBAR outside an expression causes AutoCAD to process the text immediately,
as if you had pressed ENTER.
Using the Console Window History
You can retrieve text you previously entered in the Console window by pressing TAB
while at the Console prompt. Each time you press TAB, the previously entered text
replaces the text at the Console prompt. You can repeatedly press TAB until you cycle
through all the text entered at the Console prompt during your VLISP session. After
youve scrolled to the first entered line, VLISP starts again by retrieving the last
command entered in the Console window, and the cycle repeats. Press SHIFT + TAB to
scroll the input history in the opposite direction. For example, assume you entered the
following commands at the Console prompt:
(setq origin (getpoint "\nOrigin of inyn sign: "))
(setq radius (getdist "\nRadius of inyn sign: " origin))
(setq half-r (/ radius 2))
(setq origin-x (car origin))
(command "_.CIRCLE" origin radius)
Using the Visual Lisp Editor
http://www.afralisp.com/vl/vl-edit.htm (2 of 4) [23/03/2005 05:56:21 p.m.]
To retrieve commands entered in the Console window
1 Press TAB once. VLISP retrieves the last command entered and places it at the Console
prompt:
_$ (command "_.CIRCLE" origin radius)
2 Press TAB again. The following command displays at the Console prompt:
_$ (setq origin-x (car origin))
3 Press TAB again. VLISP displays the following command:
_$ (setq half-r (/ radius 2))
4 Now press SHIFT+ TAB . VLISP reverses direction and retrieves the command you
entered after the previous command:
_$ (setq origin-x (car origin))
5 Press SHIFT+ TAB again. VLISP displays the following command:
_$ (command "_.CIRCLE" origin radius)
This was the last command you entered at the Console prompt.
6 Press SHIFT+ TAB again. Because the previous command retrieved was the last
command you entered during this VLISP session, VLISP starts again by retrieving the
first command you entered in the Console window:
_$ (setq origin (getpoint "\nOrigin of inyn sign: "))
Note that if you enter the same expression more than once, it appears only once as you
cycle through the Console window input history. You can perform an associative search
in the input history to retrieve a specific command that you previously entered. To
perform an associative search of the Console input history
1 Enter the text you want to locate. For example, enter (command at the Console prompt:
_$ (command
2 Press TAB. VLISP searches for the last text you entered that began with (command:
_$ (command "_.CIRCLE" origin radius)
If VLISP does not find a match, it does nothing (except possibly emit a beep). Press
SHIFT+ TAB to reverse the direction of the associative search and find progressively
less-recent inputs.
Interrupting Commands and Clearing the Console Input Area
To interrupt a command entered in the Console window, press SHIFT + ESC. For
example, if you enter an invalid function call like the following:
_$ ((setq origin-x (car origin)
((_>
Pressing SHIFT + ESC interrupts the command, and VLISP displays an "input discarded"
message like the following:
((_>; <input discarded>
_$
If you type text at the Console prompt, but do not press ENTER, then pressing ESC
clears the text you typed. If you press SHIFT + ESC, VLISP leaves the text you entered in
the Console window but displays a new prompt without evaluating the text.
If you type part of a command at the Console prompt, but activate the AutoCAD window
Using the Visual Lisp Editor
http://www.afralisp.com/vl/vl-edit.htm (3 of 4) [23/03/2005 05:56:21 p.m.]
before pressing ENTER, VLISP displays a new prompt when you next activate the VLISP
window. The text you typed is visible in the Console window history, so you can copy
and paste it, but you cannot retrieve the text by pressing TAB , because it was not added
to the Console history buffer.

Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Using the Visual Lisp Editor
http://www.afralisp.com/vl/vl-edit.htm (4 of 4) [23/03/2005 05:56:21 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Using the Visual Lisp Editor (cont)
Right, enough messing about. Let's load some coding. Choose "File" - "New" and then
copy and paste this coding into the text editor :
(defun C:SLOT ( )
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq oldsnap (getvar "OSMODE"))
(setq diam (getdist "\nSlot Diameter : ")
lngth (getdist "\nSlot Length : "))
(while
(setq pt1 (getpoint "\nInsertion point: "))
(setvar "OSMODE" 0)
(setq pt2 (polar pt1 0.0 (/ (- lngth diam) 2.0))
pt3 (polar pt2 (/ pi 2.0) (/ diam 4.0))
pt4 (polar pt3 pi (- lngth diam))
pt5 (polar pt4 (* pi 1.5) (/ diam 2.0))
pt6 (polar pt5 0.0 (- lngth diam)))
(command "PLINE" pt3 "W" (/ diam 2.0) "" pt4
"ARC" pt5 "LINE" pt6 "ARC" "CLOSE")
(setvar "OSMODE" oldsnap)
);while
(princ)
);defun
(princ)
The coding should look like this in the text editor :
Using the Visual Lisp Editor II
http://www.afralisp.com/vl/vl-edit1.htm (1 of 4) [23/03/2005 05:56:27 p.m.]
Before we go any further, let's have a wee chat about the colors.
As soon as you enter text in the VLISP Console or text editor windows, VLISP attempts to
determine if the entered word is a built-in AutoLISP function, a number, a string, or some
other language element. VLISP assigns every type of element its own color. This helps
you detect missing quotes or misspelled function names. The default color scheme is
shown in the following table.
AutoLISP Language Element Color
Built-in functions and protected
symbols
Blue
Strings Magenta
Integers Green
Real numbers Teal
Comments Magenta, on gray background
Parentheses Red
Unrecognized items (for example,
user variables)
Black
You can change the default colors. But, do yourself a favour. Don't!!
Selecting Text
The simplest method to select text is to double-click your left mouse button. The amount
of text selected depends on the location of your cursor.
If the cursor immediately precedes an open parenthesis, VLISP selects all the
following text up to the matching close parenthesis.
G
If the cursor immediately follows a close parenthesis, VLISP selects all preceding G
Using the Visual Lisp Editor II
http://www.afralisp.com/vl/vl-edit1.htm (2 of 4) [23/03/2005 05:56:27 p.m.]
text up to the matching open parenthesis.
If the cursor immediately precedes or follows a word, or is within a word, VLISP
selects that word.
G
Hint : Would you like help on any AutoLisp function? Double-click on the function name
to select it, and then select the "Help" toolbar button. Help for the specific function will
be displayed.
To load the "Slot" lisp routine, select the "Load active edit window" toolbar button :
This loads your coding into memory. To run the routine, type this at the Console prompt :
_$ (c:slot)
The program should now run, switching over to the AutoCAD screen when required. You
can also just run a selection of code if you desire. Select the lines of code you would like
to run and choose the "Load selection" toolbar button, and then press "Enter."
Only the lines of code you selected will be run, Great for debugging.
Talking about debugging, Place the cursor in front of the (defun C:SLOT () statement and press
"F9". This places a "Breakpoint" into your program. Now run the program again. Execution
should stop at the Breakpoint mark. Now press "F8". By continuously pressing "F8" you can
"single step" through your whole program :
Let's go one step further. Select the "diam" variable and then select the "Add Watch" toolbar
button :
The "Watch" dialog box will appear :
Using the Visual Lisp Editor II
http://www.afralisp.com/vl/vl-edit1.htm (3 of 4) [23/03/2005 05:56:27 p.m.]
Note how the variable "diam" is listed along with it's present value. Repeat this process for all the
other variables until the Watch" dialog looks like this :
Now run the program again, still "single" stepping through. Notice how the values of the variables
change as the program proceeds.
O.K. let's liven things up a bit. Select "Ctrl-Shift-F9" to clear all breakpoints. Now select the
"Debug" pull down menu and then "Animate". Now run the program again.
Hey, it's running automatically!!! Take note of the variables changing in the "Watch" window as
the program does it's thing.
Well that's about it in regards to the Visual Lisp Editor. The editor has a lot more functions than
I've shown you here, but these I feel, are some of the more important ones to get you started.
Home. Page I.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Using the Visual Lisp Editor II
http://www.afralisp.com/vl/vl-edit1.htm (4 of 4) [23/03/2005 05:56:27 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
The Beginning.
So, you want to start coding using Visual Lisp? Two things. First you really need to have a good
understanding of AutoLisp before you carry on with this Tutorial. VLisp is not an replacement for
AutoLisp, it is an extension to it. Standard AutoLisp is used extensively throughout Visual Lisp, so
a good knowledge is a necessity. Secondly, in this tutorial I am not going to delve deep into the
why's and where's of VLisp. The intention is to give you a basic grounding into what VLisp can do
and how to go about doing it. For example, some of my terminology may not be technically correct
as I've tended to convert some things to layman terms for clarity and ease of understanding. Don't
worry, we'll correct all that in future tutorials.
O.K. are you ready to start? Right, fire up AutoCAD with a blank drawing and open the Visual
Lisp Editor. You can write Visual Lisp using Notepad just like AutoLisp if you wish, but I prefer to
use the Visual Lisp Editor as we can, and will, use the "Watch" and the "Inspect" windows.
Close the Editor window, leaving the "Console" window open, and then open the "Watch" window.
Right, we're ready to start.
Type this at the Console prompt and then press enter :
_$ (vl-load-com)
Did you notice that nothing happened? Before you can use the VLisp functions with AutoLisp, you
need to load the supporting code that enables these functions. The (vl-load-com) function first
checks if the VLisp support is already loaded; if so, the function does nothing. If the functions are
not loaded, (vl-load-com) loads them. Pretty important I would say!
"All applications that use Visual Lisp should begin by calling (vl-load-com). If (vl-load-com) is not
loaded, the application will fail."
After loading the Visual Lisp functions, the next step is to establish communication with the
AutoCAD Application object.
Think of a filing cabinet. The cabinet itself is your computer and one of the filing cabinet drawers is
AutoCAD. We are going to open the AutoCAD drawer to have a look at what is inside.
To establish this connection, we use the (vlax-get-acad-object) function.
Type this at the Console prompt and then press enter :
_$ (setq acadObject (vlax-get-acad-object))
Now, double click on the variable "acadObject" in the Console window to select it, and then add it
to the "Watch" window. It should look something like this :
The Beginning I
http://www.afralisp.com/vl/vlbegin1.htm (1 of 4) [23/03/2005 05:56:34 p.m.]
We are now looking at the Acad Application object. Double click on the "ACODBJECT" in the
"Watch window to open the "Inspect" window :
This is a list of all the Objects within the AutoCAD Application Object.
Now double click on <Preferences> :
This is all the Objects within the AutoCAD - Application - Preferences object . Now double click on
<Files> :
The Beginning I
http://www.afralisp.com/vl/vlbegin1.htm (2 of 4) [23/03/2005 05:56:34 p.m.]
Compare this list with what you see when you open the Options-Files Dialog :
Pretty much the same hey? On the next page we'll have a look at how we can access these Objects
programatically.
Home. Page II. Page III.
The Beginning I
http://www.afralisp.com/vl/vlbegin1.htm (3 of 4) [23/03/2005 05:56:34 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Beginning I
http://www.afralisp.com/vl/vlbegin1.htm (4 of 4) [23/03/2005 05:56:34 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page III.
The Beginning - Page II.
Before we start this section, I think it might be a good idea if you pop along and have a look at the
AutoCAD Object Model. In fact, print it out and have it next to you as you work through these
tutorials. It's just like having a road map.
Anyway, where were we? Oh, yes. We are now going to try and extract the AutoCAD Support Path
from the Object Model using VLisp. We'll take it right from the top just in case you got a bit lost.
Here we go. Type all of the following statements into the Console window, pressing "Enter" after
each one :
(The lines in red are what VLisp returns, don't type them!)
Load the VLisp support
_$ (vl-load-com)
Store a reference to the Application Object
_$ (setq acadObject (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00adc088>
Store a reference to the Preferences Object
_$ (setq prefsObject (vlax-get-property acadObject 'Preferences))
#<VLA-OBJECT IAcadPreferences 018adfdc>
Store a reference to the Files Object
_$ (setq tabnameObject (vlax-get-property prefsObject 'Files))
#<VLA-OBJECT IAcadPreferencesFiles 018adfc0>
Get the Support Path
_$ (setq thePath (vlax-get-property tabnameObject 'SupportPath))
"D:\\ACAD2000\\SUPPORT;D:\\ACAD2000\\FONTS;
D:\\ACAD2000\\HELP;D:\\ACAD2000\\EXPRESS"
"Jings, that's great, but can we add a new directory to our Support Path?"
Of course we can, but first we need to add our new path to the existing path variable. What should
we use? Easy, let's just use the (strcat) function :
_$ (setq thePath (strcat thePath ";" "C:\\TEMP"))
"D:\\ACAD2000\\SUPPORT;D:\\ACAD2000\\FONTS;
D:\\ACAD2000\\HELP;D:\\ACAD2000\\EXPRESS;C:\\TEMP"
We've added the new directory to the Support Path variable, so now let's update it.
Type in this line:
_$ (vlax-put-property tabnameObject 'SupportPath thePath)
nil
Now, return to AutoCAD and go to "Tools" - "Options" - "Files" - "Support Search Path". Your
new directory, C:/TEMP, should have been added to your Support Path. Dead easy Hey? This Vlisp
stuff is easy!!!
Right, we've opened the filing cabinet AutoCAD drawer (the Application Object) and had a look at
the characteristics of that drawer. Now we need to delve into the drawer and have a look at one of
The Beginning II
http://www.afralisp.com/vl/vlbegin2.htm (1 of 4) [23/03/2005 05:56:38 p.m.]
the document folders stored inside.
_$ (vl-load-com)
_$ (setq acadObject (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00adc088>
Store a reference to the Active Document. (the drawing you fool!)
_$ (setq acadDocument (vla-get-ActiveDocument acadObject))
#<VLA-OBJECT IAcadDocument 00ee0f84>
Double click to select the variable "acadDocument" and add it to the "Watch" Window :
Now double click on "ACADDOCUMENT" Object.
Wow, look at all that! Now double click on <Layers> :
The Beginning II
http://www.afralisp.com/vl/vlbegin2.htm (2 of 4) [23/03/2005 05:56:38 p.m.]
Ha, we've now drilled down to all the layers contained in the drawing. In other words, the "Layers
Collection".
"Alright, that's great," I can hear you say, "I can see that there are 13 layers in this drawing, but
where are the layers? Right enter this :
_$ (vl-load-com)
_$ (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00ee0f84>
_$ (setq theLayers (vla-get-layers acadDocument))
#<VLA-OBJECT IAcadLayers 018aee84>
We are now proud owners of all the layers in this particular drawing. Would you like to have a wee
look at them? Just be very careful and don't drop them!
Enter the following at the Console prompt, pressing "Ctrl" then "Enter" after each line. After the
final line, the closing parenthesis, press "Enter" :
_$ (setq i 0)
(repeat (vla-get-count theLayers)
(setq aLayer (vla-item theLayers i))
(princ (vla-get-name aLayer))
(terpri)
(setq i (1+ i))
)
All the layer names in your drawing should be listed. Mine looks like this :
0
1
2
3
4
5
6
7
8
9
10
12
DEFPOINTS
Would you like to have a closer look at one of the layers in your drawing? Then type this :
(setq aLayer (vla-item theLayers "2"))
#<VLA-OBJECT IAcadLayer 018aeec4>
We have now accessed Layer "2" from the Layers Collection. Let's list all the properties and
methods of this Layer :
_$ (vlax-dump-object aLayer T)
; IAcadLayer: A logical grouping of data, similar to transparent acetate overlays on a drawing
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00adc088>
The Beginning II
http://www.afralisp.com/vl/vlbegin2.htm (3 of 4) [23/03/2005 05:56:38 p.m.]
; Color = 2
; Document (RO) = #<VLA-OBJECT IAcadDocument 00ee0f84>
; Freeze = 0
; Handle (RO) = "40"
; HasExtensionDictionary (RO) = 0
; LayerOn = -1
; Linetype = "DASHED2"
; Lineweight = -3
; Lock = 0
; Name = "2"
; ObjectID (RO) = 21872128
; ObjectName (RO) = "AcDbLayerTableRecord"
; OwnerID (RO) = 21871632
; PlotStyleName = "Color_511"
; Plottable = -1
; ViewportDefault = 0
; Methods supported:
; Delete ()
; GetExtensionDictionary ()
; GetXData (3)
; SetXData (2)
T
Want to change your Layers color? Enter this :
_$ (vla-put-color aLayer 4)
nil
This will have changed your Layer "2" color to "Cyan" or color "4", including the color of all
Objects within the drawing on Layer "2" with color "ByLayer".
Have a look around at the Document Object. There's stacks to see and drool over. Can you now see
the power and capabilities of Visual Lisp?
On the next page we'll go even deeper and start to have a look at creating, selecting and changing
drawing entities.
Home. Page I. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Beginning II
http://www.afralisp.com/vl/vlbegin2.htm (4 of 4) [23/03/2005 05:56:38 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page II.
The Beginning - Page III.
Before we can create entities, or Objects, within AutoCAD, we need to decide "where" we want to
draw, Model Space or Paper Space. And to do that we need to create a reference to the area in
which we would like to draw.
Remember our filing cabinet? The Application Object was our drawer, the Document Object was
our folder, and now the Model Space Object will be our piece of paper. Let's have a look at the
Model Space Object :
_$ (setq modelSpace (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object))))
#<VLA-OBJECT IAcadModelSpace 018ade24>
Now run a dump on the modelSpace Object :
_$ (vlax-dump-object modelSpace T)
; IAcadModelSpace: A special Block object containing all model space entities
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00adc088>
; Count (RO) = 0
; Document (RO) = #<VLA-OBJECT IAcadDocument 00ee0f84>
; Handle (RO) = "18"
; HasExtensionDictionary (RO) = 0
; IsLayout (RO) = -1
; IsXRef (RO) = 0
; Layout (RO) = #<VLA-OBJECT IAcadLayout 018ad934>
; Name = "*MODEL_SPACE"
; ObjectID (RO) = 21871808
; ObjectName (RO) = "AcDbBlockTableRecord"
; Origin = (0.0 0.0 0.0)
; OwnerID (RO) = 21871624
; XRefDatabase (RO) = AutoCAD.Application: No database
; Methods supported:
; Add3DFace (4)
; Add3DMesh (3)
; Add3DPoly (1)
; AddArc (4)
; AddAttribute (6)
; AddBox (4)
; AddCircle (2)
; AddCone (3)
; AddCustomObject (1)
; AddCylinder (3)
; AddDim3PointAngular (4)
; AddDimAligned (3)
; AddDimAngular (4)
; AddDimDiametric (3)
; AddDimOrdinate (3)
; AddDimRadial (3)
; AddDimRotated (4)
; AddEllipse (3)
; AddEllipticalCone (4)
; AddEllipticalCylinder (4)
; AddExtrudedSolid (3)
; AddExtrudedSolidAlongPath (2)
; AddHatch (3)
; AddLeader (3)
; AddLightWeightPolyline (1)
The Beginning III
http://www.afralisp.com/vl/vlbegin3.htm (1 of 4) [23/03/2005 05:56:39 p.m.]
; AddLine (2)
; AddMInsertBlock (10)
; AddMLine (1)
; AddMText (3)
; AddPoint (1)
; AddPolyfaceMesh (2)
; AddPolyline (1)
; AddRaster (4)
; AddRay (2)
; AddRegion (1)
; AddRevolvedSolid (4)
; AddShape (4)
; AddSolid (4)
; AddSphere (2)
; AddSpline (3)
; AddText (3)
; AddTolerance (3)
; AddTorus (3)
; AddTrace (1)
; AddWedge (4)
; AddXline (2)
; AttachExternalReference (8)
; Bind (1)
; Delete ()
; Detach ()
; GetExtensionDictionary ()
; GetXData (3)
; InsertBlock (6)
; Item (1)
; Reload ()
; SetXData (2)
; Unload ()
T
Interesting hey? Now let's draw something. Enter this coding :
(setq pt1 (getpoint "\nSpecify First Point : "))
(while (setq pt2 (getpoint "\nSpecify next point : " pt1))
(vla-addline modelSpace (vlax-3d-point pt1) (vlax-3d-point pt2))
(setq pt1 pt2)
)
(428.748 578.851 0.0)
(524.783 509.712 0.0)
At last, we've finally drawn something. Now type this :
_$ (setq pt1 (getpoint "\nSpecify First Point : "))
(setq pt2 (getpoint "\nSpecify next point : " pt1))
(setq ourLine (vla-addline modelSpace (vlax-3d-point pt1) (vlax-3d-point pt2)))
(922.321 585.542 0.0)
(1016.12 300.064 0.0)
#<VLA-OBJECT IAcadLine 018ab094>
Did you notice the (setq ourLine statement? This sets a reference to our Line Object. Let's run a
dump on that :
_$ (vlax-dump-object ourLine T)
; IAcadLine: AutoCAD Line Interface
; Property values:
; Angle (RO) = 5.02985
; Application (RO) = #<VLA-OBJECT IAcadApplication 00adc088>
; Color = 256
; Delta (RO) = (93.8012 -285.479 0.0)
; Document (RO) = #<VLA-OBJECT IAcadDocument 00ee0f84>
; EndPoint = (1016.12 300.064 0.0)
; Handle (RO) = "95D"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 018aa2b4>
; Layer = "7"
; Length (RO) = 300.494
; Linetype = "BYLAYER"
; LinetypeScale = 1.0
The Beginning III
http://www.afralisp.com/vl/vlbegin3.htm (2 of 4) [23/03/2005 05:56:39 p.m.]
; Lineweight = -1
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 21873192
; ObjectName (RO) = "AcDbLine"
; OwnerID (RO) = 21871808
; PlotStyleName = "ByLayer"
; StartPoint = (922.321 585.542 0.0)
; Thickness = 0.0
; Visible = -1
; Methods supported:
; ArrayPolar (3)
; ArrayRectangular (6)
; Copy ()
; Delete ()
; GetBoundingBox (2)
; GetExtensionDictionary ()
; GetXData (3)
; Highlight (1)
; IntersectWith (2)
; Mirror (2)
; Mirror3D (3)
; Move (2)
; Offset (1)
; Rotate (2)
; Rotate3D (3)
; ScaleEntity (2)
; SetXData (2)
; TransformBy (1)
; Update ()
T
We now have a list of all the Properties and Methods of our Line Object. Let's change some of it's
properties :
Let's change it's Layer:
_$ (vla-put-layer ourLine 2)
nil
And now it's color :
_$ (vla-put-color ourLine 6)
nil
Let's delete our line :
_$ (entdel (vlax-vla-object->ename ourLine))
<Entity name: 14dc1f8>
Did you notice how we used a standard AutoLisp command (entdel) to delete the line? But before
we could do that, we had to convert the VLisp Object Reference to an AutoLisp Entity Name.
You are probably wondering why we don't just use the AutoLisp (command) function to draw or
change entities. If you use reactor call-back functions, you are not allowed to use the (command)
function.
If terms such as Objects, Properties, Methods and Events sound double Dutch to you,
have a read through An Introduction to VBA. This is written for VBA but much of the
same terminology applies to Visual Lisp.
Well, I hope this has given you an insight into the use of Visual Lisp? Don't worry, we'll be looking
a lot closer at all aspects of Visual Lisp in future Tutorials. This is just to get you started and give
you a taste of what's to come.
Home. Page I. Page II.

The Beginning III


http://www.afralisp.com/vl/vlbegin3.htm (3 of 4) [23/03/2005 05:56:39 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
The Beginning III
http://www.afralisp.com/vl/vlbegin3.htm (4 of 4) [23/03/2005 05:56:39 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
AutoCAD 2000 Object Model
http://www.afralisp.com/vl/object_model.htm (1 of 2) [23/03/2005 05:56:42 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AutoCAD 2000 Object Model
http://www.afralisp.com/vl/object_model.htm (2 of 2) [23/03/2005 05:56:42 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Viewing AutoCAD Objects
Visual Lisp has a great way of letting you view AutoCAD Objects by allowing you to
"walk" through the drawing database. Let's have a wee look at what's on offer. Open
AutoCAD with a blank drawing, and then open the Visual Lisp Editor. Let's set up what
information we would like to see first :
Choose "Tools" - "Environment Options" - "General Options". G
Click the "Diagnostic tab" in the "General Options" window. G
Select "Inspect Drawing Objects Verbosely to view detailed entity information. G
Now choose "View" - "Browse Drawing Database" - "Browse Tables". G
The "Drawing Tables" Inspection window will now open :
That's very nice!! We have a list of the symbol tables in our drawing.
Now, double-click on <Layers> :
Even better! Now we've got a list of all the Layers in our drawing.
Double-click on Layer <2> :
Viewing AutoCAD Objects
http://www.afralisp.com/vl/view.htm (1 of 3) [23/03/2005 05:56:46 p.m.]
Crikey, now we've got a list of all the Layers attributes "including" the AutoLisp Entity list!!!
Now draw a line, a circle, and some text anywhere in your drawing and then select "View" -
"Browse Drawing Database" - "Browse All Entities". The following Inspect window will
open :
Now double-click on <TEXT> :
Now we've got a list of all the text attributes.
Just one more so that you get the idea. This time choose "View" - "Browse Drawing
Database" - "Browse Selection". The AutoCAD window will appear prompting you to
select objects. Do just that :
A list of all entities contained in your selection set will be displayed. This time
double-click on the <Line> object :
Again a list of the Objects attributes are displayed.
Insert a few more Objects into your drawing such as blocks, blocks with attributes, polylines,
hatches,etc.
Viewing AutoCAD Objects
http://www.afralisp.com/vl/view.htm (2 of 3) [23/03/2005 05:56:46 p.m.]
This set of tools gives you a good idea of how the AutoCAD Object Model is put together. Play
around the them, you'll learn a lot........

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Viewing AutoCAD Objects
http://www.afralisp.com/vl/view.htm (3 of 3) [23/03/2005 05:56:46 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
Properties and Methods
The aim of this tutorial is not to describe the Properties and Methods of every AutoCAD
Object, but rather to show you, first how to find the Properties and Methods available for an
Object, and secondly to describe the usage of such Property or Method within Visual Lisp.
Each Object within AutoCAD has numerous Properties and Methods which differ from Object
to Object. To attempt to list each Property or Method for each Object is way beyond the scope
of this tutorial.
First of all, let's have a look at defining a Property and a Method.
Visual Lisp Objects support properties and methods, In Visual Lisp, an Object's data (settings
or attributes) are called 'properties', while the various procedures that can operate on an
Object are called it's 'methods'.
You can change an Object's characteristics by changing it's properties.
Consider a radio: One property of a radio is its volume. In Visual Lisp,
you might say that a radio has a 'Volume' property that you can adjust by
changing its value. Assume you can set the volume of a radio from 0 to 10.
If you could control a radio with Visual Lisp, you might write code in a
procedure that changes the value of the 'Volume' property from 3 to 5 to
make it play louder :
(vla-put-Volume Radio 5)
In addition to properties, objects have methods. Methods are part of objects
just as properties are. Generally, methods are actions you want to perform,
while properties are the attributes you set or retrieve. For example, you dial
a telephone to make a call. You might say that telephones have a 'Dial' method, and you could
use this syntax to dial a seven digit number 3334444:
(vla-Dial Telephone 3334444)
Properties and Methods
http://www.afralisp.com/vl/pm1.htm (1 of 5) [23/03/2005 05:56:49 p.m.]
Before you can start to change an Objects Properties or Methods, you
need to know what Properties and Methods are available to the
particular Object. There are a couple of ways of going about this. First
we'll look at Properties.
Under AutoCAD Help, open "Visual Lisp and AutoLisp" and then
"ActiveX and VBA Reference". Choose the "Objects" sub-section and
from the list choose the Object whose Properties you would like list.
Choose "Line".
As you can see, all the Properties applicable to the "Line" Object are
listed.
Be careful though, as some of these Properties are "Read Only" and
cannot be changed.
e.g. The "Angle" property is "Read Only." Think about it, if you
changed the "ANGLE" Property, the Start or End point of the Line
Object would have to change as well.
Click on any of the Property hyperlinks for further information.
Another way of finding an Objects properties is to use the Visual Lisp
function (vlax-dump-object).
Open AutoCAD and then the Visual Lisp editor and type the following
at the Console prompt :
_$ (vl-load-com)
_$ (setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00b94e14>
_$ (setq mspace (vla-get-modelspace acadDocument))
#<VLA-OBJECT IAcadModelSpace 01e42494>
_$ (setq apt (getpoint "Specify First Point: "))
(228.279 430.843 0.0)
_$ (setq pt (getpoint "Specify next point: " apt))
(503.866 538.358 0.0)
_$ (setq myline (vla-addline mspace (vlax-3d-point apt)(vlax-3d-point pt)))
#<VLA-OBJECT IAcadLine 01e84614>
_$ (vlax-dump-object myline)
; IAcadLine: AutoCAD Line Interface
; Property values:
; Angle (RO) = 0.371971
; Application (RO) = #<VLA-OBJECT IAcadApplication 00adc088>
; Color = 256
; Delta (RO) = (275.587 107.515 0.0)
; Document (RO) = #<VLA-OBJECT IAcadDocument 00b94e14>
; EndPoint = (503.866 538.358 0.0)
; Handle (RO) = "958"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 01e84564>
; Layer = "7"
; Length (RO) = 295.817
; Linetype = "BYLAYER"
; LinetypeScale = 1.0
; Lineweight = -1
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 25187840
Properties and Methods
http://www.afralisp.com/vl/pm1.htm (2 of 5) [23/03/2005 05:56:49 p.m.]
; ObjectName (RO) = "AcDbLine"
; OwnerID (RO) = 25186496
; PlotStyleName = "ByLayer"
; StartPoint = (228.279 430.843 0.0)
; Thickness = 0.0
; Visible = -1
The (vlax-dump object) function lists all the available properties for a particular Object.
Note the (RO) after some of the Properties. This tells you that this Property is "Read Only".
Let's have a look at the Methods pertaining to an Object.
Under AutoCAD help, open "Visual Lisp and AutoLisp" and then "ActiveX
and VBA Reference". Again, choose the "Objects" sub-section and from
the list choose the Object whose Methods you would like list. Choose
"Line".
As you can see, all the Methods applicable to the "Line" Object are listed.
Click on the "Move" method.
The VBA Method for "Move" is displayed and the syntax is as follows :
object.Move Point1, Point2
Object : All Drawing Objects, AttributeRef. The object or objects this method applies to.
Point1 : Variant (three-element array of doubles); input-only. The 3D WCS coordinates
specifying the first point of the move vector.
Point2 : Variant (three-element array of doubles); input-only. The 3D WCS coordinates
specifying the second point of the move vector.

Let's move the line we've just drawn :


_$ (setq apt2 (getpoint "Specify Base Point: "))
(220.911 526.575 0.0)
_$ (setq pt2 (getpoint "Specify second point: " apt2))
(383.02 617.889 0.0)
_$ (vla-move myline (vlax-3d-point apt2)(vlax-3d-point pt2))

Now let's "dump" the Object, but this time we'll use the "T" flag to display the Objects
Methods as well as it's Properties.
_$ (vlax-dump-object myline T)
; IAcadLine: AutoCAD Line Interface
; Property values:
; Angle (RO) = 5.60729
; Application (RO) = #<VLA-OBJECT IAcadApplication 00adc088>
; Color = 256
; Delta (RO) = (246.112 -197.356 0.0)
; Document (RO) = #<VLA-OBJECT IAcadDocument 00b94e14>
; EndPoint = (629.133 420.533 0.0)
; Handle (RO) = "957"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 01e84574>
; Layer = "7"
; Length (RO) = 315.469
; Linetype = "BYLAYER"
; LinetypeScale = 1.0
; Lineweight = -1
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 25187832
; ObjectName (RO) = "AcDbLine"
; OwnerID (RO) = 25186496
Properties and Methods
http://www.afralisp.com/vl/pm1.htm (3 of 5) [23/03/2005 05:56:49 p.m.]
; PlotStyleName = "ByLayer"
; StartPoint = (383.02 617.889 0.0)
; Thickness = 0.0
; Visible = -1
; Methods supported:
; ArrayPolar (3)
; ArrayRectangular (6)
; Copy ()
; Delete ()
; GetBoundingBox (2)
; GetExtensionDictionary ()
; GetXData (3)
; Highlight (1)
; IntersectWith (2)
; Mirror (2)
; Mirror3D (3)
; Move (2)
; Offset (1)
; Rotate (2)
; Rotate3D (3)
; ScaleEntity (2)
; SetXData (2)
; TransformBy (1)
; Update ()
"But, the syntax of the "Move" method you used in Visual Lisp, is different from the VBA
syntax!! How do I know how to call the function in Visual Lisp?"
Don't worry, we'll be having a look at that on the next page.
Before we go there, here's a little application that will dump all Properties and Methods for
selected Objects :
;coding starts here
(defun C:HaveaDump ( / ent)
(vl-load-com)
(while
(setq ent (entsel))
(vlax-dump-object (vlax-Ename->Vla-Object (car ent)) T)

);while
(princ)
);defun
(princ)
;coding ends here
On the next page we'll have a look at how we call Property and Method Functions. See you
there.......

Home. Page II. Page III.

Properties and Methods


http://www.afralisp.com/vl/pm1.htm (4 of 5) [23/03/2005 05:56:49 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Properties and Methods
http://www.afralisp.com/vl/pm1.htm (5 of 5) [23/03/2005 05:56:49 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page III.
Properties and Methods - Page II.
How to Call a Visual Lisp Function
Right, you've identified the Visual Lisp Property or Method that you need, but you still
need to determine how to call the function. You need to know the arguments to specify
and the data type of those arguments.
Let's look at Properties first.
The syntax for the Layer Property in VBA is as follows :
object.Layer or object.property
object : All Drawing objects, AttributeRef, Group. The object or objects this property applies to.
Layer : String; read-write (write-only for the Group object). The name of the layer.
Remarks
All entities have an associated layer. The document always contains at least one layer (layer 0). As with
linetypes, you can specify a layer for an entity. If you dont specify a layer, the current active layer is
used for a new entity. If a layer is specified for an entity, the current active layer is ignored. Use the
ActiveLayer property to set or query the current active layer.
Each layer has associated properties that can be set and queried through the Layer object.
In VBA you would use
Oldlayer =object.Layer to retrieve the Layer Name, and
object.Layer ="2" to change the Layer Name.
Visual Lisp provides functions for reading and updating Object Properties.
Functions that read Object Properties are named with a vla-get prefix and require the
following syntax :
(vla-get-property object)
For example, "vla-get-layer object" returns the Layer the Object is on.
Enter this in the Visual Lisp Console :
_$ (vl-load-com)
_$ (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00b94e14>
_$ (setq mspace (vla-get-modelspace acadDocument))
#<VLA-OBJECT IAcadModelSpace 01e42444>
_$ (setq apt (getpoint "Specify First Point: "))
(307.86 539.809 0.0)
_$ (setq pt (getpoint "Specify next point: " apt))
(738.188 479.426 0.0)
_$ (setq myline (vla-addline mspace (vlax-3d-point apt)(vlax-3d-point pt)))
#<VLA-OBJECT IAcadLine 01e81de4>
Properties and Methods II
http://www.afralisp.com/vl/pm2.htm (1 of 3) [23/03/2005 05:56:50 p.m.]
_$ (setq oldlayer (vla-get-layer myline))
"7"
The variable "oldLayer" now contains the Layer name of your Line Object.
Functions that update Properties are prefixed with vla-put and use the following syntax :
(vla-put-property object new-value)
For example, "vla-put-layer object new-value" changes the layer of the Object.
Enter this at the Console prompt :
_$ (vla-put-layer myline "4")
nil
Your line will have now changed to Layer "4".
Let's have a look at Methods now.
The syntax for the "Offset" Method in VBA is as follows :
RetVal = object.Offset(Distance) or Return Value = object.Method (arguments)
Object : Arc, Circle, Ellipse, Line, LightweightPolyline, Polyline, Spline, XLine. The object or objects this
method applies to.
Distance : Double; input-only. The distance to offset the object. The offset can be a positive or negative
number, but it cannot equal zero. If the offset is negative, this is interpreted as being an offset to make a
"smaller" curve (that is, for an arc it would offset to a radius that is "Distance less" than the starting
curve's radius). If "smaller" has no meaning, then it would offset in the direction of smaller X, Y, and Z
WCS coordinates.
RetVal : Variant (array of objects). An array of the newly created objects resulting from the offset.
In VBA you would use
offsetObj = object.offset(15.5) to Offset an Object.
The syntax definitions used in the "ActiveX and VBA Reference" were designed for Visual Basic
Users. Consider the VBA Offset Method :
returnvalue = object.Method (arguments)
returnvalue = object.Offset(Distance) or using the names in our example
offLine = myline.Offset(15.5)
The syntax for the same operation in Visual Lisp is :
(setq returnvalue (vla-method object argument)) or using our names
(setq offLine (vla-offset myline 15.5))
Different Objects have different Methods but the same principle applies.
Type this at the Console prompt :
_$ (setq offLine (vla-offset myline 15.5))
#<variant 8201 ...>
The variable "offLine", now contains the data for your newly created line in the form of a
variant array.
So to recap :
vla-get- functions correspond to every ActiveX Property, enabling you to retrieve
the value of that Property (for example, vla-get-Color obtains an Object's Color
Property.
G
Properties and Methods II
http://www.afralisp.com/vl/pm2.htm (2 of 3) [23/03/2005 05:56:50 p.m.]
vla-put- functions correspond to every Property, enabling you to update the value
of the Property (for example, vla-put-Color updates an Objects Color Property.
G
vla- functions correspond to every ActiveX Method. Use these functions to invoke
the Method (for example, vla-addCircle invokes the addCircle Method.
G
Visual Lisp also adds a set of ActiveX-related functions whose names are prefixed with
vlax-. These are more general ActiveX functions, each of which can be applied to
numerous Methods, Properties or Objects. For example, with the vlax-get-property
function, you can obtain any Property of any ActiveX Object.
On the next page we'll have a look at how we can determine whether an Object is
available for updating and whether a Method or a Property applies to an Object.
Home. Page I. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Properties and Methods II
http://www.afralisp.com/vl/pm2.htm (3 of 3) [23/03/2005 05:56:50 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page II.
Properties and Methods - Page III.
Determining Whether an Object is Available for Updating
If other applications are working with any AutoCAD Objects at the same time as your
program, those Objects may not be accessible. This is especially important to lookout for
if your application includes reactors, because reactors execute code segments in
response to external events that cannot be predicted in advance. Even a simple thing
such as a locked Layer can prevent you from changing an Objects Properties.
Visual Lisp provides the following functions to test the accessibility of an Object before
trying to use the Object :
vlax-read-enabled-p Tests whether you can read an Object. G
vlax-write-enabled-p Determines whether you can modify an Objects Properties. G
vlax-erased-p Checks to see if an Object has been erased. Erased Objects may still
exist in the drawing database.
G
All these test functions return T if true, and nil if false.
Let's test them out. Draw a line anywhere in AutoCAD then enter this at the Console
prompt :
_$ (vl-load-com)
_$ (setq ent (entsel))
(<Entity name: 17e39f8> (434.601 389.588 0.0))
_$ (setq myLine (vlax-Ename->Vla-Object (car ent)))
#<VLA-OBJECT IAcadLine 01e81f84>
Determine whether the line is readable :
_$ (vlax-read-enabled-p myLine)
T
Determine whether the line is modifiable :
_$ (vlax-write-enabled-p myLine)
T
See if the line has been erased :
_$ (vlax-erased-p myLine)
nil
Erase the line :
_$ (vla-delete myLine)
nil
See if the line is still readable :
_$ (vlax-read-enabled-p myLine)
nil
Properties and Methods III
http://www.afralisp.com/vl/pm3.htm (1 of 3) [23/03/2005 05:56:51 p.m.]
Check to confirm that the object has been deleted :
_$ (vlax-erased-p myLine)
T
Determining If a Method or Property Applies to an Object
Trying to use a Method that does not apply to a specified Object will result in an error.
The same goes for trying to reference a Property that does not apply to an Object. This
will also result in an error. In instances where you are not sure what applies, use the
vlax-method-applicable-p and the vlax-property-available-p functions.
These functions return T if the Method or Property is available for the Object, and nil if
not.
The syntax for vlax-method-applicable-p is :
(vlax-method-applicable-p object method)
The following command checks to see if the "Copy" Method can be applied to an Object :
_$ (vlax-method-applicable-p myLine "Copy")
T
The following command determines if the "addBox" Method can be applied to an Object :
_$ (vlax-method-applicable-p myLine "addBox")
nil
For vlax-property-available-p the syntax is :
(vlax-property-available-p object property [T])
The following commands determine if Color and Center are properties of the myLine
Object :
(vlax-property-available-p myLine "Color")
T
(vlax-property-available-p myLine "Center")
nil
Supplying the optional "T" argument to vlax-property-available-p changes the meaning of
the test. If you supply this argument, the function returns T only if the Object has the
Property AND the Property can be modified. If the Object has no such Property or the
Property is Read-Only, vlax-property-available-p returns nil.
For example, a Circle contains an Area Property, but you cannot update it.
If you check the Property without specifying the optional argument the result is T.
(vlax-property-available-p myCircle "area")
T
If you supply the optional argument, the result is nil :
(vlax-property-available-p myCircle "area" T)
nil
Well, that's it with Methods and Properties. Time for me to pour myself a nice long, cold beer and
retire to the garden and sit in the sun. The advantages of living in Africa. Eat your heart out............
Oh, by the way, my Mum has got a great Method of cooking Tripe and Onion's if anybody is
interested!!
Home. Page I. Page II.

Properties and Methods III


http://www.afralisp.com/vl/pm3.htm (2 of 3) [23/03/2005 05:56:51 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Properties and Methods III
http://www.afralisp.com/vl/pm3.htm (3 of 3) [23/03/2005 05:56:51 p.m.]
Search
Visual Lisp Methods Reference
Back to the Tutorials

A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
A big thank you to the following people for help in compiling this reference :
Stig Madsen; Randall Rath; David Stein, J onathan Trostat, Namibian Breweries.
As you can see, this reference is still far from complete but I'm busy working on it as time permits. If you
feel that you have an example of a method that you would like to contribute, please feel free to mail it to
me. Don't worry if it's a method that has an example already, if yours is different, I will post it as well.
Hey, you'll even get your name at the top of the page.
A
Activate - Makes the specified drawing active.
Add - Creates a member object and adds it to the appropriate collection.
Add3DFace - Creates a 3DFace object given four vertices.
Add3DMesh - Creates a free-form 3D mesh, given the number of points in the M and N directions and the
coordinates of the points in the M and N directions.
Add3DPoly - Creates a 3D polyline from the given array of coordinates.
AddArc - Creates an arc given the center, radius, start angle, and end angle of the arc.
AddAttribute - Creates an attribute definition at the given location with the specified properties.
AddBox - Creates a 3D solid box with edges parallel to the axes of the WCS.
AddCircle - Creates a circle given a center point and radius.
AddCone - Creates a 3D solid cone with the base on the XY plane of the WCS.
AddCustomObject - Creates a Custom object.
AddCylinder - Creates a 3D solid cylinder whose base is on the XY plane of the WCS.
AddDim3PointAngular - Creates an angular dimension using 3 points.
AddDimAligned - Creates an aligned dimension object.
AddDimAngular - Creates an angular dimension for an arc, two lines, or a circle.
AddDimDiametric - Creates a diametric dimension for a circle or arc given the two points on the diameter
and the length of the leader line.
AddDimOrdinate - Creates an ordinate dimension given the definition point, and leader endpoint.
AddDimRadial - Creates a radial dimension for the selected object at the given location.
AddDimRotated - Creates a rotated linear dimension.
AddEllipse - Creates an ellipse in the XY plane of the WCS given the center point, a point on the major
axis, and the radius ratio.
AddEllipticalCone - Creates a 3D solid elliptical cone on the XY plane of the WCS given the Center,
MajorRadius, MinorRadius, and Height.
AddEllipticalCylinder - Creates a 3D solid elliptical cylinder whose base is on the XY plane of the WCS,
given the Center, MajorRadius, MinorRadius, and Height.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (1 of 9) [23/03/2005 05:56:54 p.m.]
AddExtrudedSolid - Creates an extruded solid given the Profile, Height, and TaperAngle.
AddExtrudedSolidAlongPath - Creates an extruded solid given the profile and an extrusion path.
AddFitPoint - Adds the fit point to the spline at a given index.
AddHatch - Creates a Hatch object.
AddItems - Adds one or more objects to the specified selection set.
AddLeader - Creates a leader line, given the coordinates of the points.
AddLightweightPolyline - Creates a lightweight polyline from a list of vertices.
AddLine - Creates a line passing through two points.
AddMenuItem - Adds a popup menu item to a popup menu.
AddMInsertBlock - Inserts an array of blocks.
AddMLine - Creates multiple lines passing through an array of points.
AddMtext - Creates an MText entity in a rectangle defined by the insertion point and width of the
bounding box.
AddObject - Adds an object to a named dictionary.
AddPoint - Creates a Point object at a given location.
AddPolyfaceMesh - Creates a polyface mesh from a list of vertices.
AddPolyline - Creates a polyline from a list of vertices.
AddPViewport - Adds a paper space viewport, given the center, height, and width.
AddRaster - Creates a new raster image based on an existing image file.
AddRay - Creates a ray passing through two unique points.
AddRegion - Creates a region from a set of entities. The given entities must form a closed coplanar
region.
AddRevolvedSolid - Creates a revolved solid, given the region around an axis.
AddSeparator - Adds a separator to an existing menu or toolbar.
AddShape - Creates a Shape object based on a template identified by name, at the given insertion point,
scale factor, and rotation.
AddSolid - Creates a 2D solid polygon.
AddSphere - Creates a sphere given the center and radius.
AddSpline - Creates a quadratic or cubic NURBS (nonuniform rational B-spline) curve.
AddSubMenu - Adds a submenu to an existing menu.
AddText - Creates a single line of text.
AddTolerance - Creates a tolerance entity.
AddToolbarButton - Adds a toolbar item to a toolbar at a specified position.
AddTorus - Creates a torus at the given location.
AddTrace - Creates a Trace object from an array of points.
AddVertex - Adds a vertex to a lightweight polyline.
AddWedge - Creates a wedge with edges parallel to the axes given the length, width, and height.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (2 of 9) [23/03/2005 05:56:54 p.m.]
AddXLine - Creates an xline (an infinite line) passing through two specified points.
AddXRecord - Creates an XRecord object in any dictionary.
AngleFromXAxis - Gets the angle of a line from the X axis.
AngleToReal - Converts an angle as a string to a real (double) value.
AngleToString - Converts an angle from a real (double) value to a string.
AppendInnerLoop - Appends an inner loop to the hatch.
AppendItems - Appends one or more entities to the specified group.
AppendOuterLoop - Appends an outer loop to the hatch.
AppendVertex - Appends a vertex to the end of a 3DPolyline , Polyline or PolygonMesh object.
ArrayPolar - Creates a polar array of objects given a NumberOfObjects, AngleToFill, and CenterPoint.
ArrayRectangular - Creates a 2D or 3D rectangular array of objects.
AttachExternalReference - Attaches an external reference (xref) to the drawing.
AttachToolbarToFlyout - Attaches a toolbar to a toolbar button defined as a flyout.
AuditInfo - Evaluates the integrity of the drawing.
B
Bind - Binds an external reference (xref) to a drawing.
Boolean - Performs a boolean operation (union, intersect, or subtract) between the object and another
3DSolid or Region object.
C
CheckInterference - Checks for interference between two solids and, if specified, creates a solid from the
interference.
Clear - Clears the specified selection set of all items.
ClipBoundary - Specifies the clipping boundary for a raster image.
Close - Closes the specified drawing, or all open drawings.
Copy - Duplicates the given object to the same location.
CopyFrom - Copies the settings from the given plot configuration.
CopyObjects - Duplicates multiple objects (deep cloning).
CopyProfile - Copies the specified profile.
CreateTypedArray - Creates a variant that contains an array of typed arguments.
D
Delete - Deletes a specified object or a set of saved layer settings.
DeleteConfiguration - Deletes a viewport configuration.
DeleteFitPoint - Deletes the fit point of a spline at a given index.
DeleteProfile - Deletes the specified profile.
Detach - Detachs an external reference (xref) from a drawing.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (3 of 9) [23/03/2005 05:56:54 p.m.]
Display - Toggles the display control of the PViewport object on or off.
DisplayPlotPreview - Displays the Plot Preview dialog box with the specified partial or full view preview.
DistanceToReal - Converts a distance from a string to a real (double) value.
Dock - Docks the toolbar to the owning frame window.
E
ElevateOrder - Elevates the order of the spline to the given order.
EndUndoMark - Marks the end of a block of operations.
Erase - Erases all the objects in a selection set.
Eval - Evaluates an Expression in VBA.
Evaluate - Evaluates the given hatch or leader.
Explode - Explodes the compound object into subentities.
Export - Exports a drawing or a group of saved layer settings to a file.
ExportProfile - Exports the active profile so it can be shared with other users.
F
Float - Floats the toolbar.
G
GetAcadState - Gets an AcadState object to monitor the state of AutoCAD from out-of-process
applications.
GetAllProfileNames - Gets all available profiles for the system.
GetAngle - Gets the angle specified. Considers the setting of the ANGBASE system variable.
GetAttributes - Gets the attributes in the block reference.
GetBitmaps - Gets the large and small bitmaps used as icons for the toolbar item.
GetBoundingBox - Gets two points of a box enclosing the specified object.
GetBulge - Gets the bulge value at a given index of the polyline.
GetCanonicalMediaNames - Gets all available canonical media names for the specified plot device.
GetConstantAttributes - Gets the constant attributes in the block or external reference.
GetControlPoint - Gets the coordinates of the control point at a given index.
GetCorner - Gets a corner of a rectangle.
GetCustomScale - Gets the custom scale for a layout or plot configuration.
GetDistance - Gets the distance from the prompt line or a selected set of points on the screen.
GetEntity - Gets an object interactively.
GetExtensionDictionary - Gets the extension dictionary associated with an object.
GetFitPoint - Gets the fit point of a spline at a given index.
GetFont - Gets the definition data of the font for the TextStyle.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (4 of 9) [23/03/2005 05:56:54 p.m.]
GetGridSpacing - Gets the grid spacing for the viewport.
GetInput - Converts an input string from the user into a keyword index.
GetInteger - Gets an integer value from the user.
GetInterfaceObject - Accepts a program ID and attempts to load it into AutoCAD as an in-process server.
GetInvisibleEdge - Gets the visibility setting for an edge of a 3DFace object at a given index.
GetKeyword - Gets a keyword string from the user.
GetLocaleMediaName - Gets the localized version of the canonical media name.
GetLoopAt - Gets the hatch loop at a given index.
GetName - Gets the name (keyword) of an object in a dictionary.
GetObject - Gets the object in a dictionary, given the name (keyword) of the object.
GetOrientation - Gets the angle specified. Ignores the setting of the ANGBASE system variable.
GetPaperMargins - Gets the margins for the layout or plot configuration.
GetPaperSize - Gets the width and height of the configured paper.
GetPlotDeviceNames - Gets all available plot device names.
GetPlotStyleTableNames - Gets all available plot style table names.
GetPoint - Gets the point selected in AutoCAD.
GetProjectFilePath - Gets the directory in which AutoCAD looks for external reference files.
GetReal - Gets a real (double) value from the user.
GetRemoteFile - Downloads the file specified by a URL.
GetSnapSpacing - Gets the snap spacing for the viewport.
GetString - Gets a string from the user.
GetSubEntity - Gets an object or subentity interactively.
GetUCSMatrix - Gets the transformation matrix consisting of UCS coordinate system data.
GetVariable - Gets the current setting of an AutoCAD system variable.
GetWeight - Gets the weight of the control point at a given index.
GetWidth - Gets the start and end width for a polyline.
GetWindowToPlot - Gets the coordinates that define the portion of the layout to plot.
GetXData - Gets the extended data (XData) associated with an object.
GetXRecordData - Gets the extended record data (XRecordData) associated with a dictionary.
H
HandleToObject - Gets the object that corresponds to the given handle.
Highlight - Sets the highlight status for the given object, or for all objects in a given selection set.
I
Import - Imports a drawing or a group of saved layer settings from a file.
ImportProfile - Imports a profile created by another user.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (5 of 9) [23/03/2005 05:56:54 p.m.]
InitializeUserInput - Initializes the GetKeyword method.
InsertBlock - Inserts a drawing file or a named block that has been defined in the current drawing.
InsertInMenuBar - Inserts the popup menu into the AutoCAD menu bar at a specified location.
InsertLoopAt - Inserts a loop at a given index of a hatch.
InsertMenuInMenuBar - Inserts a menu into the AutoCAD menu bar.
IntersectWith - Gets the points where one object intersects another object in the drawing.
IsRemoteFile - Returns the URL that a remote file was downloaded from.
IsURL - Validates a given URL.
Item - Gets the member object at a given index in a collection, group, or selection set.
J
K
L
LaunchBrowserDialog - Launches the Web Browser dialog that allows the user to navigate to any URL
and select a URL.
ListARX - Gets the currently loaded AutoCAD ARX applications.
Load - Loads a menu group from a menu file or the definition of a linetype from a library (LIN) file.
LoadARX - Loads the specified AutoCAD ARX application.
LoadDVB - Loads the specified AutoCAD VBA project file.
LoadShapeFile - Loads a shape file (SHX).
M
Mirror - Creates a mirror image copy of a planar object around an axis.
Mirror3D - Creates a mirror image of the given object about a plane.
Move - Moves an object along a vector.
N
New - Creates a new document in SDI mode.
O
ObjectIDToObject - Gets the object that corresponds to the given object ID.
Offset - Creates a new object at a specified offset distance from an existing object.
Open - Opens an existing drawing file (DWG) and makes it the active document.
P
PlotToDevice - Plots a layout to a device.
PlotToFile - Plots a layout to the specified file.
PolarPoint - Gets the point at a specified angle and distance from a given point.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (6 of 9) [23/03/2005 05:56:54 p.m.]
Prompt - Posts a prompt to the command line.
PurgeAll - Removes unused named references such as unused blocks or layers from the document.
PurgetFitData - Purges the fit data of a spline.
PutRemoteFile - Uploads a file to a remote location specified a URL.
Q
Quit - Closes the drawing file and exits the AutoCAD application.
R
RealToString - Converts a real (double) value to a string.
RefreshPlotDeviceInfo - Updates the plot, canonical media, and plot style table information to reflect the
current system state.
Regen - Regenerates the entire drawing and recomputes the screen coordinates and view resolution for
all objects.
Reload - Reloads the external reference (xref).
Remove - Removes a named object from the dictionary.
RemoveItems - Removes specified items from the group or selection set.
RemoveFromMenuBar - Removes the popup menu from the AutoCAD menu bar.
RemoveMenuFromMenuBar - Removes the popup menu, as specified from the collection, from the
AutoCAD menu bar.
Rename - Renames an item in a dictionary or a set of saved layer settings.
RenameProfile - Renames the specified profile.
Replace - Replaces an item in the dictionary by a given item.
ResetProfile - Resets the value in the specified profile to its default values.
Restore - Restores a group of layer property settings.
Reverse - Reverses the direction of a spline.
Rotate - Rotates an object around a base point.
Rotate3D - Rotates an object around a 3D axis. Point1 and Point2 define the line that becomes the axis of
rotation.
RunMacro - Runs a VBA macro from the Application object.
S
Save - Saves a document, menu group, or group of layer property settings.
SaveAs - Saves the document or menu group to a specified file.
ScaleEntity - Scales an object equally in the X, Y, and Z directions.
SectionSolid - Creates a region that represents the intersection of a plane defined by three points and
the solid.
Select - Selects objects and places them into a selection set.
SelectAtPoint - Selects an object passing through a given point and places it into a selection set.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (7 of 9) [23/03/2005 05:56:54 p.m.]
SelectByPolygon - Selects entities within a fence and adds them to the selection set.
SelectOnScreen - Prompts the user to pick an object from the screen.
SendCommand - Sends a command string to the document for syncronous processing.
SetBitmaps - Sets the large and small bitmaps used as icons for the toolbar item.
SetBulge - Sets the bulge for the polyline at the given index.
SetControlPoint - Sets the control point of the spline at a given index.
SetCustomScale - Sets the custom scale for a layout or plot configuration.
SetDatabase - Associates an AutoCAD database with the LayerStateManager object.
SetFitPoint - Sets a fit point for the spline.
SetFont - Sets the definition data of the font for the TextStyle.
SetGridSpacing - Sets the grid spacing for the viewport.
SetInvisibleEdge - Sets the visibility state of an edge at a given index.
SetLayoutsToPlot - Specifies the layout or layouts to plot.
SetPattern - Sets the pattern name and pattern type for the hatch.
SetProjectFilePath - Sets the directory in which AutoCAD looks for external reference files.
SetSnapSpacing - Sets the snap spacing for the viewport.
SetVariable - Sets the value of an AutoCAD system variable.
SetView - Sets the view in a viewport to a saved view in the Views Collection object.
SetWeight - Sets the weight of the control point at a given index.
SetWidth - Sets the start and end width of a polyline, given the segment index.
SetWindowToPlot - Sets the coordinates that define the portion of the layout to plot.
SetXData - Sets the extended data (XData) associated with an object.
SetXRecordData - Sets the extended record data (XRecordData) associated with a dictionary.
SliceSolid - Creates a slice of the 3DSolid object given three points that define the plane.
Split - Splits a viewport into the given number of views.
StartBatchMode - Invokes batchmode printing.
StartUndoMark - Marks the beginning of a block of operations.
T
TransformBy - Moves, scales, or rotates an object given a 4x4 transformation matrix.
TranslateCoordinates - Translates a point from one coordinate system to another coordinate system.
U
Unload - Unloads the menu group or external reference.
UnloadARX - Unloads the specified AutoCAD ARX application.
UnloadDVB - Unloads the specified AutoCAD VBA project file.
Update - Updates the object to the drawing screen.
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (8 of 9) [23/03/2005 05:56:54 p.m.]
V
W
WBlock - Writes out the given selection set as a new drawing file.
X
Xmlin - Translates the specified DesignXML file's AcDbXML model channel to objects and inserts them
into the given database.
Xmlout - Translates the entire database or a set of specified objects (and all dependent objects) to a new
DesignXML file using the AcDbXml model channel.
Y
Z
ZoomAll - Zooms the current viewport to display the entire drawing.
ZoomCenter - Zooms the current viewport to a specified center point and magnification.
ZoomExtents - Zooms the current viewport to the drawing extents.
ZoomPickWindow - Zooms the current viewport to a window defined by points picked on the screen.
ZoomPrevious - Zooms the current viewport to its previous extents.
ZoomScaled - Zooms the current viewport to given scale factor.
ZoomWindow - Zooms the current viewport to the area specified by two opposite corners of a rectangle.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp Methods Reference
http://www.afralisp.com/methods/methods_ref.htm (9 of 9) [23/03/2005 05:56:54 p.m.]
Search
Activate Method
Back to Methods Reference
Makes the specified drawing active.
Signature
VBA : object.Activate
VL : vla-Activate Object
(vla-activate (vla-item docs 1))
Object : Document
The object or objects this method applies to.
G
Example :
;Get the document collection object from the application
;and active the 2nd item in the collection:
(setq docs (vla-get-documents (vlax-get-acad-object)))
(vla-activate (vla-item docs 1))

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Activate Method
http://www.afralisp.com/methods/list/activate_method.htm [23/03/2005 05:56:55 p.m.]
Search
Add Method
Back to Methods Reference
Creates a member object and adds it to the appropriate collection.
Signatures: Overview
Blocks
VBA : RetVal = object.Add(InsertionPoint, Name) G
VL : RetVal = (vla-Add object InsertionPoint Name) G
UCSs
VBA : RetVal = object.Add(Origin, XAxisPoint, YAxisPoint, Name) G
VL : RetVal = (vla-Add Object Origin XAxisPoint YAxisPoint Name) G
Hyperlinks
VBA : RetVal = object.Add(Name[, Description][, NamedLocation]) G
VL : RetVal = (vla-Add object Name Description NamedLocation) G
PlotConfigurations
VBA : RetVal = object.Add(Name[, ModelType]) G
VL : RetVal = (vla-Add object Name ModelType) G
Dictionaries, DimStyles, Documents, Groups; Layers, Layouts, Linetypes, PlotConfigurations,
PopupMenus, Projects, RegisteredApps, SelectionSets, TextStyles, Toolbars, Views, Viewports
VBA: RetVal = object.Add(Name) G
VL : RetVal = (vla-Add Name) G
Signatures: Detail
VBA : RetVal = object.Add(InsertionPoint, Name)
VL : RetVal = (vla-Add object InsertionPoint Name)
Object : Blocks
The collection to add the new object to.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying where the Blocks Collection object will be added.
G
Name : String; input-only
The name of the block to add to the collection.
G
RetVal : Block object
The newly added Block object.
G
VBA : RetVal = object.Add(Origin, XAxisPoint, YAxisPoint, Name)
VL : RetVal = (vla-Add Object Origin XAxisPoint YAxisPoint Name)
Object : UCSs
The collection to add the new object to.
G
Origin : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying where the UCS is to be added.
G
XAxisPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point on the positive X axis of the UCS. The XAxisPoint
and YAxisPoint together cannot specify the same location as the Origin.
G
YAxisPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point on the positive Y axis of the UCS.
(The Z axis follows by applying the right-hand rule.)
G
Name : String; input-only
The name of the UCS to add to the collection.
G
RetVal : UCS object
The newly added UCS object.
G
VBA : RetVal = object.Add(Name[, Description][, NamedLocation])
Add Method
http://www.afralisp.com/methods/list/add_method.htm (1 of 3) [23/03/2005 05:56:56 p.m.]
VL : RetVal = (vla-Add object Name Description NamedLocation)
Object : Hyperlinks
The collection to add the new object to.
G
Name : String; input-only
The name of the hyperlink to add.
G
Description : Variant; input-only; optional
The description of the hyperlink to add.
G
NamedLocation : Variant; input-only; optional
A given location, such as a named view in AutoCAD or a bookmark in a word processing
program. If you specify a named view to jump to in an AutoCAD drawing, AutoCAD restores that
view when the hyperlink is opened.
G
RetVal : Hyperlink
The newly added object.
G
VBA : RetVal = object.Add(Name[, ModelType])
VL : RetVal = (vla-Add object Name ModelType)
Object : PlotConfigurations
The collection to add the new object to.
G
Name : String; input-only
The name of the object to add to the collection.
G
ModelType : Boolean; input-only; optional
TRUE: The plot configuration applies only to the Model Space tab.
FALSE: The plot configuration applies to all layouts.
G
RetVal PlotConfiguration
The newly added object.
G
VBA : RetVal = object.Add(Name)
VL : RetVal = (vla-Add Name)
(vla-add ssets "$Set")
Object : Dictionaries, DimStyles, Documents, Groups; Layers, Layouts, Linetypes, PopupMenus,
RegisteredApps
, SelectionSets, TextStyles, Toolbars, Views, Viewports
The collection to add the new object to.
G
Name : String; input-only; optional for the Documents collection.
The name of the object to add to the collection. For the Documents collection, this name
represents the name of the drawing template to use and will accept a URL address or a fully
qualified path and file name.
G
RetVal : Dictionary, DimStyle, Document, Group, Layer, Layout, Linetype, PopupMenu
, RegisteredApp, SelectionSet
, TextStyle, Toolbar, View, Viewport
The newly added object.
G
Remarks
Although you can create a linetype and add it to the Linetypes Collection object using this method, it
will be created with the default properties only. Because you cannot edit properties of the Linetype
object with this release of ActiveX Automation, use the Load method to load existing linetypes into
your drawing.
Layers are created with default color and linetype properties. The default color is white, the default
linetype is standard.
Documents collection: You cannot use the Add method for the Documents collection while in SDI
mode. When in SDI mode, use the Open method on the Document object. When accessing a secure
URL a dialog box will be posted prompting the user for the necessary password information. Message
boxes may also appear if the user has not suppressed this activity in their browser. When
downloading a file, AutoCAD creates a temporary file for internal processing. Do not attempt to access
this temporary file. Information in this file is deleted at the end of the AutoCAD session.
Example :
Add Method
http://www.afralisp.com/methods/list/add_method.htm (2 of 3) [23/03/2005 05:56:56 p.m.]
(defun c:al-add ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if
(vla-SelectOnScreen newSet)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Add Method
http://www.afralisp.com/methods/list/add_method.htm (3 of 3) [23/03/2005 05:56:56 p.m.]
Search
Add3DFace Method
Back to Methods Reference
Creates a 3DFace object given four vertices.
Signature
VBA : RetVal = object.Add3DFace(Point1, Point2, Point3[, Point4])
VL : Retval = (vla-add3DFace object point1 point2 point3 point4)
(vla-add3dface mspace pt1 pt2 pt3 pt4)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point on the 3DFace object.
G
Point2 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point on the 3DFace object.
G
Point3 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point on the 3DFace object.
G
Point4 : Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying a point on the 3DFace object. If omitted, this point will
default to the coordinates of Point3 in order to create a three-sided face.
G
RetVal : 3DFace object
The newly created 3DFace object.
G
Remarks
To create a three-sided face, omit the last point. Use the SetInvisibleEdge method to set the visibility of
an edge.
Points must be entered in a clockwise or counterclockwise order to create a 3DFace object. You can
create multiple adjacent faces by specifying the first two points of an additional face exactly as the last
two points of the previous face.
Example :
;Get the ModelSpace collection of the active document,
;select 4 point and add the 3Dface:
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt1 (vlax-3d-point (getpoint "First point: ")))
(setq pt2 (vlax-3d-point (getpoint "Second point: ")))
(setq pt3 (vlax-3d-point (getpoint "Third point: ")))
(setq pt4 (vlax-3d-point (getpoint "Fourth point: ")))
(vla-add3dface mspace pt1 pt2 pt3 pt4)

Add3DFace Method
http://www.afralisp.com/methods/list/add3dface_method.htm (1 of 2) [23/03/2005 05:56:57 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Add3DFace Method
http://www.afralisp.com/methods/list/add3dface_method.htm (2 of 2) [23/03/2005 05:56:57 p.m.]
Search
Add3DPoly Method
Back to Methods Reference
Creates a 3D polyline from the given array of coordinates.
Signature
VBA : RetVal = object.Add3Dpoly(PointsArray)
VL : RetVal = (vla-Add3Dpoly object PointsArray)
(setq myobj (vla-Add3DPoly mspace tmp))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
PointsArray : Variant (array of doubles); input-only
An array of 3D WCS coordinates. The polyline will be created according to the order of the
coordinates in the array. The number of elements in the array must be a multiple of three. (Three
elements define a single coordinate.)
G
RetVal : 3DPolyline object
The newly created 3DPolyline object.
G
Remarks
To close the polyline, use the Closed property on the 3DPolyline object.
Example :
(defun c:al-Add3DPoly ( / mspace pt ptlist tmp myobj)
(vl-load-com)

(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq pt (getpoint "\nSpecify start point: "))
; Start by assembling a list of points
(setq ptlist (cons pt ptlist))
(while (setq pt (getpoint "\nSpecify next point: " pt))
(setq ptlist (cons pt ptlist))
);while
; "dissolve" the points into atoms with append:
(setq ptlist (apply 'append ptlist))
; If number of coordinates in point list is not
; a multiple of 3 then a lwpolyline can't be made.
; If it's a multiple of 3 then put the point
; list into an array and pass it on to Add3DPoly:
(if (= (rem (length ptlist) 3) 0)
(progn
(setq
tmp (vlax-make-safearray
vlax-vbDouble
Add3DPoly Method
http://www.afralisp.com/methods/list/add3dpoly_method.htm (1 of 2) [23/03/2005 05:56:57 p.m.]
(cons 0 (- (length ptlist) 1))
)
)
(vlax-safearray-fill tmp ptlist)
(setq myobj (vla-Add3DPoly mspace tmp))
);progn
(princ "\nError: 3DPoly could not be created")
);if
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Add3DPoly Method
http://www.afralisp.com/methods/list/add3dpoly_method.htm (2 of 2) [23/03/2005 05:56:57 p.m.]
Search
AddArc Method
Back to Methods Reference
Creates an arc given the center, radius, start angle, and end angle of the arc.
Signature
VBA : RetVal = object.AddArc(Center, Radius, StartAngle, EndAngle)
VL : RetVal = (vla-AddArc Object Center Radius StartAngle EndAngle)
(vla-AddArc mspace pt1 rad sang eang)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Center : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the center point of the arc.
G
Radius : Double; input-only
The radius of the arc.
G
StartAngle, EndAngle : Double; input-only
The start and end angles, in radians, defining the arc. A start angle greater than an end angle
defines a counterclockwise arc.
G
RetVal : Arc object
The newly created Arc object.
G
Example :
;Get the ModelSpace collection of the active document,
;select center point, input radius, start angle and end angle:
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt1 (vlax-3d-point (getpoint "Center point: ")))
(setq rad (getreal "Radius of arc: "))
(setq sang (getangle "Start angle: ")
eang (getangle "End angle: ")
)
(vla-addarc mspace pt1 rad sang eang)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AddArc Method
http://www.afralisp.com/methods/list/addarc_method.htm (1 of 2) [23/03/2005 05:56:58 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddArc Method
http://www.afralisp.com/methods/list/addarc_method.htm (2 of 2) [23/03/2005 05:56:58 p.m.]
AddAttribute Method
Back to Methods Reference
Creates an attribute definition at the given location with the specified properties.
Signature
VBA : RetVal = object.AddAttribute(Height, Mode, Prompt, InsertionPoint, Tag, Value)
VL : RetVal = (vla-AddAtribute object Height Mode Prompt InsertionPoint Tag Value)
(vla-addattribute mspace height mode pr pt1 tag val)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Height : Double; input-only
The text height in the current drawing unit.
G
Mode : AcAttributeMode enum; input-only
(any combination of constants can be used by adding them together):
acAttributeModeInvisible
acAttributeModeConstant
acAttributeModeVerify
acAttributeModePreset
G
Prompt String : input-only
This string appears when a block containing this attribute is inserted. The default for this string
is the Tag string. Inputting acAttributeModeConstant for the Mode parameter disables the
prompt.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the location for the attribute.
Tag String; input-only
This non-null string identifies each occurrence of the attribute. Enter any characters except
spaces or exclamation points. AutoCAD changes lowercase letters to uppercase.
G
Value String : input-only
This non-null string is the default attribute value.
G
RetVal Attribute object
The newly created Attribute object.
G
Remarks
An attribute definition is associated to the block upon which it is created. Attribute definitions created
on model space or paper space are not considered to be attached to any given block.
The attribute can be created with any or all of the following modes:
acAttributeModeInvisible:
Specifies that attribute values won't appear when you insert the block. The ATTDISP system
variable overrides the Invisible mode.
G
acAttributeModeConstant:
Gives attributes a fixed value for block insertions.
G
acAttributeModeVerify:
Prompts you to verify that the attribute value is correct when you insert the block.
G
acAttributeModePreset:
Sets the attribute to its default value when you insert a block containing a present attribute. The
value cannot be edited in this mode.
G
The AFLAGS system variable stores the mode setting. You can query this value using the GetVariable
method, or set it using the SetVariable method.
Example :
AddAttribute Method
http://www.afralisp.com/methods/list/addattribute_method.htm (1 of 2) [23/03/2005 05:56:59 p.m.]
;Create an attribute in ModelSpace.
;Ask for all parameters, except mode which is retrieved
;from the system variable AFLAGS, and create the attribute.
;Because this attribute is created in ModelSpace it is not
;attached to a block.
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (setq pt (getpoint "\nInsertion point: "))))
(setq height (getdist "\nHeight: " pt))
(setq mode (getvar "AFLAGS")
pr (getstring "Prompt: ")
tag (getstring "Tag: ")
val (getstring "Initial value: ")
)
(vla-addattribute mspace height mode pr pt1 tag val)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddAttribute Method
http://www.afralisp.com/methods/list/addattribute_method.htm (2 of 2) [23/03/2005 05:56:59 p.m.]
Search
AddBox Method
Back to Methods Reference
Creates a 3D solid box with edges parallel to the axes of the WCS.
Signature
VBA : RetVal = object.AddBox(Origin, Length, Width, Height)
VL : RetVal = (vla-AddBox object Origin Length Width Height)
(vla-addbox mspace pt1 len wid hgt)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Origin : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the origin of the box. This coordinate represents the center
of the bounding box for the object, not a corner.
G
Length Double : input-only
The length of the box. Must be a positive number.
G
Width Double : input-only
The width of the box. Must be a positive number.
G
Height Double : input-only
The height of the box. Must be a positive number.
G
RetVal : 3DSolid object
A 3DSolid object as the newly created box.
G
Example :
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (setq pt (getpoint "\nOrigin: "))))
(setq len (getdist "\nLength: " pt)
wid (getdist "\nWidth: " pt)
hgt (getdist "\nHeight: " pt)
)
(vla-addbox mspace pt1 len wid hgt)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
AddBox Method
http://www.afralisp.com/methods/list/AddBox_method.htm (1 of 2) [23/03/2005 05:57:00 p.m.]
Search
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddBox Method
http://www.afralisp.com/methods/list/AddBox_method.htm (2 of 2) [23/03/2005 05:57:00 p.m.]
AddCircle Method
Back to Methods Reference
Creates a circle given a center point and radius.
Signature
VBA : RetVal = object.AddCircle(Center, Radius)
VLA : RetVal = (vla-AddCircle Center Radius)
(vla-AddCircle mspace pt1 rad)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Center : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the circle's center.
G
Radius : Double; input-only
The radius of the circle. Must be a positive number.
G
RetVal : Circle object
The newly created Circle object.
G
Remarks
This circle is created on the XY plane of the WCS.
Example :
;Get the ModelSpace collection of the active document,
;select center point and radius:
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt1 (vlax-3d-point (getpoint "\nCenter point: ")))
(setq rad (getreal "\nRadius: "))
(vla-AddCircle mspace pt1 rad)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
AddCircle Method
http://www.afralisp.com/methods/list/addcircle_method.htm (1 of 2) [23/03/2005 05:57:01 p.m.]
Search
Powered by CORBIMITE.com
AddCircle Method
http://www.afralisp.com/methods/list/addcircle_method.htm (2 of 2) [23/03/2005 05:57:01 p.m.]
AddCone Method
Back to Methods Reference
Creates a 3D solid cone with the base on the XY plane of the WCS.
Signature
VBA : RetVal = object.AddCone(Center, BaseRadius, Height)
VLA : RetVal = (vla-AddCone object Center BaseRadius Height)
(vla-addcone mspace pt1 rad hgt)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Center : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the center of the bounding box.
G
BaseRadius Double : input-only
The radius of the cone base. Must be a positive number.
G
Height Double : input-only
The height of the cone. Must be a positive number.
G
RetVal : 3DSolid object
A 3DSolid object as the newly created cone.
G
Example :
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (setq pt (getpoint "\nCenter point: "))))
(setq rad (getdist "\nBase radius: " pt))
(setq hgt (getdist "\nCone height: " pt))
(vla-addcone mspace pt1 rad hgt)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddCone Method
http://www.afralisp.com/methods/list/addcone_method.htm [23/03/2005 05:57:01 p.m.]
Search
AddCylinder Method
Back to Methods Reference
Creates a 3D solid cylinder whose base is on the XY plane of the WCS.
Signature
VBA : RetVal = object.AddCylinder(Center, Radius, Height)
VLA : RetVal = (vla-AddCylinder Center Radius Height)
(vla-addcylinder mspace pt1 rad hgt)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Center : Variant (three-element array of doubles); input-only
A 3D WCS coordinates specifying the center of the bounding box.
G
Radius : Double; input-only
The cylinder radius. Must be a positive number.
G
Height : Double; input-only
The cylinder height. Must be a positive number.
G
RetVal : 3DSolid object
A 3DSolid object as the newly created cylinder.
G
Example :
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (setq pt (getpoint "\nCenter point: "))))
(setq rad (getdist "\nRadius: " pt))
(setq hgt (getdist "\nHeight: " pt))
(vla-addcylinder mspace pt1 rad hgt)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddCylinder Method
http://www.afralisp.com/methods/list/addcylinder_method.htm [23/03/2005 05:57:02 p.m.]
Search
AddDim3PointAngular Method
Back to Methods Reference
Creates an angular dimension using 3 points.
Signature
VBA : RetVal = object.AddDim3PointAngular(AngleVertex,FirstEndPoint,SecondEndPoint, TextPoint)
VL : RetVal = (vla-AddDim3PointAngular object AngleVertex FirstEndPoint SecondEndPoint TextPoint)
(vla-AddDim3PointAngular mspace pt1 pt2 pt3 pt4)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
AngleVertex : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the vertex of the angle to be measured.
G
FirstEndPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the point through which the first extension line passes.
G
SecondEndPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the point through which the second extension line passes.
G
TextPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the point at which the dimension text is to be displayed.
G
RetVal : Dim3PointAngular object
The newly created angular dimension.
G
Example :
(defun c:al-AddDim3PointAngular ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt1 (vlax-3d-point (setq pt (getpoint "Angle vertex point: "))))
(setq pt2 (vlax-3d-point (getpoint "1st extension point: " pt)))
(setq pt3 (vlax-3d-point (getpoint "2nd extension point: " pt)))
(setq pt4 (vlax-3d-point (getpoint "Text insertion point: ")))
(vla-adddim3pointangular mspace pt1 pt2 pt3 pt4)
(princ)

);defun

AddDim3PointAngular Method
http://www.afralisp.com/methods/list/adddim3pointangular_method.htm (1 of 2) [23/03/2005 05:57:03 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddDim3PointAngular Method
http://www.afralisp.com/methods/list/adddim3pointangular_method.htm (2 of 2) [23/03/2005 05:57:03 p.m.]
Search
AddDimAligned Method
Back to Methods Reference
Creates an aligned dimension object.
Signature
VBA : RetVal = object.AddDimAligned(ExtLine1Point, ExtLine2Point, TextPosition)
VL : RetVal = (vla-AddDimAligned object ExtLine1Point ExtLine2Point TextPosition)
(vla-AddDimAligned mspace pt1 pt2 pt3)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
ExtLine1Point : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first endpoint of the extension line.
G
ExtLine2Point : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second endpoint of the extension line.
G
TextPosition : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the text position.
G
RetVal : DimAligned object
The newly created aligned dimension.
G
Remarks
In aligned dimensions, the dimension line is parallel to the extension line origins. The extension line
origins are specified using the ExtLine1Point and ExtLine2Point properties.
Example :
(defun c:al-adddimaligned ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt1 (vlax-3d-point (setq pt
(getpoint "First alignment point: "))))
(setq pt2 (vlax-3d-point
(getpoint "Second alignment point: " pt)))
(setq pt3 (vlax-3d-point
(getpoint "Text insertion point: ")))
(vla-AddDimAligned mspace pt1 pt2 pt3)
(princ)
);defun

AddDimAligned Method
http://www.afralisp.com/methods/listb/adddimaligned_method.htm (1 of 2) [23/03/2005 05:57:04 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddDimAligned Method
http://www.afralisp.com/methods/listb/adddimaligned_method.htm (2 of 2) [23/03/2005 05:57:04 p.m.]
Search
AddLine Method
Back to Methods Reference
Creates a line passing through two points.
Signature :
VBA : RetVal =object.AddLine(StartPoint, EndPoint)
VL : RetVal =vla-AddLine Object StartPoint EndPoint
(setq aLine (vla-AddLine mSpace pt1 pt2))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
StartPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the line start point.
G
EndPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the line endpoint.
G
RetVal : Line object
The newly created Line object.
G
Example :
(defun c:al-addline ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq PT1 (getpoint "\nSpecify First Point: "))
(setq PT2 (getpoint "\nSpecify next point: " PT1))
(setq myline (vla-addline mspace (vlax-3d-point PT1)(vlax-3d-point PT2)))
(princ)
);defun
(princ)
;-------------------------------
;alternative method
(defun c:al-addline1 ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq util (vla-get-utility thisdrawing))
(setq PT1 (vla-getpoint util nil "\nSpecify First Point : "))
AddLine Method
http://www.afralisp.com/methods/list/addline_method.htm (1 of 2) [23/03/2005 05:57:05 p.m.]
(setq PT2 (vla-getpoint util PT1 "\nSpecify Second Point : "))
(setq myline (vla-addline mspace PT1 PT2))
(princ)
);defun
(princ)
;---------------------------

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddLine Method
http://www.afralisp.com/methods/list/addline_method.htm (2 of 2) [23/03/2005 05:57:05 p.m.]
Search
AddMtext Method
Back to Methods Reference
Creates an MText entity in a rectangle defined by the insertion point and width of the bounding box.
Signature
VBA : RetVal = object.AddMText(InsertionPoint, Width, Text)
VL : RetVal = (vla-AddMtext object InsertionPoint Width Text)
(vla-AddMText mspace (vlax-3d-point apt) wt thestring)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The insertion point of the mtext bounding box.
G
Width : Double; input-only
The width of the mtext bounding box.
G
Text : String; input-only
The actual text string for the MText object.
G
RetVal : MText object
The newly created MText object.
G
Example :
(defun c:al-addMText ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq apt (getpoint "\nInsertion Point: "))
(setq wt (getdist apt "\nWidth : "))
(setq thestring (getstring T "\nText : "))
(setq theMText (vla-AddMText mspace (vlax-3d-point apt) wt thestring))
(princ)
);defun

AddMtext Method
http://www.afralisp.com/methods/lista/addmtext_method.htm (1 of 2) [23/03/2005 05:57:05 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddMtext Method
http://www.afralisp.com/methods/lista/addmtext_method.htm (2 of 2) [23/03/2005 05:57:05 p.m.]
Search
AddPoint Method
Back to Methods Reference
Creates a Point object at a given location.
Signature
VBA : RetVal = object.AddPoint(Point)
VL : RetVal = (vla-AddPoint object Point)
(vla-AddPoint mspace (vlax-3d-point apt))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only
The coordinates of the point to be created.
G
RetVal : Point object
The newly created Point object.
G
Example :
(defun c:al-addpoint ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(while
(setq apt (getpoint "\nInsertion Point: "))
(setq thepoint (vla-AddPoint mspace (vlax-3d-point apt)))
);while
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
AddPoint Method
http://www.afralisp.com/methods/list/addpoint_method.htm (1 of 2) [23/03/2005 05:57:06 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddPoint Method
http://www.afralisp.com/methods/list/addpoint_method.htm (2 of 2) [23/03/2005 05:57:06 p.m.]
AddPolyline Method
Back to Methods Reference
Creates a polyline from a list of vertices.
Signature
VBA : RetVal = object.AddPolyline(VerticesList)
VL : RetVal = (vla-AddPolyline object VertricesList)
(vla-addPolyline mspace tmp)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
VerticesList : Variant (array of doubles); input-only
An array of OCS coordinates used to create the polyline vertices. Each vertex is represented
with three elements, with the first two being the X and Y coodinates in OCS; the third element is
ignored. At least two points (six elements) are required for constructing a polyline object. The
array size must be a multiple of three.
G
RetVal : Polyline object
The newly created Polyline object.
G
Remarks
To create a polyline containing arcs, first create the straight polyline, then set the bulge at specific
vertices using the SetBulge method.
This method exists for backward compatibility only. Use the new AddLightweightPolyline method to
create polylines with an optimized format that saves memory and disk space.
Coordinates can be converted to and from the OCS using the TranslateCoordinates method.
Example :
(defun c:al-addpolyline (/ pt ptlist tmp myobj a)
(setq thisdrawing
(vla-get-activedocument
(vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq pt (getpoint "\nSpecify start point: "))
;; Start by assembling a list of points
(setq ptlist (cons pt ptlist))
(while (setq pt (getpoint "\nSpecify next point: " pt))
(setq ptlist (cons pt ptlist))
)
;; "dissolve" the points into atoms with append:
(setq ptlist (apply 'append ptlist))
;; If number of coordinates in point list is not
;; a multiple of 3 then a polyline can't be made.
;; If it's a multiple of 3 then put the point
;; list into an array and pass it on to vla-addPolyline:
(if (= (rem (length ptlist) 3) 0)
(progn
AddPolyline Method
http://www.afralisp.com/methods/list/addpolyline_method.htm (1 of 3) [23/03/2005 05:57:07 p.m.]
(setq
tmp (vlax-make-safearray
vlax-vbDouble
(cons 0 (- (length ptlist) 1))
)
)
(vlax-safearray-fill tmp ptlist)
(setq myobj (vla-addPolyline mspace tmp))
)
(princ "\nerror: Polyline could not be created")
)
;; Just for the fun of it, convert every other segment
;; to a semicircle. First, get number of vertex points
;; and then set the bulge factor for every second point:
(if myobj
(progn
(setq coords (vla-get-coordinates myobj))
(setq coords (vlax-safearray->list
(vlax-variant-value
(vla-get-coordinates myobj))
)
)
(setq a 0)
(while (< a (/ (length coords) 3))
(if (= (rem a 2) 0)
(vla-setBulge myobj a 1.0)
)
(setq a (1+ a))
)
)
)
AddPolyline Method
http://www.afralisp.com/methods/list/addpolyline_method.htm (2 of 3) [23/03/2005 05:57:07 p.m.]
)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddPolyline Method
http://www.afralisp.com/methods/list/addpolyline_method.htm (3 of 3) [23/03/2005 05:57:07 p.m.]
Search
AddRaster Method
Back to Methods Reference
Creates a new raster image based on an existing image file.
Signature
VBA : RetVal = object.AddRaster(ImageFileName, InsertionPoint,
ScaleFactor, RotationAngle)
VL : RetVal = (vla-AddRaster object ImageFileName InsertionPoint
ScaleFactor RotationAngle)
(vla-AddRaster mspace "c:/AfraLisp.jpg" (vlax-3d-point IP) 1.0 0.0)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
ImageFileName : String; input-only
The full path and file name of the image.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates in the drawing where the raster image will be created.
G
ScaleFactor : Double; input-only
The raster image scale factor. The default image scale factor is 1. The scale factor must be a
positive number. You can set the scale of the image to the scale of the geometry created in the
AutoCAD drawing.
G
RotationAngle : Double; input-only
The rotation angle in radians for the raster image.
G
RetVal : Raster object
The newly created Raster object.
G
Remarks
Images placed through the AddRaster method are not actually part of the drawing file. The raster
image is linked to the drawing file through a path name or document ID. Linked image paths can be
changed or removed at any time by using the SupportPath property. By attaching images using linked
image paths you place images in your drawing without increasing the file size of the drawing.
You can add the same raster image file to your drawing file multiple times. Each instance has its own
clip boundary and its own settings for brightness, contrast, fade, and transparency. A single image
can be cut into multiple pieces that can be rearranged independently in your drawing.
Example :
(defun c:al-addRaster ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq IP (getpoint "\nInsertion Point: "))
;remember to substitute the path to your image.
(setq theraster (vla-AddRaster mspace
"c:/AfraLisp.jpg"
(vlax-3d-point IP) 1.0 0.0))
(princ)
);defun
AddRaster Method
http://www.afralisp.com/methods/lista/addraster_method.htm (1 of 2) [23/03/2005 05:57:08 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddRaster Method
http://www.afralisp.com/methods/lista/addraster_method.htm (2 of 2) [23/03/2005 05:57:08 p.m.]
Search
AddRay Method
Back to Methods Reference
Creates a ray passing through two unique points.
Signature
VBA: RetVal = object.AddRay(Point1, Point2)
VL : RetVal = (vla-AddRay object Point1 Point2)
(vla-addRay mspace (vlax-3d-point apt) (vlax-3d-point pt))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the finite start point of the ray.
G
Point2 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying a point through which the ray will pass. The ray extends
from Point1, through Point2 to infinity.
G
RetVal : Ray object
The newly created Ray object.
G
Example :
(defun c:al-addray ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq apt (getpoint "\nSpecify First Point: "))
(setq pt (getpoint "\nSpecify Second Point: " apt))
(setq myray (vla-addRay mspace (vlax-3d-point apt)
(vlax-3d-point pt)))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AddRay Method
http://www.afralisp.com/methods/lista/addray_method.htm (1 of 2) [23/03/2005 05:57:09 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddRay Method
http://www.afralisp.com/methods/lista/addray_method.htm (2 of 2) [23/03/2005 05:57:09 p.m.]
AddSolid Method
Back to Methods Reference
Creates a 2D solid polygon.
Signature
VBA : RetVal = object.AddSolid(Point1, Point2, Point3, Point4)
VL : RetVal = (vla-AddSolid Point1 Point2 Point3 Point4)
(vla-AddSolid mspace
(vlax-3d-point PT1)
(vlax-3d-point PT2)
(vlax-3d-point PT3)
(vlax-3d-point PT4))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only G
Point2 : Variant (three-element array of doubles); input-only G
Point3 : Variant (three-element array of doubles); input-only G
Point4 : Variant (three-element array of doubles); input-only G
RetVal : Solid object
The newly created polygon.
G
Remarks
The first two points define one edge of the polygon. The third point is defined diagonally opposite from
the second. If the fourth point is set equal to the third point, then a filled triangle is created.
Solids are filled only when the FILLMODE system variable is set to on. To set or query a system
variable, use the SetVariable and GetVariable methods, respectively.
Example :
(defun c:al-addSolid ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq PT1 (getpoint "\nFirst Point: "))
(setq PT2 (getpoint PT1 "\nSecond Point: "))
(setq PT3 (getpoint PT2 "\nThird Point: "))
(setq PT4 (getpoint PT3 "\nFourth Point: "))
(setq theSolid (vla-AddSolid mspace
(vlax-3d-point PT1)
(vlax-3d-point PT2)
(vlax-3d-point PT3)
(vlax-3d-point PT4)))
(princ)
);defun
AddSolid Method
http://www.afralisp.com/methods/lista/addsolid_method.htm (1 of 2) [23/03/2005 05:57:09 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddSolid Method
http://www.afralisp.com/methods/lista/addsolid_method.htm (2 of 2) [23/03/2005 05:57:09 p.m.]
Search
AddText Method
Back to Methods Reference
Creates a single line of text.
Signature
VBA: RetVal = object.AddText(TextString, InsertionPoint, Height)
VL : RetVal = (vla-AddText object TextString InsertionPoint Height)
(vla-AddText mspace thestring (vlax-3d-point apt) ht)
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
TextString : String; input-only
The actual text to be displayed.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates on the drawing where the text is placed.
G
Height : Double; input-only
The height of the text. Must be a positive number.
G
RetVal : Text object
The newly created Text object.
G
Example :
(defun c:al-addText ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq apt (getpoint "\nInsertion Point: "))
(setq thestring (getstring T "\nText : "))
(setq ht (getreal "\nHeight : "))
(setq thetext (vla-AddText mspace thestring
(vlax-3d-point apt) ht))
(princ)
);defun

AddText Method
http://www.afralisp.com/methods/lista/addtext_method.htm (1 of 2) [23/03/2005 05:57:10 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddText Method
http://www.afralisp.com/methods/lista/addtext_method.htm (2 of 2) [23/03/2005 05:57:10 p.m.]
Search
AddXLine Method
Back to Methods Reference
Creates an xline (an infinite line) passing through two specified points.
Signature
VBA : RetVal = object.AddXline(Point1, Point2)
VL : RetVal = (vla-addXLine object Point1 Point2)
(vla-addXline mspace
(vlax-3d-point apt)
(vlax-3d-point pt))
Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only G
Point2 : Variant (three-element array of doubles); input-only G
RetVal : XLine object
The newly created XLine object.
G
Example :
(defun c:al-addxline ()
(vl-load-com)
(setq mspace (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object))))
(setq apt (getpoint "\nSpecify First Point: "))
(setq pt (getpoint "\nSpecify Second Point: " apt))
(setq myxline (vla-addXline mspace
(vlax-3d-point apt)
(vlax-3d-point pt)))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
AddXLine Method
http://www.afralisp.com/methods/lista/addxline_method.htm (1 of 2) [23/03/2005 05:57:11 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AddXLine Method
http://www.afralisp.com/methods/lista/addxline_method.htm (2 of 2) [23/03/2005 05:57:11 p.m.]
AngleToString Method
Back to Methods Reference
Converts an angle from a real (double) value to a string.
Signature
VBA : RetVal = object.AngleToString(Angle, Unit, Precision)
VL : RetVal = (vla-AngleToString object Angle Unit Precision)
(vla-AngleToString util a acdegrees 3)
Object :Utility
The object or objects this method applies to.
G
Angle : Double; input-only G
Unit : AcAngleUnits enum; input-only
acDegrees
acDegreeMinuteSeconds
acGrads
acRadians
G
Precision : Integer; input-only
The precision of the angle. An integer between 0 and 8.
G
RetVal : String
The angle as a string.
G
Example :
(defun c:al-angletostring ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
(setq bpt (vla-getpoint util nil "\nSelect Base Point: "))
(setq a (vla-getangle util bpt "\nSelect Angle: "))
(setq thestring (vla-AngleToString util a acdegrees 3))
(princ thestring)
(princ)
);defun

AngleToString Method
http://www.afralisp.com/methods/lista/angletostring_method.htm (1 of 2) [23/03/2005 05:57:12 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AngleToString Method
http://www.afralisp.com/methods/lista/angletostring_method.htm (2 of 2) [23/03/2005 05:57:12 p.m.]
Search
ArrayPolar Method
Back to Methods Reference
Creates a polar array of objects given a NumberOfObjects, AngleToFill, and CenterPoint.
Signature
VBA : RetVal = object.ArrayPolar (NumberOfObjects, AngleToFill, CenterPoint)
VL : RetVal = (vla-ArrayPolar object NumberOfObjects AngleToFill CenterPoint)
(vla-ArrayPolar obj theinteger (dtr theangle) thepoint)
Object : All Drawing Objects
The object or objects this method applies to.
G
NumberOfObjects : Integer; input-only
The number of objects to be created in the polar array. This must be a positive integer greater
than 1.
G
AngleToFill : Double; input-only
The angle to fill in radians. A positive value specifies counterclockwise rotation. A negative
value specifies clockwise rotation. An error is returned for an angle that equals 0.
G
CenterPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the center point for the polar array.
G
RetVal : Variant Array (array of objects)
The array of new objects.
G
Remarks
AutoCAD determines the distance from the array's center point to a reference point on the last object
selected. The reference point used depends on the type of object previously selected. AutoCAD uses
the center point of a circle or arc, the insertion point of a block or shape, the start point of text, and
one endpoint of a line or trace.
Note that this method does not support the Rotate While Copying option of the AutoCAD ARRAY
command.
NOTE! You cannot execute this method while simultaneously iterating through a collection. An
iteration will open the work space for a read-only operation, while this method attempts to perform a
read-write operation. Complete any iteration before you call this method.
AttributeReference: You should not attempt to use this method on AttributeReference objects.
AttributeReference objects inherit this method because they are one of the drawing objects, however,
it is not feasible to perform this operation on an attribute reference.
Example :
(defun c:al-arraypolar ()
(vl-load-com)
(defun dtr (a)
(* pi (/ a 180))
);defun
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq thepoint (vla-GetPoint util nil
"\nSpecify center point of array or [Base]: "))
ArrayPolar Method
http://www.afralisp.com/methods/lista/arraypolar_method.htm (1 of 2) [23/03/2005 05:57:13 p.m.]
(setq theinteger (vla-GetInteger util
"\nEnter the number of items in the array: "))
(setq theangle (vla-GetReal util
"\nSpecify the angle to fill (+=ccw, -=cw): "))
(setq thearray (vla-ArrayPolar obj theinteger
(dtr theangle) thepoint))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ArrayPolar Method
http://www.afralisp.com/methods/lista/arraypolar_method.htm (2 of 2) [23/03/2005 05:57:13 p.m.]
Search
ArrayRectangular Method
Back to Methods Reference
Creates a 2D or 3D rectangular array of objects.
Signature
VBA : RetVal = object.ArrayRectangular (NumberOfRows, NumberOfColumns, NumberOfLevels,
DistBetweenRows, DistBetweenColumns, DistBetweenLevels)
VL : RetVal = (vla-ArrayRectangular object NumberOfRows NumberOfColumns NumberOfLevels
DistBetweenRows DistBetweenColumns DistBetweenLevels)
(vla-ArrayRectangular obj therows thecols thelevels drows dcols dlevels)
Object : All Drawing Objects
The object or objects this method applies to.
G
NumberOfRows : Integer; input-only
The number of rows in the rectangular array. This must be a positive number. If this number is 1,
then NumberOfColumns must be greater than 1.
G
NumberOfColumns : Integer; input-only
The number of columns in the rectangular array. This must be a positive number. If this number
is 1, then NumberOfRows must be greater than 1.
G
NumberOfLevels : Integer; input-only
The number of levels in a 3D array.
G
DistBetweenRows : Double; input-only
The distance between the rows. If the distance between rows is a positive number, rows are
added upward from the base entity. If the distance is a negative number, rows are added
downward.
G
DistBetweenColumns : Double; input-only
The distance between the columns. If the distance between columns is a positive number,
columns are added to the right of the base entity. If the distance is a negative number, columns
are added to the left.
G
DistBetweenLevels : Double; input-only
The distance between the array levels. If the distance between levels is a positive number, levels
are added in the positive direction from the base entity. If the distance is a negative number,
levels are added in the negative direction.
G
RetVal : Variant Array (array of objects)
The array of newly created objects.
G
Remarks
For a 2D array, specify the NumberOfRows, NumberOfColumns, DistBetweenRow, and
DistBetweenColumns. For creating a 3D array, specify the NumberOfLevels and DistBetweenLevels as
well.
A rectangular array is constructed by replicating the object in the selection set the appropriate number
of times. If you define one row, you must specify more than one column and vice versa.
The object in the selection set is assumed to be in the lower left-hand corner, and the array is
generated up and to the right. If the distance between rows is a negative number, rows are added
downward. If the distance between columns is a negative number, the columns are added to the left.
AutoCAD builds the rectangular array along a baseline defined by the current snap rotation angle. This
angle is zero by default, so the rows and columns of a rectangular array are orthogonal with respect to
the X and Y drawing axes. You can change this angle and create a rotated array by setting the snap
rotation angle to a nonzero value. To do this, use the SnapRotationAngle property.
NOTE! You cannot execute this method while simultaneously iterating through a collection. An
iteration will open the work space for a read-only operation, while this method attempts to perform a
read-write operation. Complete any iteration before you call this method.
AttributeReference: You should not attempt to use this method on AttributeReference objects.
AttributeReference objects inherit this method because they are one of the drawing objects, however,
it is not feasible to perform this operation on an attribute reference.
ArrayRectangular Method
http://www.afralisp.com/methods/lista/arrayrectangular_method.htm (1 of 3) [23/03/2005 05:57:14 p.m.]
Example :
(defun c:al-arrayrectangular ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq therows (vla-GetInteger util
"\nEnter the number of rows (---): "))
(setq thecols (vla-GetInteger util
"\nEnter the number of columns (|||): "))
(setq thelevels (vla-GetInteger util
"\nEnter the number of levels: "))
(setq drows (vla-GetReal util
"\nEnter the distance between rows (---): "))
(setq dcols (vla-GetReal util
"\nSpecify the distance between columns (|||): "))
(setq dlevels (vla-GetReal util
"\nSpecify the distance between levels: "))
(setq thearray (vla-ArrayRectangular obj therows thecols
thelevels drows dcols dlevels))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
ArrayRectangular Method
http://www.afralisp.com/methods/lista/arrayrectangular_method.htm (2 of 3) [23/03/2005 05:57:14 p.m.]
Search
Powered by CORBIMITE.com
ArrayRectangular Method
http://www.afralisp.com/methods/lista/arrayrectangular_method.htm (3 of 3) [23/03/2005 05:57:14 p.m.]
AuditInfo Method
Back to Methods Reference
Evaluates the integrity of the drawing.
Signature
VBA : object.AuditInfo FixError
VL : (vla-AuditInfo object FixError)
(vla-auditinfo thisdrawing 1)
Object : Document
The object or objects this method applies to.
G
FixError : Boolean; input-only
TRUE: AutoCAD should attempt to fix any problems it encounters.
FALSE: AutoCAD should not attempt to fix any problems it encounters.
G
Remarks
For every error detected, AutoCAD provides a description of the error and recommends corrective
action.
If you specify FixError = TRUE, AutoCAD will attempt to fix any errors it encounters.
Example :
(defun c:al-auditinfo ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))

(vla-auditinfo thisdrawing 1)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
AuditInfo Method
http://www.afralisp.com/methods/lista/auditinfo_method.htm [23/03/2005 05:57:14 p.m.]
Search
Clear Method
Back to Methods Reference
Clears the specified selection set of all items.
Signature
VBA : object.Clear
VL : (vla-Clear object)
(vla-Clear newSset)
Object : SelectionSet
The object or objects this method applies to.
G
Remarks
Items cleared from a selection set remain in the drawing; they are simply no longer associated to the
selection set.
To clear a subset of the items in a selection set, use the RemoveItems method.
This method differs from the Delete method in that it does not remove objects from the drawing.
Example :
;Example:
;In the following sample code, a new selection set is created
;by name if it doesn't already exist. It is merely populated
;by picking objects on the screen and then emptied.
;After completion, the selection set still exists, but is empty.
;This is kind of a silly example, but it shows a way to use the method.
(defun c:al-Clear (/ acadobj doc ssetCollection a flag)
(setq acadobj (vlax-get-acad-object)
doc (vla-get-activedocument acadobj)
;;get hold of the selectionSet Collection
ssetCollection (vla-get-selectionsets doc)
a 0
)
(repeat (setq w (vla-get-count ssetCollection))
(if (= (vla-get-name (vla-item ssetCollection a)) "NEW_SET")
(setq flag T)
)
(setq a (1+ a))
)
;;check if the selectionSet already exists - otherwise, create it
(if (null flag)
(setq newSset (vla-add ssetCollection "NEW_SET"))
)
;;let the user select objects on screen
(vla-selectOnScreen newSset)
;;report the number of objects held in selectionSet
(mapcar 'princ
(list "\n"
(vla-get-count newSset)
" objects were added to the selection set"
)
)
;;clear the selectionSet
(vla-Clear newSset)
Clear Method
http://www.afralisp.com/methods/list/clear_method.htm (1 of 2) [23/03/2005 05:57:15 p.m.]
;;report result
(mapcar 'princ
(list "\nAfter clearing, the selection set now holds "
(vla-get-count newSset)
" objects"
)
)
(princ)
)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Clear Method
http://www.afralisp.com/methods/list/clear_method.htm (2 of 2) [23/03/2005 05:57:15 p.m.]
Search
Copy Method
Back to Methods Reference
Duplicates the given object to the same location.
Signature
VLA : RetVal = object.Copy
VL : RetVal = (vla-copy object)
(setq newobj (vla-copy object))
Object : All Drawing Objects G
RetVal Object
The newly created duplicate object.
G
Remarks
AttributeReference: You should not attempt to use this method on AttributeReference objects.
AttributeReference objects inherit this method because they are one of the drawing objects, however,
it is not feasible to perform this operation on an attribute reference.
NOTE You cannot execute this method while simultaneously iterating through a collection. An iteration
will open the work space for a read-only operation, while this method attempts to perform a read-write
operation. Complete any iteration before you call this method.
Example :
(defun c:al-copy ()
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;copy the object
(setq newobj (vla-copy theobj))
;move the object
(vla-move newobj BP PT2)
(princ)
);defun
(princ)

Copy Method
http://www.afralisp.com/methods/list/copy_method.htm (1 of 2) [23/03/2005 05:57:16 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Copy Method
http://www.afralisp.com/methods/list/copy_method.htm (2 of 2) [23/03/2005 05:57:16 p.m.]
Search
CreateTypedArray Method
Back to Methods Reference
Creates a variant that contains an array of typed arguments.
Signature
VBA : Object.CreateTypedArray(VarArr, Type, Value1, [value2, value3, ...valueN])
VL : vla-CreateTypedArray Object VarArr Type Value1 [value2 value3 ...valueN]
(vla-CreateTypedArray util 'thearray vlax-vbDouble 1.2 2.3 0.0)
Object : Utility
The object or objects this method applies to.
G
VarArr : Variant; output-only
The array of values as a variant.
G
Type : Visual Lisp Constant; input-only
The type of values you are supplying.
vbBoolean, vbInteger, vbLong, vbSingle, or vbDouble.
G
Value1 [Value2, ...ValueN.]
Of the type specified in the Type parameter above; input-only
The value(s) to be included in the variant.
G
Remarks
The resulting variant can be passed into any AutoCAD method or property that accepts an array of
numbers as a variant.
Example :
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
(vla-createtypedarray util 'thearray vlax-vbDouble 1.2 2.3 0.0)
;Your safearray is stored in the variable "thearray"

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
CreateTypedArray Method
http://www.afralisp.com/methods/list/createtypedarray_method.htm (1 of 2) [23/03/2005 05:57:17 p.m.]
Search
Powered by CORBIMITE.com
CreateTypedArray Method
http://www.afralisp.com/methods/list/createtypedarray_method.htm (2 of 2) [23/03/2005 05:57:17 p.m.]
Delete Method
Back to Methods Reference
Deletes a specified object.
Signature
VBA : object.Delete Name
VL : (vla-Delete object Name)
(vla-delete (vla-item ssets "$Set"))
Object : All Drawing Objects, Block, Dictionary, DimStyle, Group, Hyperlink, Layer, Layout,
Linetype, PlotConfiguration , PopupMenuItem, PViewport, RegisteredApplication, SelectionSet,
TextStyle, Toolbar, ToolbarItem, UCS, View, Viewport, XRecord
G
Name : The object or objects this method applies to. G
Remarks
When you delete an object in a collection, all remaining items in the collection are reassigned a new
index based on the current count. You should therefore avoid loops that delete an object while
iterating through the collection.
Although most collections inherit a Delete method, you cannot actually delete collections. Attempting
to delete a collection will result in an error, therefore the Delete method has been removed from the
documentation for all collections.
ToolbarItem: You can only add or remove toolbar items when the toolbar is visible.
Example :
(defun c:al-select ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if
(vla-Select newSet acSelectionSetAll)
(princ)
);defun
Delete Method
http://www.afralisp.com/methods/list/delete_method.htm (1 of 2) [23/03/2005 05:57:18 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Delete Method
http://www.afralisp.com/methods/list/delete_method.htm (2 of 2) [23/03/2005 05:57:18 p.m.]
Search
DeleteProfile Method
Back to Methods Reference
Deletes the specified profile.
Signature
VBA : object.DeleteProfile ProfileName
VL : (vla-DeleteProfile object ProfileName)
(vla-DeleteProfile acadprofiles "Afralisp")
Object : PreferencesProfiles
The object or objects this property applies to.
G
ProfileName : String
The name of the profile to delete.
G
Example :
(defun c:al-deleteprofile ()
(vl-load-com)
(setq acadprofiles (vla-get-profiles
(vla-get-preferences
(vlax-get-Acad-Object))))
(vla-DeleteProfile acadprofiles "Afralisp")

(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
DeleteProfile Method
http://www.afralisp.com/methods/list/deleteprofile_method.htm [23/03/2005 05:57:18 p.m.]
Search
EndUndoMark Method
Back to Methods Reference
Marks the end of a block of operations.
Signature
VBA : object.EndUndoMark
VL : (vla-EndUndoMark object)
(vla-endundomark thisdrawing)
Object : Document
The object or objects this method applies to.
G
Remarks
This method allows AutoCAD to close the environment so operations from StartUndoMark to
EndUndoMark can be treated as a group of operations.
Example :
(defun c:al-undomark ()
;This example creates a series of lines, each one with an undo marker
;defined for it. After lines are created you can switch to AutoCAD
and type the Undo command, and only one line at a time will be undone.
;If StartUndoMark call is not made, an undo in AutoCAD will undo
;all the lines at once.
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(repeat 3
(setq pt1 (getpoint "\nSpecify First Point: "))
(setq pt2 (getpoint "\nSpecify Second Point: " pt1))
(vla-startundomark thisdrawing)
(setq myline (vla-addline mspace
(vlax-3d-point pt1)(vlax-3d-point pt2)))
(vla-endundomark thisdrawing)
);repeat
(princ)
);defun

EndUndoMark Method
http://www.afralisp.com/methods/lista/endundomark_method.htm (1 of 2) [23/03/2005 05:57:19 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
EndUndoMark Method
http://www.afralisp.com/methods/lista/endundomark_method.htm (2 of 2) [23/03/2005 05:57:19 p.m.]
Search
Eval Method
Back to Methods Reference
Evaluates an expression in VBA.
Signature
VBA : object.Eval(Expression)
VL : (val-Eval Expression)
(vla-eval applic (strcat "MsgBox \"Hello Everybody\"" ", " "vbInformation" ", " "\"AfraLisp\""))
Object : Application
The object or objects this method applies to.
G
Expression : String; input-only
The expression to be evaluated.
G
Remarks
This method allows Automation clients to execute a line of VBA code in the context of the current
project without creating modules and functions.
Example :
(defun c:al-eval ()
(vl-load-com)
(setq applic (vlax-get-acad-object))
(vla-eval applic (strcat "MsgBox \"Hello Everybody\"" ", "
"vbInformation" ", " "\"AfraLisp\""))
(vla-eval applic (strcat "MsgBox \"Are You Fine?\"" ", "
"vbQuestion" ", " "\"CAD Encoding\""))
(vla-eval applic (strcat "MsgBox \"Or, are you not Well?\"" ", "
"vbCritical" ", " "\"VBA Expresso\""))
(alert "\nAnd this is the boring\nAutoCAD message box!!")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Eval Method
http://www.afralisp.com/methods/list/eval_method.htm (1 of 2) [23/03/2005 05:57:20 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Eval Method
http://www.afralisp.com/methods/list/eval_method.htm (2 of 2) [23/03/2005 05:57:20 p.m.]
Explode Method
Back to Methods Reference
Explodes the compound object into subentities.
Signature
VBA : RetVal = object.Explode
VL : RetVal = (vla-Explode object)
(vla-Explode obj)
Object : 3DPolyline , BlockRef, LightweightPolyline, MInsertBlock, Polygonmesh, Polyline,
Region
The object or objects this method applies to.
G
RetVal : Variant (array of objects)
The array of exploded objects.
G
Remarks
Depending on the type of compound object you're exploding, different results occur. Refer to the
EXPLODE command topic in the AutoCAD Command Reference for a detailed list of explodable
objects and their results.
You do not have to explode a block in order to manipulate its constituent entities. All block definitions
have an Item method that allow you to manaipulte the entities within the block without exploding the
block definition itself.
Example :
(defun c:al-explode ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq objs (vla-Explode obj))
(princ objs)
(princ)
);defun

Explode Method
http://www.afralisp.com/methods/lista/explode_method.htm (1 of 2) [23/03/2005 05:57:21 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Explode Method
http://www.afralisp.com/methods/lista/explode_method.htm (2 of 2) [23/03/2005 05:57:21 p.m.]
Search
ExportProfile Method
Back to Methods Reference
Exports the active profile so it can be shared with other users.
Signature
VBA : object.ExportProfile Profile, RegFile
VL : (vla-ExportProfile object Profile RegFile)
(vla-ExportProfile acadprofiles "Afralisp" "c:/afralisp.arg")
Object : PreferencesProfiles
The object or objects this property applies to.
G
Profile : String; input-only
The name of the profile to be exported.
G
RegFile : String; input-only
The name of the file the profile will be exported to. The extension of the file should be arg.
G
Example :
(defun c:al-exportprofile ()
(vl-load-com)
(setq acadprofiles (vla-get-profiles
(vla-get-preferences
(vlax-get-Acad-Object))))
(vla-ExportProfile acadprofiles
"Afralisp" "c:/afralisp.arg")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ExportProfile Method
http://www.afralisp.com/methods/list/exportprofile_method.htm [23/03/2005 05:57:22 p.m.]
Search
GetAcadState Method
Back to Methods Reference
Gets an AcadState object to monitor the state of AutoCAD from out-of-process applications.
Signature
VBA : RetVal = object.GetAcadState()
VL : RetVal = (vla-GetAcadState object)
(vla-GetAcadState applic)
Object : Application
The object or objects this method applies to.
G
RetVal : AcadState
An object containing an IsQuiescent property used to monitor the state of AutoCAD.
G
Remarks
It is recommended that you call this method immediately after acquiring the AutoCAD appplication
object. This is the best opportunity to catch AutoCAD in a quiescent state.
Example :
(defun c:al-getacadstate ()
(vl-load-com)
(setq applic (vlax-get-acad-object))
(setq state (vla-GetAcadState applic))
(princ state)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetAcadState Method
http://www.afralisp.com/methods/lista/getacadstate_method.htm [23/03/2005 05:57:22 p.m.]
Search
GetAllProfileNames Method
Back to Methods Reference
Gets all available profiles for the system.
Signature
VBA : object.GetAllProfileNames(pNames)
VL : (vla-GetAllProfileNames object pNames)
(vla-GetAllProfileNames acadprofiles 'thelist)
Object : PreferencesProfiles
The object or objects this method applies to.
G
pNames : Variant (array of strings)
The array of available profile names for the system.
G
Example :
(defun c:al-getallprofilenames ()
(vl-load-com)
(setq acadprofiles (vla-get-profiles
(vla-get-preferences
(vlax-get-Acad-Object))))
(vla-GetAllProfileNames acadprofiles 'thelist)
(setq thelist (vlax-safearray->list thelist))
(princ thelist)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetAllProfileNames Method
http://www.afralisp.com/methods/list/getallprofilenames_method.htm [23/03/2005 05:57:23 p.m.]
Search
GetAngle Method
Back to Methods Reference
Gets the angle specified. Considers the setting of the ANGBASE system variable.
Signature
VLA : RetVal = Object.GetAngle([Point][, Prompt])
VL : RetVal = (vla-GetAngle Object Point Prompt)
(vla-getangle util nil "\nSelect Angle: ")
Object Utility
The object or objects this method applies to.
G
Point Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying the first point.
G
Prompt Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal Double
The angle specified.
G
Remarks
AutoCAD pauses for user input of an angle and sets the return value to the value of the selected angle.
The Point parameter specifies an angle base point in the two-dimensional WCS. The Prompt parameter
specifies a string that AutoCAD displays before it pauses. Both Point and Prompt are optional.
The AutoCAD user can specify the angle by entering a number in the current angular units format. The
user can set the angle also by specifying two 2D locations on the graphics screen. AutoCAD draws a
rubber-band line from the first point to the current crosshair position to help the user visualize the
angle. If the Point parameter is provided, AutoCAD uses this value as the first of the two points. The
angle is measured in the XY plane of the WCS (GetAngle ignores the Z field of Point).
Regardless of the method used to specify the angle, GetAngle always sets the return value to a value
expressed in radians. The direction of angular increase is always counterclockwise.
This function is almost identical to GetOrientation, but it takes into account the current value of the
ANGBASE system variable. For GetOrientation, the zero angle is always to the right: "east" or "three
o'clock." For GetAngle, the zero angle is the value of ANGBASE, which can be set to any of the four
90-degree quadrants. Both GetAngle and GetOrientation return a (real) angle value in radians
measured counterclockwise from a base (zero) angle. For GetAngle, the base equals ANGBASE; for
GetOrientation, the base is at the right. Both functions honor the current value of ANGDIR, which
affects the value the user enters but not the value that these functions return.
User input
(degrees)
GetAngle
returns
GetOrientation returns
0 0.0 1.5708
-90 1.5708 3.14159
180 3.14159 4.71239
90 4.71239 0.0
You can use GetAngle to obtain a rotation amount for a block insertion, because an input of 0 degrees
always returns 0 radians. You can use GetOrientation to obtain the baseline angle for a text entity to be
aligned with other objects.
If a keyword is returned instead of an angle, AutoCAD will generate the error message "User input
keyword." Use the GetInput method to obtain the keyword from the return value.
Example :
GetAngle Method
http://www.afralisp.com/methods/list/getangle_method.htm (1 of 2) [23/03/2005 05:57:24 p.m.]
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
(setq a (vla-getangle util nil "\nSelect Angle: "))
;Let's give it a base point :
(setq bpt (vla-getpoint util nil "/nSelect Base Point: "))
;And use it to "rubber band" :
(setq a (vla-getangle util bpt "\nSelect Angle: "))

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetAngle Method
http://www.afralisp.com/methods/list/getangle_method.htm (2 of 2) [23/03/2005 05:57:24 p.m.]
Search
GetBoundingBox Method
Back to Methods Reference
Gets two points of a box enclosing the specified object.
Signature
VBA : object.GetBoundingBox MinPoint, MaxPoint
VL : (vla-GetBoundingBox object MinPoint Maxpoint)
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
Object : All Drawing Objects, AttributeReference
The object or objects this method applies to.
G
MinPoint : Variant (three-element array of doubles); output-only
The 3D WCS coordinates specifying the minimum point of the object's bounding box.
G
MaxPoint : Variant (three-element array of doubles); output-only
The 3D WCS coordinates specifying the maximum point of the object's bounding box.
G
Remarks
The corners are returned in WCS coordinates with the box edges parallel to the WCS X, Y, and Z axes.
Example :
(defun c:al-getboundingbox ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
;minpoint contains the minimum point of the bounding box
;maxpoint contains the maximum point of the bounding box
(princ minpoint)
(terpri)
(princ maxpoint)
(princ)
);defun

GetBoundingBox Method
http://www.afralisp.com/methods/lista/getboundingbox_method.htm (1 of 2) [23/03/2005 05:57:25 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetBoundingBox Method
http://www.afralisp.com/methods/lista/getboundingbox_method.htm (2 of 2) [23/03/2005 05:57:25 p.m.]
Search
GetCorner Method
Back to Methods Reference
Gets a corner of a rectangle.
Signature
VBA : RetVal = object.GetCorner(Point[, Prompt])
VL : RetVal = (vla-GetCorner object Point Prompt)
(vla-GetCorner util pt1 "\nSecond Corner : ")
Object : Utility
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the base point of the rectangle.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : Variant (three-element array of doubles)
The 3D WCS coordinates representing the corner of the rectangle.
G
Remarks
AutoCAD pauses for user input of the corner of a rectangle, and sets the return value to the value of
the selected point. The Point parameter specifies the base point of the rectangle in the 3D WCS
coordinates; this parameter is required. The Prompt parameter specifies a string that AutoCAD
displays before it pauses. The prompt is optional.
The AutoCAD user can specify the corner by entering a point in the WCS coordinate format; GetCorner
treats Point as a three-dimensional point. The user can specify the corner also by specifying a location
on the graphics screen. AutoCAD draws a dynamically sized rectangle from Point to the current
crosshair position to help the user visualize the location of the second corner. The rectangle is drawn
in the XY plane of the WCS. When the pointing device is used, GetCorner ignores the Z field of Point
and sets the Z field of result to the current elevation.
Example :
(defun c:al-getcorner ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq pt1 (vla-GetPoint util nil "\nFirst Corner : "))
(setq cnr (vla-GetCorner util pt1 "\nSecond Corner : "))
(princ pt1)
(terpri)
(princ cnr)
(princ)
);defun

GetCorner Method
http://www.afralisp.com/methods/lista/getcorner_method.htm (1 of 2) [23/03/2005 05:57:26 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetCorner Method
http://www.afralisp.com/methods/lista/getcorner_method.htm (2 of 2) [23/03/2005 05:57:26 p.m.]
Search
GetDistance Method
Back to Methods Reference
Gets the distance from the prompt line or a selected set of points on the screen.
Signature
VBA : RetVal =Object.GetDistance([Point][, Prompt])
VL : RetVal =(vla-GetDistance Object Point Prompt)
(setq dist (vla-GetDistance util pt1 "\nFirst Point"))
Object : Utility
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying the base point. If this point is not provided, the user must
input two points.
G
Prompt : Variant (string); input-only; optional
The text to display to prompt the user for input.
G
RetVal : Variant (double or array of doubles)
The distance from the prompt line or a selected set of points on the screen.
G
Remarks
AutoCAD pauses for user input of a linear distance and sets the return value to the value of the
selected distance. The Point parameter specifies a base point in WCS coordinates. The Prompt
parameter specifies a string that AutoCAD displays before it pauses. Both Point and Prompt are
optional.
The AutoCAD user can specify the distance by entering a number in the current units format. The user
can also set the distance by specifying two locations on the graphics screen. AutoCAD draws a
rubber-band line from the first point to the current crosshair position to help the user visualize the
distance. If the Point parameter is provided, AutoCAD uses this value as the first of the two points.
By default, GetDistance treats Point and the return value as three-dimensional points. A prior call to
the InitializeUserInput method can force Point to be two-dimensional, ensuring that this method
returns a planar distance.
Regardless of the method used to specify the distance or the current linear units (for example, feet and
inches), this method always sets the return value to a double-precision floating-point value.
Example :
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq dist (vla-getdistance util nil "\nFirst Point : \n"))
(setq dist (vla-getdistance util PT1 "\nSecond Point : \n"))

GetDistance Method
http://www.afralisp.com/methods/list/getdistance_method.htm (1 of 2) [23/03/2005 05:57:26 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetDistance Method
http://www.afralisp.com/methods/list/getdistance_method.htm (2 of 2) [23/03/2005 05:57:26 p.m.]
Search
GetEntity Method
Back to Methods Reference
Gets an object interactively.
Signature
VBA : object.GetEntity Object, PickedPoint[, Prompt]
VL : (vla-GetEntity Object Object PickedPoint Prompt)
(vla-getentity util 'obj 'ip "\nSelect Object: ")
Object : Utility
The object or objects this method applies to.
G
Object : Object; output-only
The picked object. Can be one of any of the Drawing Objects.
G
PickedPoint : Variant (three-element array of doubles); output-only
A 3D WCS coordinate specifying the point that was selected.
G
Prompt : Variant (string); input-only; optional
The text to display to prompt the user for input.
G
Remarks
This method requires the AutoCAD user to select an object by picking a point on the graphics screen. If an
entity is picked, it is returned in the first parameter and the second parameter will contain the point picked
in WCS coordinates. If the pick point is not on an entity the call will fail.
The pick point returned by GetEntity does not necessarily lie on the selected object. The returned point
represents the location of the crosshairs at the time of selection. The relationship between this point and
the object varies depending on the size of the pickbox and the current zoom scale.
This method can retrieve an entity even if it is not visible on the screen or if it is on a frozen layer.
Example :
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
The reference to the Object is stored in the variable "obj"
and the pickpoint is stored in variable "ip" in the form of a safearray.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
GetEntity Method
http://www.afralisp.com/methods/list/getentity_method.htm (1 of 2) [23/03/2005 05:57:27 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetEntity Method
http://www.afralisp.com/methods/list/getentity_method.htm (2 of 2) [23/03/2005 05:57:27 p.m.]
GetFont Method
Back to Methods Reference
Gets the definition data of the font for the TextStyle.
Signature
VBA : object.GetFont Typeface, Bold, Italic, CharSet, PitchAndFamily
VL : (vla-GetFont object Typeface, Bold, Italic, CharSet, PitchAndFamily)
(vla-GetFont thestyle 'typeface 'bold 'italic 'charset 'pitchandfamily)
Object : TextStyle
The object or objects this method applies to.
G
Typeface : String; output-only
The typeface (font name) of the TextStyle you queried.
G
Bold : Boolean; output-only
Specifies if the TextStyle is bold.
TRUE: The TextStyle is bold.
FALSE: The TextStyle is not bold.
G
Italic : Boolean; output-only
Specifies if the TextStyle is italic.
TRUE: The TextStyle is italic.
FALSE: The TextStyle is not italic.
G
CharSet : Long; output-only
The character set for the font. (See the available values in the Remarks section.)
G
PitchAndFamily : Long; output-only
The pitch and family definitions for the font. (See the available values in the Remarks section.)
G
Example :
(defun c:al-getfont ()
(vl-load-com)
(setq thestyle (vla-get-activetextstyle
(vla-get-activedocument
(vlax-get-acad-object))))
(vla-GetFont thestyle 'typeface 'bold 'italic
'charset 'pitchandfamily)
;typeface contains the font name
;bold contains a boolean value
;italic contains a boolean value
;charset contains the character set value
;pitchandfamily contains the pitch and family value
(princ typeface)
(terpri)
(princ bold)
(terpri)
(princ italic)
(terpri)
(princ charset)
(terpri)
(princ pitchandfamily)

GetFont Method
http://www.afralisp.com/methods/lista/getfont_method.htm (1 of 2) [23/03/2005 05:57:28 p.m.]
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetFont Method
http://www.afralisp.com/methods/lista/getfont_method.htm (2 of 2) [23/03/2005 05:57:28 p.m.]
Search
GetInteger Method
Back to Methods Reference
Gets an integer value from the user.
Signature
VBA : RetVal = object.GetInteger([Prompt])
VL : RetVal = (vla-GetInteger object Prompt)
(vla-GetInteger util "\nEnter Integer : ")
Object : Utility
The object or objects this method applies to.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : Integer
The integer value returned by the user.
G
Remarks
AutoCAD pauses for user input of an integer and sets the return value to the selected value. The
Prompt parameter specifies a string that AutoCAD displays before it pauses. The Prompt is optional.
The AutoCAD user can enter any valid (short) integer in the range of -32,768 to +32,767.
If a keyword is returned instead of an integer, or if the user presses ENTER without entering a value,
AutoCAD generates error number -2145320928 (and the error message, "User input is a keyword"). Use
the GetInput method to obtain the keyword from the return value.
Example :
(defun c:al-getinteger ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq theinteger (vla-GetInteger util "\nEnter Integer : "))
(princ theinteger)
(princ)
);defun

GetInteger Method
http://www.afralisp.com/methods/lista/getinteger_method.htm (1 of 2) [23/03/2005 05:57:29 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetInteger Method
http://www.afralisp.com/methods/lista/getinteger_method.htm (2 of 2) [23/03/2005 05:57:29 p.m.]
Search
GetOrientation Method
Back to Methods Reference
Gets the angle specified. Ignores the setting of the ANGBASE system variable.
Signature
VBA : RetVal = object.GetOrientation([Point][, Prompt])
VL : RetVal = (vla-GetOrientation object Point Prompt)
(vla-GetOrientation util nil "\nBase Point:\n")
Object : Utility
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying the base point.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : Double
The specified angle.
G
Remarks
AutoCAD pauses for user input of an angle, and sets the return value to the value of the selected
angle. The Point parameter specifies an angle base point in the WCS. The Prompt parameter specifies
a string that AutoCAD displays before it pauses. Both Point and Prompt are optional.
The AutoCAD user can specify the angle by entering a number in the current angular units format. The
user can specify the angle also by specifying two 2D locations on the graphics screen. AutoCAD
draws a rubber-band line from the first point to the current crosshair position to help the user visualize
the angle. If the Point parameter is provided, AutoCAD uses this value as the first of the two points.
The angle is measured in the XY plane of the WCS (this method ignores the Z field of Point). The
direction of angular increase is always counterclockwise.
Regardless of the method used to specify the angle, GetOrientation always sets the return value to a
value expressed in radians.
This method is similar to the GetAngle method, but it ignores the current direction of angle 0, which is
stored in the ANGBASE system variable. The 0 angle employed by GetOrientation is always to the
right: "east" or "three o'clock."
If a keyword is returned instead of an angle AutoCAD will generate the error message "User input
keyword." Use the GetInput method to obtain the keyword from the return value.
Example :
(defun c:al-getorientation ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq ort (vla-GetOrientation util nil "\nBase Point:\n"))
(princ ort)
(princ)
);defun
GetOrientation Method
http://www.afralisp.com/methods/lista/getorientation_method.htm (1 of 2) [23/03/2005 05:57:30 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetOrientation Method
http://www.afralisp.com/methods/lista/getorientation_method.htm (2 of 2) [23/03/2005 05:57:30 p.m.]
Search
GetPoint Method
Back to Methods Reference
Gets the point selected in AutoCAD.
Signature
VBA : RetVal = object.GetPoint([Point][, Prompt])
VL : RetVal = (vla-GetPoint object Point Prompt)
(vla-GetPoint util nil "\nFirst Point : ")
Object : Utility
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying the relative base point.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : Variant (three-element array of doubles)
The 3D WCS coordinates of the point the AutoCAD user has selected.
G
Remarks
AutoCAD pauses for user input of a point, and sets the return value to the value of the selected point.
The Point parameter specifies a relative base point in the WCS. The Prompt parameter specifies a
string that AutoCAD displays before it pauses. Both Point and Prompt are optional.
The AutoCAD user can specify the point by entering a coordinate in the current units format; GetPoint
treats the Point parameter and the return value as three-dimensional points. The user can specify the
point also by specifying a location on the graphics screen. If the Point parameter is provided,
AutoCAD draws a rubber-band line from Point to the current crosshair position.
The coordinates of the point stored in the return value are expressed in terms of the WCS.
If a keyword is returned instead of a point, AutoCAD will generate the error message "User input
keyword." Use the GetInput method to obtain the keyword from the return value.
Example :
(defun c:al-getpoint ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq thepoint (vla-GetPoint util nil "\nFirst Point : "))
(princ thepoint)
(princ)
);defun

GetPoint Method
http://www.afralisp.com/methods/lista/getpoint_method.htm (1 of 2) [23/03/2005 05:57:31 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetPoint Method
http://www.afralisp.com/methods/lista/getpoint_method.htm (2 of 2) [23/03/2005 05:57:31 p.m.]
Search
GetReal Method
Back to Methods Reference
Gets a real (double) value from the user.
Signature
VBA : RetVal = object.GetReal([Prompt])
VL : RetVal = (vla-GetReal object Prompt)
(vla-GetReal util "\nEnter Real Number : ")
Object : Utility
The object or objects this method applies to.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : Double
The value returned from the user.
G
Remarks
AutoCAD pauses for user input of a real value, and sets the return value to the value that the user
enters. The Prompt parameter specifies a string that AutoCAD displays before it pauses. The prompt is
optional.
If a keyword is returned instead of a double, AutoCAD will generate the error message "User input
keyword." Use the GetInput method to obtain the keyword from the return value.
Example :
(defun c:al-getreal ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq thereal (vla-GetReal util "\nEnter Real Number : "))
(princ thereal)
(princ)
);defun

GetReal Method
http://www.afralisp.com/methods/lista/getreal_method.htm (1 of 2) [23/03/2005 05:57:31 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetReal Method
http://www.afralisp.com/methods/lista/getreal_method.htm (2 of 2) [23/03/2005 05:57:31 p.m.]
Search
GetString Method
Back to Methods Reference
Gets a string from the user.
Signature
VLA : RetVal =Object,GetString(HasSpaces[, Prompt])
VL : RetVal =(vla- GetString Object HasSpaces Prompt)
(setq thestring (vla-GetString util 0 "\nEnter your name : "))
Object : Utility G
HasSpaces : Integer; input-only
TRUE: The return string can contain spaces. It is terminated by a carriage return only.
FALSE: The return string may not contain spaces. It is terminated by a carriage return or space.
G
Prompt : Variant (string); input-only; optional
The text used to prompt the user for input.
G
RetVal : String
The string returned from the user.
G
Remarks
AutoCAD pauses for user input of the string, and sets the result to the string that the user enters. The
HasSpaces parameter specifies whether the string can contain spaces. The Prompt parameter
specifies a string that this method displays before AutoCAD pauses.
The AutoCAD user can enter the string from the keyboard. If the HasSpaces parameter is TRUE, the
string can contain blanks and the user must terminate it by entering [Return]. If HasSpaces is False,
entering either a blank or [Return] terminates the string. If the user enters more than 132 characters,
string entry continues until the user enters a blank or carriage return (according to HasSpaces), but
GetString places only the first 132 characters into the return value.
Example :
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

;no spaces allowed
(setq s (vla-getstring util 0 "Enter String: "))
;spaces allowed
(setq s (vla-getstring util 1 "Enter String: "))

You are visitor number



Web afralisp.com
GetString Method
http://www.afralisp.com/methods/list/getstring_method.htm (1 of 2) [23/03/2005 05:57:32 p.m.]
Search
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetString Method
http://www.afralisp.com/methods/list/getstring_method.htm (2 of 2) [23/03/2005 05:57:32 p.m.]
GetVariable Method
Back to Methods Reference
Gets the current setting of an AutoCAD system variable.
Signature
VBA : RetVal = object.GetVariable(Name)
VL : RetVal = (vla-GetVariable object Name)
(vla-GetVariable thisdrawing "OSMODE")
Object : Document
The object or objects this method applies to.
G
Name : String; input-only
The name of the variable to return. Must contain a valid system variable name (the case of the
characters is not significant).
G
RetVal : Variant
The value of the specified system variable.
G
Remarks
For a list of all the AutoCAD system variables and their types, please refer to System Variables.
Example :
(defun c:al-getvar ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq thevar (vla-GetVariable thisdrawing "OSMODE"))
(princ thevar)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
GetVariable Method
http://www.afralisp.com/methods/lista/getvar_method.htm (1 of 2) [23/03/2005 05:57:33 p.m.]
Search
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
GetVariable Method
http://www.afralisp.com/methods/lista/getvar_method.htm (2 of 2) [23/03/2005 05:57:33 p.m.]
HighLight Method
Back to Methods Reference
Sets the highlight status for the given object, or for all objects in a given selection set.
Signature
VBA : object.Highlight HighlightFlag
VL : (vla-HighLight object HighlightFlag)
(vla-Highlight obj 1)
Object : All Drawing Objects, SelectionSet, AttributeReference, Group
The object or objects this method applies to.
G
HighlightFlag :: Boolean; input-only
TRUE: The object is highlighted.
FALSE: The existing highlight is removed from the object.
G
Remarks
Once the highlight flag for an object has been set, a call to the Update or Regen method is required to
view the change.
Note that this function does not return the current highlight status of an object.
Example :
(defun c:al-highlight ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(vla-Highlight obj 1)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
HighLight Method
http://www.afralisp.com/methods/lista/highlight_method.htm (1 of 2) [23/03/2005 05:57:34 p.m.]
Search
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
HighLight Method
http://www.afralisp.com/methods/lista/highlight_method.htm (2 of 2) [23/03/2005 05:57:34 p.m.]
Import Method
Back to Methods Reference
Imports a drawing or a group of saved layer settings from a file.
Signatures: Overview
Drawing
VBA : RetVal =object.Import(FileName, InsertionPoint, ScaleFactor)
VL : RetVal =(vla-Import object FileName InsertionPoint Scale Factor)
Layer Settings
VBA : object.Import FileName
VL : (vla-Import object FileName)
Signatures: Detail
RetVal = object.Import(FileName, InsertionPoint, ScaleFactor)
VL : RetVal = (vla-Import object FileName InsertionPoint Scale Factor)
(vla-Import thisdrawing "c:/test.dxf" thepoint thescale)
Object : Document
The object or objects this method applies to.
G
FileName : String; input-only
The name of the file to be imported.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates location in the current drawing where the imported file is placed.
G
ScaleFactor : Double; input-only
The scale used to place the imported file.
G
RetVal : Object
In the case of importing a WMF file, a BlockReference object is returned. In all other cases, the
return value is NULL.
G
VBA : object.Import FileName
VL : (vla-Import object FileName)
Object : LayerStateManager
A LayerStateManager object.
G
FileName : String; input-only
The name of the file you are importing layer settings from.
G
Example :
(defun c:al-import ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq util (vla-get-utility thisdrawing))

(setq thepoint (vla-GetPoint util nil "\nInsertion Point: "))
(setq thescale (vla-GetReal util "\nEnter Scale Factor : "))
Import Method
http://www.afralisp.com/methods/lista/import_method.htm (1 of 2) [23/03/2005 05:57:35 p.m.]

(vla-Import thisdrawing "c:/test.dxf" thepoint thescale)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Import Method
http://www.afralisp.com/methods/lista/import_method.htm (2 of 2) [23/03/2005 05:57:35 p.m.]
Search
InsertBlock Method
Back to Methods Reference
Inserts a drawing file or a named block that has been defined in the current drawing.
Signature
VBA :RetVal = object.InsertBlock(InsertionPoint, Name, Xscale, Yscale, ZScale, Rotation)
VL : RetVal = (vla-InserBlock object InsertionPoint, Name, Xscale, Yscale, ZScale, Rotation)
(vla-InsertBlock mspace ip thename xscale yscale zscale rot)
Object : ModelSpace, PaperSpace, Block
The object or objects this method applies to.
G
InsertionPoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the location in the drawing to insert the block.
G
Name : String; input-only
The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name,
include any path information necessary for AutoCAD to find the file and the .dwg extension.
G
Xscale : Double; input-only; optional
The default equals 1.0. Must be a positive number.
G
Yscale : Double; input-only; optional
The default equals 1.0. Must be a positive number.
G
Zscale : Double; input-only; optional
The default equals 1.0. Must be a positive number.
G
Rotation : Double; input-only; optional
The default equals 0.0 radians.
G
RetVal : BlockRef object
The placed block as a Block Reference object.
G
Remarks
Inserting a block into another block will create nested blocks.
Attempting to call the InsertBlock method with an uninitialized Name parameter results in unexpected
behavior.
Example :
(defun c:al-insertblock ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(setq util (vla-get-utility thisdrawing))
(setq ip (vla-GetPoint util nil "\nInsertion Point: "))
(setq thename (vla-GetString util 1 "\nBlock Name: "))
(setq xscale (vla-GetReal util "\nX Scale Factor : "))
(setq yscale (vla-GetReal util "\nY Scale Factor : "))
(setq zscale (vla-GetReal util "\nZ Scale Factor : "))
InsertBlock Method
http://www.afralisp.com/methods/lista/insertblock_method.htm (1 of 2) [23/03/2005 05:57:36 p.m.]
(setq rot (vla-GetReal util "\nRotation Angle : "))
(setq theblock (vla-InsertBlock mspace ip
thename xscale yscale zscale rot))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
InsertBlock Method
http://www.afralisp.com/methods/lista/insertblock_method.htm (2 of 2) [23/03/2005 05:57:36 p.m.]
Search
IntersectWith Method
Back to Methods Reference
Gets the points where one object intersects another object in the drawing.
Signature
VBA : RetVal = object.IntersectWith(IntersectObject, ExtendOption)
VL : RetVal = (vla-IntersectWith object IntersectObject, ExtendOption)
(vla-IntersectWith obj1 obj2 acExtendBoth)
Object : All Drawing Objects (Except Pviewport and PolygonMesh)
The object or objects this method applies to.
G
IntersectObject : Object, input-only;
The object can be one of All Drawing Objects.
G
ExtendOption : AcExtendOption enum; input-only
This option specifies if one or the other, both, or none of the entities are to be extended in order
to attempt an intersection.
G
acExtendNone Does not extend either object.
acExtendThisEntity Extends the base object.
acExtendOtherEntity Extends the object passed as an argument.
acExtendBoth Extends both objects.

RetVal : Variant (array of doubles)


The array of points where one object intersects another object in the drawing.
G
Remarks
If the two objects do not intersect, no data is returned. You can request the point of intersection that
would occur if one or both of the objects were extended to meet the other.
Example :
(defun c:al-intersectwith ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj1 'ip "\nSelect First Object: ")
(vla-getentity util 'obj2 'ip "\nSelect Second Object: ")
(setq int (vla-IntersectWith obj1 obj2 acExtendBoth))
(princ int)
(princ)
);defun

IntersectWith Method
http://www.afralisp.com/methods/lista/intersectwith_method.htm (1 of 2) [23/03/2005 05:57:37 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
IntersectWith Method
http://www.afralisp.com/methods/lista/intersectwith_method.htm (2 of 2) [23/03/2005 05:57:37 p.m.]
Search
IsURL Method
Back to Methods Reference
Validates a given URL.
Signature
VBA : RetVal = object.IsURL(URL)
VL : RetVal = (vla-IsURL object URL)
(vla-IsUrl util "http://www.afralisp.com")
Object : Utility
The object or objects this method applies to.
G
LocalFile : String; input-only
The URL to validate.
G
RetVal : Boolean
TRUE: The string represents a valid URL.
FALSE: The string is not a valid URL.
G
Remarks
The definition of a "valid" URL is application-dependent, in that a given 3rd party application may not
be interested in supporting all Internet protocols. For instance, an application that attempts to connect
users to Web sites would probably not need to provide access to FTP sites. In this hypothetical
application, a FALSE value would be returned if a URL that begins with something other than "http://"
was entered.
The default functionality of this method for AutoCAD supports FTP, HTTP, HTTPS, and FILE protocols.
Example :
(defun c:al-isurl ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq flag (vla-IsUrl util "http://www.afralisp.com"))
(princ flag)
(princ)
);defun

IsURL Method
http://www.afralisp.com/methods/lista/isurl_method.htm (1 of 2) [23/03/2005 05:57:37 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
IsURL Method
http://www.afralisp.com/methods/lista/isurl_method.htm (2 of 2) [23/03/2005 05:57:37 p.m.]
Search
LauchBrowserDialog Method
Back to Methods Reference
Launches the Web Browser dialog that allows the user to navigate to any URL and select a URL.
Signature
VBA : RetVal = object.LaunchBrowserDialog (SelectedURL,DialogTitle, OpenButtonCaption,
StartPageURL, RegistryRootKey, OpenButtonAlwaysEnabled)
VL : RetVAL = (vla-LaunchBrowserDialog object SelectedURL DialogTitle OpenButtonCaption
StartPageURL RegistryRootKey OpenButtonAlwaysEnabled)
(vla-LaunchBrowserDialog util 'theurl "AfraLisp Browser"
"Open" "http://www.afralisp.com" "ACADBROWSER" 1)
Object : Utility
The object or objects this method applies to.
G
SelectedURL : String; output-only
The URL selected.
G
DialogTitle : String; input-only
The title to be displayed for the browser dialog.
G
OpenButtonCaption : String; input-only
The caption for the OK/Open button.
G
StartPageURL : String; input-only
The URL that the Web Browser should use as its start page.
G
ReigstryRootKey : String; input-only
Product root key for storing persistent Web Browser dialog information. This key specifies
where information about the size, position, and other preferences information of the dialog can
be stored across sessions. Input an empty string to disregard this functionality.
G
OpenButtonAlwaysEnabled : Boolean; input-only
TRUE: The Open button is enabled, allowing a file or link to be selected.
FALSE: The Open button is disabled and is only enabled when the user selects a file for
download.
G
RetVal : Boolean
TRUE: The Web Browser was opened successfully.
FALSE: The Web Browser did not open successfully.
G
Remarks
The last parameter, OpenButtonAlwaysEnabled, determines whether the user can select HTML links in
addition to files that are "downloadable".
Example :
(defun c:al-launchbrowserdialog ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-LaunchBrowserDialog util 'theurl "AfraLisp Browser"
"Open" "http://www.afralisp.com" "ACADBROWSER" 1)
(princ theurl)
(princ)
);defun
LaunchBrowserDialog Method
http://www.afralisp.com/methods/lista/launchbrowserdialog_method.htm (1 of 2) [23/03/2005 05:57:38 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
LaunchBrowserDialog Method
http://www.afralisp.com/methods/lista/launchbrowserdialog_method.htm (2 of 2) [23/03/2005 05:57:38 p.m.]
Search
ListArx Method
Back to Methods Reference
Gets the currently loaded AutoCAD ARX applications.
Signature
VBA : RetVal = object.ListArx()
VL : RetVal = (vla-ListArx object)
(vla-ListARX applic)
Object : Application
The object or objects this method applies to.
G
RetVal : Variant
An array of ARX applications currently loaded. Returns empty if no applications are currently
loaded.
G
Example :
(defun c:al-listarx ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(setq thearx (vla-ListARX applic))
(princ thearx)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ListArx Method
http://www.afralisp.com/methods/lista/listarx_method.htm [23/03/2005 05:57:39 p.m.]
Search
LoadARX Method
Back to Methods Reference
Loads the specified AutoCAD ARX application.
Signature
VBA : object.LoadARX Name
VL : (vla-LoadARX object Name)
(vla-LoadARX applic "c:/test.arx")
Object : Application
The object or objects this method applies to.
G
Name : String; input-only
The full path name of the application to load.
G
Example :
(defun c:al-loadarx ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(vla-LoadARX applic "c:/test.arx")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
LoadARX Method
http://www.afralisp.com/methods/lista/loadarx_method.htm [23/03/2005 05:57:40 p.m.]
Search
LoadDVB Method
Back to Methods Reference
Loads the specified AutoCAD VBA project file.
Signature
VBA : object.LoadDVB Name
VL : (vla-LoadDVB object Name)
(vla-LoadDVB applic "c:/test.dvb")
Object : Application
The object or objects this method applies to.
G
Name : String; input-only
The full path name of the .dvb project to load.
G
Example :
(defun c:al-loaddvb ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(vla-LoadDVB applic "c:/test.dvb")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
LoadDVB Method
http://www.afralisp.com/methods/lista/loaddvb_method.htm [23/03/2005 05:57:41 p.m.]
Search
Mirror Method
Back to Methods Reference
Creates a mirror image copy of a planar object around an axis.
Signature
VBA : RetVal = object.Mirror(Point1, Point2)
VL : RetVal = (vla-Mirror object Point1 Point2)
(vla-Mirror obj fpoint spoint)
Object : All Drawing Objects
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first point of the mirror axis.
G
Point2 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second point of the mirror axis.
G
RetVal : Mirrored object
This object can be one of any Drawing Objects.
G
System Variables
To manage the reflection properties of text objects, use the MIRRTEXT system variable. The default
setting of MIRRTEXT is on (1), which causes text objects to be mirrored just as any other object. When
MIRRTEXT is off (0), text is not mirrored.
This method places the reflected image into the drawing and retains the original object. To remove the
original object, use the Delete method.
You can mirror a Viewport object in paper space, although doing so has no affect on its model space
view or on model space objects.
AutoCAD checks to see if the object to be copied owns any other object. If it does, it performs a copy
on those objects as well. The process continues until all owned objects have been copied.
NOTE!
You cannot execute this method while simultaneously iterating through a collection. An iteration will
open the work space for a read-only operation, while this method attempts to perform a read-write
operation. Complete any iteration before you call this method.
AttributeReference: You should not attempt to use this method on AttributeReference objects.
AttributeReference objects inherit this method because they are one of the drawing objects, however,
it is not feasible to perform this operation on an attribute reference.Example :
(defun c:al-mirror ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq fpoint (vla-getpoint util nil
"\nSpecify first point of mirror line: "))
(setq spoint (vla-getpoint util fpoint
"\nSpecify second point of mirror line: "))
(setq newobj (vla-Mirror obj fpoint spoint))
Mirror Method
http://www.afralisp.com/methods/lista/mirror_method.htm (1 of 2) [23/03/2005 05:57:41 p.m.]
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Mirror Method
http://www.afralisp.com/methods/lista/mirror_method.htm (2 of 2) [23/03/2005 05:57:41 p.m.]
Search
Mirror3D Method
Back to Methods Reference
Creates a mirror image of the given object about a plane.
Signature
VBA : RetVal = object.Mirror3D(Point1, Point2, Point3)
VL : RetVal = (vla-Mirror3D object Point1 Point2 Point3)
(vla-Mirror3D obj fpoint spoint tpoint)
Object : All Drawing Objects
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first point of the mirror plane.
G
Point2 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second point of the mirror plane.
G
Point3 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the third point of the mirror plane.
G
RetVal : Mirrored object
This object can be one of any Drawing Objects.
G
Remarks
AutoCAD checks to see if the object to be copied owns any other object. If it does, it performs a copy
on those objects as well. The process continues until all owned objects have been copied.
NOTE You cannot execute this method while simultaneously iterating through a collection. An iteration
will open the work space for a read-only operation, while this method attempts to perform a read-write
operation. Complete any iteration before you call this method.
AttributeReference: You should not attempt to use this method on AttributeReference objects.
AttributeReference objects inherit this method because they are one of the drawing objects, however,
it is not feasible to perform this operation on an attribute reference.
Example :
(defun c:al-mirror3d ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq fpoint (vla-getpoint util nil
"\nSpecify first point of mirror line: "))
(setq spoint (vla-getpoint util fpoint
"\nSpecify second point of mirror line: "))
(setq tpoint (vla-getpoint util fpoint
"\nSpecify third point of mirror line: "))
(setq newobj (vla-Mirror3D obj fpoint spoint tpoint))
(princ)
Mirror3D Method
http://www.afralisp.com/methods/lista/mirror3d_method.htm (1 of 2) [23/03/2005 05:57:42 p.m.]
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Mirror3D Method
http://www.afralisp.com/methods/lista/mirror3d_method.htm (2 of 2) [23/03/2005 05:57:42 p.m.]
Search
Move Method
Back to Methods Reference
Moves an object along a vector.
Signature
VBA : object.Move Point1, Point2
VL : (vla-move object Point1 Point2)
(vla-move theobj PT1 PT2)
Object : All Drawing Objects, AttributeRef
The object or objects this method applies to.
G
Point1 Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first point of the move vector.
G
Point2 Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second point of the move vector.
G
Remarks
The two points you specify define a displacement vector indicating how far the given object is to be
moved and in what direction.
Example :
(defun c:al-move ()
(vl-load-com)
;get a reference to the Utilities Object :
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))
;select the object
(vla-getentity util 'theobj 'ip "\nSelect Object: ")
;get the base point
(setq BP (vla-getpoint util nil
"\nSpecify base point or displacement: "))
;get the displacement
(setq PT2 (vla-getpoint util BP
"\nSpecify second point of displacement: "))
;move the object
(vla-move theobj BP PT2)
(princ)
);defun
(princ)

Move Method
http://www.afralisp.com/methods/list/move_method.htm (1 of 2) [23/03/2005 05:57:43 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Move Method
http://www.afralisp.com/methods/list/move_method.htm (2 of 2) [23/03/2005 05:57:43 p.m.]
Search
Offset Method
Back to Methods Reference
Creates a new object at a specified offset distance from an existing object.
Signature
VBA : RetVal = object.Offset(Distance)
VL : RetVal = (vla-offset object Distance)
(vla-Offset myline dist)
Object : Arc, Circle, Ellipse, Line, LightweightPolyline, Polyline, Spline, XLine
The object or objects this method applies to.
G
Distance : Double; input-only
The distance to offset the object. The offset can be a positive or negative number, but it cannot equal zero. If the
offset is negative, this is interpreted as being an offset to make a "smaller" curve (that is, for an arc it would offset
to a radius that is "Distance less" than the starting curve's radius). If "smaller" has no meaning, then it would offset
in the direction of smaller X, Y, and Z WCS coordinates.
G
RetVal : Variant (array of objects)
An array of the newly created objects resulting from the offset.
G
Remarks
For many curves, the result of this operation will be a single new curve (which may not be of the same type as the original
curve). For example, offsetting an ellipse will result in a spline because the result does fit the equation of an ellipse. In
some cases it may be necessary for the offset result to be several curves.
Example :
(defun c:al-offset ()
(vl-load-com)
(setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setq apt (getpoint "\nSpecify First Point: "))
(setq pt (getpoint "\nSpecify next point: " apt))
(setq myline (vla-addline mspace (vlax-3d-point apt)(vlax-3d-point pt)))
(setq dist (getdist "\nOffset Distance : "))
(setq offLine (vla-Offset myline dist))
(princ)
);defun
(princ)

Offset Method
http://www.afralisp.com/methods/list/offset_method.htm (1 of 2) [23/03/2005 05:57:44 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Offset Method
http://www.afralisp.com/methods/list/offset_method.htm (2 of 2) [23/03/2005 05:57:44 p.m.]
Search
PolarPoint Method
Back to Methods Reference
Gets the point at a specified angle and distance from a given point.
Signature
VBA : RetVal = object.PolarPoint(Point, Angle, Distance)
VL : RetVal = (vla-PolarPoint object Point Angle Distance)
(vla-polarpoint util P3 0 lg)
Object : Utility
The object or objects this method applies to.
G
Point : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the start point.
G
Angle : Double; input-only
The angle in radians.
G
Distance : Double; input-only
The distance in current units.
G
RetVal : Variant (three-element array of doubles)
The 3D WCS coordinates at the specified angle and distance from a given point.
G
Example :
;CODING STARTS HERE
(defun c:slot ( / acaddoc util mspace ip lg
dia P1 P2 P3 P4 P5 P6 P7)
;load VL functions
(vl-load-com)
;obtain reference to the Active Document
(setq acaddoc (vla-get-activeDocument (vlax-get-acad-object)))
;obtain reference to Utilities
(setq util (vla-get-utility acaddoc))
;obtain reference to Model Space
(setq mspace (vla-get-modelSpace acaddoc))
;get the insertion point
(setq ip (vla-getpoint util nil "\nInsertion Point: "))
;get the length
(setq lg (vla-getreal util "\nEnter Slot Length: "))
;get the diameter
(setq dia (vla-getreal util "\nEnter Slot Diameter: "))
;calculate all the points
(setq P1 (vla-polarpoint util IP (dtr 270.0) (/ dia 2)))
(setq P2 (vla-polarpoint util P1 (dtr 180.0) (/ lg 2)))
(setq P3 (vla-polarpoint util P2 (dtr 90.0) dia))
(setq P4 (vla-polarpoint util P3 0 lg))
(setq P5 (vla-polarpoint util P4 (dtr 270.0) dia))
(setq P6 (vla-polarpoint util P2 (dtr 90.0) (/ dia 2)))
(setq P7 (vla-polarpoint util P5 (dtr 90.0) (/ dia 2)))
;draw the lines
PolarPoint Method
http://www.afralisp.com/methods/list/polarpoint_method.htm (1 of 2) [23/03/2005 05:57:45 p.m.]
(vla-AddLine mspace p2 p5)
(vla-AddLine mspace p3 p4)
;add the arcs
(vla-AddArc mspace p6 (/ dia 2) (dtr 90.0) (dtr 270.0))
(vla-AddArc mspace p7 (/ dia 2) (dtr 270.0) (dtr 90.0))
(princ)
);defun
----------
;convert degrees to radians
(defun DTR (a)
(* pi (/ a 180))
);defun
----------
(princ)
;CODING ENDS HERE

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PolarPoint Method
http://www.afralisp.com/methods/list/polarpoint_method.htm (2 of 2) [23/03/2005 05:57:45 p.m.]
Search
Prompt Method
Back to Methods Reference
Posts a prompt to the command line.
Signature
VBA : object.Prompt Message
VL : (vla-Prompt object Message)
(vla-prompt util "\nSelect Object :")
Object : Utility
The object or objects this method applies to.
G
Message : String; input-only
The prompt to display.
G
Example :
;obtain reference to the utility object
(setq util (vla-get-utility (vla-get-activedocument
(vlax-get-acad-object))))
(vla-Prompt util "\nEnter your name : ")

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Prompt Method
http://www.afralisp.com/methods/list/prompt_method.htm [23/03/2005 05:57:46 p.m.]
Search
PurgeAll Method
Back to Methods Reference
Removes unused named references such as unused blocks or layers from the document.
Signature
VBA : object.PurgeAll
VL : (vla-PurgeAll thisdrawing)
(vla-PurgeAll thisdrawing)
Object : Document
The object or objects this method applies to.
G
Remarks
This method is the equivalent of entering PURGE on the command line, selecting the All option and
choosing Yes to the Purge Everything? prompt.
Deleted objects remain in the document until they are purged using this method.
Example :
;obtain a reference to the active document
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(vla-PurgeAll thisdrawing)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PurgeAll Method
http://www.afralisp.com/methods/list/purgeall_method.htm [23/03/2005 05:57:46 p.m.]
Search
RealToString Method
Back to Methods Reference
Converts a real (double) value to a string.
Signature
VBA : RetVal = object.RealToString(Value, Unit, Precision)
VL : RetVal = (vla-RealToString object Value Unit Precision)
(vla-RealToString util thereal acdecimal 3)
Object : Utility
The object or objects this method applies to.
G
Value : Double; input-only
The value to be converted.
G
Unit : AcUnits enum; input-only
acDefaultUnits
acScientific
acDecimal
acEngineering
acArchitectural
acFractional
G
Precision : Integer; input-only
The precision of the value. An integer between 0 and 8.
G
RetVal : String
The value as a properly formatted string.
G
Example :
(defun c:al-realtostring ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(setq thereal (vla-GetReal util "\nEnter Real Number : "))
(setq thestring (vla-RealToString util thereal acdecimal 3))
(prin thestring)
(princ)
);defun

RealToString Method
http://www.afralisp.com/methods/lista/realtostring_method.htm (1 of 2) [23/03/2005 05:57:47 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
RealToString Method
http://www.afralisp.com/methods/lista/realtostring_method.htm (2 of 2) [23/03/2005 05:57:47 p.m.]
Search
Regen Method
Back to Methods Reference
Regenerates the entire drawing and recomputes the screen coordinates and view resolution for all
objects.
Signature
object.Regen WhichViewports
VL : (vla-Regen object WhichViewports
(vla-Regen thisdrawing acAllViewports)
Object : Document
The object or objects this method applies to.
G
WhichViewports : Integer; input-only
acActiveViewport - Regenerates only the active viewport.
acAllViewports - Regenerates all viewports on the document.
G
Remarks
Regen also reindexes the drawing database for optimum display and better object selection
performance.
Example :
(defun c:al-Regen ()
(vl-load-com)
(setq thisdrawing
(vla-get-activedocument
(vlax-get-acad-object)))
(vla-Regen thisdrawing acAllViewports)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Regen Method
http://www.afralisp.com/methods/lista/regen_method.htm (1 of 2) [23/03/2005 05:57:48 p.m.]
Search
Regen Method
http://www.afralisp.com/methods/lista/regen_method.htm (2 of 2) [23/03/2005 05:57:48 p.m.]
Rotate Method
Back to Methods Reference
Rotates an object around a base point.
Signature
VBA : object.Rotate BasePoint, RotationAngle
VL : (vla-Rotate object BasePoint RotationAngle
(vla-Rotate obj bpoint rangle)
Object : All Drawing Objects, AttributeReference
The object or objects this method applies to.
G
BasePoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the point through which the axis of rotation is defined as
parallel to the Z axis of the UCS.
G
RotationAngle : Double; input-only
The angle in radians to rotate the object. This angle determines how far an object rotates around
the base point relative to its current location.
G
Example :
(defun c:al-rotate ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq bpoint (vla-getpoint util nil "\nSpecify base point: "))
(setq rangle (vla-getangle util bpoint "\nRotation Angle: "))
(vla-Rotate obj bpoint rangle)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Rotate Method
http://www.afralisp.com/methods/lista/rotate_method.htm (1 of 2) [23/03/2005 05:57:49 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Rotate Method
http://www.afralisp.com/methods/lista/rotate_method.htm (2 of 2) [23/03/2005 05:57:49 p.m.]
Rotate3D Method
Back to Methods Reference
Rotates an object around a 3D axis. Point1 and Point2 define the line that becomes the axis of rotation.
Signature
VBA : object.Rotate3D Point1, Point2, RotationAngle
VL : (vla-Rotate3D object Point1 Point2 RotationAngle)
(vla-Rotate3D obj bpoint spoint rangle)
Object : All Drawing Objects, AttributeReference
The object or objects this method applies to.
G
Point1 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the first point of the axis line.
G
Point2 : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the second point of the axis line.
G
RotationAngle : Double; input-only
The angle in radians to rotate the object about the selected axis.
G
Example :
(defun c:al-rotate3D ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq bpoint (vla-getpoint util nil "\nSpecify base point: "))
(setq spoint (vla-getpoint util bpoint "\nSpecify second point: "))
(setq rangle (vla-getangle util bpoint "\nRotation Angle: "))
(vla-Rotate3D obj bpoint spoint rangle)
(princ)
);defun

Rotate 3D Method
http://www.afralisp.com/methods/lista/rotate3d_method.htm (1 of 2) [23/03/2005 05:57:49 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Rotate 3D Method
http://www.afralisp.com/methods/lista/rotate3d_method.htm (2 of 2) [23/03/2005 05:57:49 p.m.]
Search
RunMacro Method
Back to Methods Reference
Runs a VBA macro from the Application object.
Signature
VBA : object.RunMacro(MacroPath)
VL : (vl-RunMacro object MacroPath)
(vla-RunMacro applic "test.dvb!Module1.macro")
Object : Application
The object or objects this method applies to.
G
MacroPath : String; input-only
A string representing the calling sequence of the macro to run. The calling sequence must have
the following syntax, where [] represent optional parameters:
[Filename.dvb.][ProjectName.][ModuleName.]MacroName
NOTE: If Filename.dvb is followed by ProjectName, separate the names with an exclamation
point instead of a period, as in the following example:
Filename.dvb!ProjectName
The Filename.dvb specified will be loaded if it is not already loaded. If the path to the
Filename.dvb is not specified, the system will look in the AutoCAD search path to try and locate
the file. If ProjectName is not specified, the system will search all currently loaded projects to
locate the macro.
G
Remarks
To associate a macro with a popup menu or toolbar item, use the Macro property
Example :
(defun c:al-runmacro ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(vla-RunMacro applic "test.dvb!Module1.macro")
(princ)
);defun

RunMacro Method
http://www.afralisp.com/methods/lista/runmacro_method.htm (1 of 2) [23/03/2005 05:57:50 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
RunMacro Method
http://www.afralisp.com/methods/lista/runmacro_method.htm (2 of 2) [23/03/2005 05:57:50 p.m.]
Search
Save Method
Back to Methods Reference
Saves a document, menu group, or group of layer property settings.
Signatures: Overview
Document:
VBA : object.Save
VL : (vla-Save object)
MenuGroup:
VBA : object.Save MenuFileType
VL : (vla-Save object MenuFileType)
Layer Settings:
VBA : object.Save Name, Mask
VL : (vla-Save object Name Mask
VBA : object.Save
VL : (vla-Save object)
(vla-Save thisdrawing)
Object : Document
Saves the specified document.
G
VBA : object.Save MenuFileType
VL : (vla-Save object MenuFileType)
Object : MenuGroup
The object or objects this method applies to.
G
MenuFileType : AcMenuFileType enum; input-only
Saves the menu group as the given menu type.
acMenuFileCompiled - A compiled menu file (MNC file type).
acMenuFileSource - A source menu file (MNS file type).
G
VBA : object.Save Name, Mask
VL : (vla-Save object Name Mask)
Object : LayerStateManager
A LayerStateManager object.
G
Name : String; input-only
The name to be assigned to the saved layer settings.
G
Mask : enum; input-only
A number representing the layer properties to be saved and restored. Use the following
constants to identify layer properties:
G
acLsAll All layer properties
acLsColor Color
acLsFrozen Frozen or thawed
acLsLineType Linetype
acLsLineWeight Lineweight
acLsLocked Locked or unlocked
acLsNewViewport New viewport layers frozen or thawed
acLsNone None
Save Method
http://www.afralisp.com/methods/lista/save_method.htm (1 of 2) [23/03/2005 05:57:51 p.m.]
acLsOn On or off
acLsPlot Plotting on or off
acLsPlotStyle Plot style
Remarks
Document: Saving a file to a secure Internet location prompts the user for a password.
Example :
(defun c:al-Save ()
(vl-load-com)
(setq thisdrawing
(vla-get-activedocument
(vlax-get-acad-object)))
(vla-Save thisdrawing)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Save Method
http://www.afralisp.com/methods/lista/save_method.htm (2 of 2) [23/03/2005 05:57:51 p.m.]
Search
SaveAs Method
Back to Methods Reference
Saves the document or menu group to a specified file.
Signatures
VBA : object.SaveAs FileName, FileType
VL : (vla-SaveAs object FileName FileType)
(vla-SaveAs thisdrawing name acR14_DWG)
Object : Document, MenuGroup
The object or objects this method applies to.
G
FileName : String; input-only
The full path and file name, or valid URL address, for the file. The active document or menu
group takes on the new name.
G
MenuFileType : AcMenuFileType enum; input-only; required for menu groups G
acMenuFileCompiled A compiled menu file (MNC file type).
acMenuFileSource A source menu file (MNS file type).
AcSaveAsType enum; input-only; optional for Document objects G
acR12_DXF AutoCAD Release12/LT2 DXF (*.dxf)
acR13_DWG AutoCAD Release13/LT95 DWG (*.dwg)
acR13_DXF AutoCAD Release13/LT95 DXF (*.dxf)
acR14_DWG AutoCAD Release14/LT97 DWG (*.dwg)
acR14_DXF AutoCAD Release14/LT97 DXF (*.dxf)
acR15_DWG AutoCAD 2000 DWG (*.dwg)
acR15_DXF AutoCAD 2000 DXF (*.dxf)
acR15_Template AutoCAD 2000 Drawing Template File (*.dwt)
acNative A synonym for the latest drawing release. In this
release, this value equals acR15_DWG.
Remarks
The default file type for documents is acR15_DWG.
Documents can only be saved as AutoCAD drawing files with the extension DWG. To save a document
in a different file type, use the Export method.
When saving to a secure URL a dialog box will be posted prompting the user for the necessary
password information. Message boxes may also appear if the user has not suppressed this activity in
their browser.
Example :
(defun c:al-SaveAs ()
(vl-load-com)
(setq thisdrawing
(vla-get-activedocument
(vlax-get-acad-object)))
(setq name (strcat "R14-" (getvar "DWGNAME")))
(vla-SaveAs thisdrawing name acR14_DWG)
SaveAs Method
http://www.afralisp.com/methods/lista/saveas_method.htm (1 of 2) [23/03/2005 05:57:53 p.m.]
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SaveAs Method
http://www.afralisp.com/methods/lista/saveas_method.htm (2 of 2) [23/03/2005 05:57:53 p.m.]
Search
ScaleEntity Method
Back to Methods Reference
Scales an object equally in the X, Y, and Z directions.
Signature
VBA : object.ScaleEntity BasePoint, ScaleFactor
VL : (vla-ScaleEntity object BasePoint ScaleFactor)
(vla-ScaleEntity obj bp sc)
Object : All Drawing Objects, AttributeReference
The object or objects this method applies to.
G
BasePoint : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the base point.
G
ScaleFactor : Double; input-only
The factor by which to scale the object. The dimensions of the object are multiplied by the scale
factor. A scale factor greater than 1 enlarges the object. A scale factor between 0 and 1 reduces
the object. The scale factor must be greater than 0.0.
G
Example :
(defun c:al-scaleentity ()
(vl-load-com)
(setq util (vla-get-utility
(vla-get-activedocument
(vlax-get-acad-object))))

(vla-getentity util 'obj 'ip "\nSelect Object: ")
(setq bp (vla-getpoint util nil "\nBase Point: "))
(setq sc (vla-GetReal util "\nScale Factor: "))
(vla-ScaleEntity obj bp sc)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
ScaleEntity Method
http://www.afralisp.com/methods/lista/scaleentity_method.htm (1 of 2) [23/03/2005 05:57:53 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ScaleEntity Method
http://www.afralisp.com/methods/lista/scaleentity_method.htm (2 of 2) [23/03/2005 05:57:53 p.m.]
Select Method
Back to Methods Reference
Selects objects and places them into a selection set.
Signature
VBA : object.Select Mode[, Point1][, Point2][, FilterType][, FilterData]
VLA : (vla-Select object Mode Point1 Point2 FilterType FilterData)
(vla-Select newSet acSelectionSetAll)
Object : SelectionSet
The object or objects this method applies to.
G
Mode : AcSelect enum; input-only
acSelectionSetWindow
acSelectionSetCrossing
acSelectionSetPrevious
acSelectionSetLast
acSelectionSetAll
G
Point1 : Variant (array of doubles); input-only; optional
The 3D WCS coordinates, or array of coordinates, specifying Point1. See the mode definitions
above for the proper use of Point1.
G
Point2 : Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying Point2. See the mode definitions above for the proper use
of Point2.
G
FilterType : Integer; input-only; optional
A DXF group code specifying the type of filter to use.
G
FilterData Variant; input-only; optional
The value to filter on.
G
Remarks
This method supports the filtering mechanism.
The following selection modes are available:
Window: Selects all entities completely inside a rectangular area whose corners are defined by
Point1 and Point2.
G
Crossing: Selects objects within and crossing a rectangular area whose corners are defined by
Point1 and Point2.
G
Previous: Selects the most recent selection set. This mode is ignored if you switch between
paper and model space and attempt to use the selection set.
G
Last: Selects the most recently created visible entity. G
All: Selects all entities. G
For more selection mode options, see the SelectByPolygon, SelectAtPoint, and SelectOnScreen
methods.
Refer to Visual Lisp - Selection Objects for more details.
Example :
(defun c:al-select ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
Select Method
http://www.afralisp.com/methods/list/select_method.htm (1 of 2) [23/03/2005 05:57:54 p.m.]
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if
(vla-Select newSet acSelectionSetAll)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Select Method
http://www.afralisp.com/methods/list/select_method.htm (2 of 2) [23/03/2005 05:57:54 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Selection Objects
Selecting Objects and creating Selection Sets is much the same in Visual
Lisp as it is for standard AutoLisp except for two main differences. All Entities
contained in an AutoLisp selection set, must be converted to VLA Objects
before VLA functions can be applied to them, and you cannot use AutoCAD interactive functions
such as (entsel) or (ssget) within a reactor callback function.
In this tutorial, we we look at Selecting Objects and creating Selection sets using the (entsel)
function, the (ssget) function and then using only VLA functions.
Let's look at selecting a single entity first using (entsel).
Consider this coding :
(defun selectionlisp1 ( / sset check)
;load the visual lisp extensions
(vl-load-com)
;check for selection
(while

;get the entity and entity name
(setq sset (car (entsel)))
;convert to vl object
(setq sset (vlax-ename->vla-object sset))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p sset "Color" T))
;if it can
(if check
;change it's color
(vlax-put-property sset 'Color 4)
);if
);while
(princ)
);defun
(princ)
We select the entity using the standard (entsel) function. We then have to
convert the entity to a VLA Object by using the (vlax-ename->vla-object)
function.
Next we check to see if the object first has a color property, and secondly
is updateable using the (vlax-property-available-p) function with it's "T"
argument set.
Finally we change it's color property using the (vlax-put-property) function.
Dead easy, hey?
Selection Sets
http://www.afralisp.com/vl/selsets.htm (1 of 7) [23/03/2005 05:57:56 p.m.]
Create Selection sets utilising (ssget) is also quite straightforward.
Have a look at this :
(defun selectionlisp2 ( / sset item ctr check)
;load the visual lisp extensions
(vl-load-com)
;check for selection
(while
;get the selection set
(setq sset (ssget))
;set up the counter
(setq ctr 0)
;count the number of entities and loop
(repeat (sslength sset)
;extract the entity name
(setq item (ssname sset ctr))
;convert to vl object
(setq item (vlax-ename->vla-object item))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p item "Color" T))
;if it can
(if check
;change it's color
(vlax-put-property item 'Color 6)
);if
;increment the counter
(setq ctr (1+ctr))
);repeat
);while
(princ)
);defun
(princ)
The only difference here, is that we need to loop through each individual
item in the selection set, converting it to a VLA Object, and then checking
and changing it's properties.
Again this is standard AutoLisp with a little bit of VLA thrown in to confuse
you.
To create a selection set using only VLA is a slightly different matter.
Here we need to access the Object Model to reference, create and
store our selection set. Have a look at this :
(defun selectionvl ( / ssets acadDocument newsset ctr item)
Selection Sets
http://www.afralisp.com/vl/selsets.htm (2 of 7) [23/03/2005 05:57:56 p.m.]
;load the visual lisp extensions
(vl-load-com)
;retrieve a reference to the documents object
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
;retrieve a reference to the selection sets object
(setq ssets (vla-get-selectionsets acadDocument))
;add a new selection set
(setq newsset (vla-add ssets "SS1"))
;select your new selection set objects
(vla-selectOnScreen newsset)
;set the counter to zero
(setq ctr 0)
;count the number of objects and loop
(repeat (vla-get-count newsset)
;retrieve each object
(setq item (vla-item newsset ctr))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p item "Color" T))
;if it can
(if check
;change it's color
(vlax-put-property item 'Color 5)
);if
;increment the counter
(setq ctr (1+ctr))
);repeat
;delete the selection set
(vla-delete (vla-item ssets "SS1"))
(princ)
);defun
(princ)
First we need to reference the selection set collection. Looking at the
Object Model, we find this collection to be part of the "Active Document" Object.
After grabbing and storing our reference, using the (vla-get-selectionsets) function, we then
need to create a new selection set. (SS1) using the
(vla-add) function.
O.K. that's done, now what next?
Well, we've got a selection set but there's nothing in it. Using the (vla-selectOnScreen) method,
we populate our selection set with the
Objects that we would like to process. Again, we use the (repeat) function
to loop through all of our objects, checking if each object has a color
property and is updateable before changing it's color. Of course, we
Selection Sets
http://www.afralisp.com/vl/selsets.htm (3 of 7) [23/03/2005 05:57:56 p.m.]
don't need to convert these Objects as they are already VLA Objects.
The final step in our application is to delete the selection set to prevent
"Selection Set Already Exists" errors when we run the routine again.
Selecting with Filters
Now things get a wee bit tricky. I suggest you read my Tutorial on "Arrays" before you carry on
with this section, as a good understanding of them will help you a lot.
First of all, let's have a look at the VBA syntax for Selecting with Filters :
object.SelectOnScreen [FilterType][, FilterData]
Object : SelectionSet
The object or objects this method applies to.
FilterType : Integer; input-only; optional
A DXF group code specifying the type of filter to use.
FilterData : Variant; input-only; optional
The value to filter on.
ActiveX requires a Filter Type to be an Array of Integers, and the Filter Data to be an Array of
Variants. To Filter for all Objects on Layer "7" we would write it like this in Visual Lisp:
;create a single element array for the DXF Code
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 0)))
;create a single element array for the value
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 0)))
;DXF Code for layers
(vlax-safearray-fill filter_code '(8))
;the filter value
(vlax-safearray-fill filter_value '("7"))
;Use Select on Screen to select objects on Layer 7
(vla-selectOnScreen newsset filter_code filter_value)
In AutoLisp you would write this :
(setq newsset (ssget '((8 . "7"))))
This is how the revised program would look :
(defun selectionvl ( / ssets acadDocument newsset ctr item filter_code filter_value)
;load the visual lisp extensions
(vl-load-com)
;retrieve a reference to the documents object
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
;retrieve a reference to the selection sets object
(setq ssets (vla-get-selectionsets acadDocument))
;add a new selection set
(setq newsset (vla-add ssets "SS1"))
;create a single element array for the DXF Code
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 0)))
;create a single element array for the value
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 0)))
;DXF Code for layers
(vlax-safearray-fill filter_code '(8))
;the filter value
(vlax-safearray-fill filter_value '("7"))
;Use Select on Screen to select objects on Layer 7
Selection Sets
http://www.afralisp.com/vl/selsets.htm (4 of 7) [23/03/2005 05:57:56 p.m.]
(vla-selectOnScreen newsset filter_code filter_value)
;set the counter to zero
(setq ctr 0)
;count the number of objects and loop
(repeat (vla-get-count newsset)
;retrieve each object
(setq item (vla-item newsset ctr))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p item "Color" T))
;if it can
(if check

;change it's color


(vlax-put-property item 'Color 5)
);if
;increment the counter
(setq ctr (1+ctr))
);repeat
;delete the selection set
(vla-delete (vla-item ssets "SS1"))
(princ)
);defun
(princ)

To select ALL the Circles on Layer "2", We would write this :


;create a 2 element array for the DXF Code
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 1)))
;create a 2 element array for the values
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 1)))
;DXF Code for Objects and Layer
(vlax-safearray-fill filter_code '(0 8))
;the filter values
(vlax-safearray-fill filter_value '("CIRCLE" "2"))
;select ALL Circles on Layer 2
(vla-select newsset acSelectionSetAll nil nil filter_code filter_value)
This is the equivalent in AutoLisp :
(setq newsset (ssget "x" '((0 . "CIRCLE") (8 . "2"))))
To select ALL Circles OR Text, we would write this :
;create a 4 element array for the DXF codes
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 3)))
;create a 4 element array for the names
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 3)))
;DXF Codes for OR and Objects
(vlax-safearray-fill filter_code '(-4 0 0 -4))
;the filter values
(vlax-safearray-fill filter_value '("<or" "CIRCLE" "TEXT" "or>"))
;select ALL Circles OR Text
(vla-select newsset acSelectionSetAll nil nil filter_code filter_value)
Selection Sets
http://www.afralisp.com/vl/selsets.htm (5 of 7) [23/03/2005 05:57:56 p.m.]
In AutoLisp, this is equivalent to :
(setq newsset (ssget "x" '((-4 . "<or") (0 . "CIRCLE") (0 . "TEXT") (-4 . "or>"))))
Can you see what we are doing?
We are basically "splitting" the AutoLisp dotted pairs into two arrays, one containing the DXF
codes, and the other containing the filter values.
There is another way of filtering the Selection Set itself. Consider this code:
(if (=(vlax-get-property item 'ObjectName) "AcDbCircle")
(vlax-put-property item 'Color 3)
);if
Makes you think doesn't it?
Selection Set Already Exists
Did you notice how, at the end of our routines, we added the line :
(vla-delete (vla-item ssets "SS1"))
If we didn't delete the selection set, next time we ran the routine we would get a "Selection Set Already
Exists" error. Now adding this line is fine if everything runs correctly in our routine, but what happens if
the user Cancels or there is another error that causes our program not to reach this line.
Have a look at this :
(defun selset_test ()
(vl-load-com)
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets acadDocument))
(setq flag nil)
(vlax-for item ssets
(if (= (vla-get-name item) "newsset")
(setq flag T)
);if
);
(if flag
(vla-delete (vla-item ssets "newsset"))

);if
(setq newsset (vla-add ssets "newsset"))
);defun

This routine loops through each selection set in the selection set collection.
If it finds the selection set (newset), it deletes it and then creates it. If it does not find it, it simple creates it.
A better way of achieving the same result, is to make use of the (vl-Catch-All-Apply) function :
Selection Sets
http://www.afralisp.com/vl/selsets.htm (6 of 7) [23/03/2005 05:57:56 p.m.]
(defun selset_test1 ()
(vl-load-com)
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets acadDocument))
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if

Have a look at "Visual Lisp and Errors" for a more detailed explanation of the
(vl-Catch-All-Apply) function.
Well, that's about it with "Selecting Objects." Not too bad, hey?
(I can hear you groaning from here in Africa, Hee, hee, hee.)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Selection Sets
http://www.afralisp.com/vl/selsets.htm (7 of 7) [23/03/2005 05:57:56 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Arrays
If you've programmed in VBA or other languages, you're probably familiar with the
concept of arrays. An array is a named collection of variables of the same data type.
Each array element can be distinguished from other elements by one or more integer
indexes. For example, if the "sheetNames" array contains three names, you can set and
return the names in VBA as shown in the following example :
sheetNames(0) = "Sheet1"
sheetNames(1) = "Sheet2"
sheetNames(2) = "Sheet3"
MsgBox sheetNames(1)
Would return a message :
"Sheet2"
Arrays allow you to group related variables in a way that makes it easier for you to keep
track of, access, and manipulate them all at once, while still being able to access each
variable individually. This helps you create smaller and simpler routines in many
situations, because you can set up loops using index numbers to deal efficiently with any
number of cases.
When you create an array, its size is determined by the number of dimensions it has and
the by the upper and lower bounds for the index numbers in each dimension. The
"sheetNames" array in the earlier example has one dimension and three elements; the
lower bound is 0 and the upper bound is 2.
"That's fine Kenny, but how do we create an Array in Visual Lisp?"
O.K. I hear you, there's no need to yell!
Enter this at the Console prompt :
_$ (vl-load-com)
_$ (setq sheet_type (vlax-make-safearray vlax-vbString '(0 . 2)))
#<safearray...>
_$ (vlax-safearray-fill sheet_type '("Sheet1" "Sheet2" "Sheet3"))
#<safearray...>

Have a look at the "sheet_ type" variable in the Watch window :


This tells us that the Array contains strings, has one dimension and contains 3 elements.
Let's convert it to an AutoLisp List :
_$ (setq alist (vlax-safearray->list sheet_type))
Arrays
http://www.afralisp.com/vl/array.htm (1 of 6) [23/03/2005 05:57:58 p.m.]
("Sheet1" "Sheet2" "Sheet3")
Did a light just go off in your head? An Array is just a List in a slightly different format. To
create an Array, or safearray as they are know in Visual Lisp, we use the
"vlax-make-safearray" function. To populate a safearray we use the "vlax-safearray-fill"
or the "vlax-safearray-put" functions.
The "vlax-make-safearray" function requires a minimum of two arguments. The first
argument identifies the type of data that will be stored in the array.
One of the following constants must be specified for the data type :
vlax-vbInteger Integer
vlax-vbLong Long Integer
vlax-vbSingle Single-precision floating point number
vlax-vbDouble Double-precision floating point number
vlax-vbString String
vlax-vbObject Object
vlax-vbBoolean Boolean
vlax-vbVariant Variant
The remaining arguments to "vlax-make-safearray" specify the upper and lower bounds
of each dimension of the array. The lower bound for an index can be zero or any positive
or negative number. Have another look at the function we called earlier :
_$ (setq sheet_type (vlax-make-safearray vlax-vbString '(0 . 2)))
This function created a single-dimension array consisting of three strings with a starting
index of 0 (element 0, element 1 and element 2).
Consider this :
_$ (setq pt1 (vlax-make-safearray vlax-vbDouble '(1 . 3)))
The lower bound specified in this example is one and the upper bound specified is three,
so the array will hold three doubles (element 1, element 2 and element 3).
The "vla-safearray-fill" function requires two arguments: the variable containing the array
you are populating and a list of the values to be assigned to the array elements. You
must specify as many values as there are elements in the array or vla-safearray-fill"
results in an error.
The following code populates a single-dimension array of three doubles:
_$ (vlax-safearray-fill pt1 '(100 100 0))
To convert an array to an AutoLisp list, you can use the (vlax-safearray->list) function.
Try it out :
_$ (vlax-safearray->list pt1)
(100.0 100.0 0.0)
Let's create a Array with two dimensions, each dimension with three elements:
_$ (setq two_dim (vlax-make-safearray vlax-vbString '(0 . 1) '(1 . 3)))
#<safearray...>
_$ (vlax-safearray-fill two_dim '(("Sheet1" "Sheet2" "Sheet3") ("a" "b" "c")))
#<safearray...>
_$ (vlax-safearray->list two_dim)
(("Sheet1" "Sheet2" "Sheet3") ("a" "b" "c"))
This is just a list of lists.
Arrays
http://www.afralisp.com/vl/array.htm (2 of 6) [23/03/2005 05:57:58 p.m.]
The first list, '(0 .1) is the number of dimensions.
The second list, '(1 . 3) is the number of elements
And now a three dimensional Array with two elements in each dimension:
_$ (setq three_dim (vlax-make-safearray vlax-vbString '(0 . 2) '(1 . 2)))
#<safearray...>
_$ (vlax-safearray-fill three_dim '(("Sheet1" "Sheet2") ("a" "b") ("d" "e")))
#<safearray...>
_$ (vlax-safearray->list three_dim)
(("Sheet1" "Sheet2") ("a" "b") ("d" "e"))
Here we have a list of three lists.
This time, the first list '(0 . 2) defines three dimensions and the second '(1 . 2) defines 2
elements in each dimension.
One place you will be using "vlax-safearray-fill" is when creating selection sets with
filters. The syntax in ActiveX for "Selecting All with Filters" is as follows "
object.Select Mode[, Point1][, Point2][, Filter_Code][, Filter_Value]
Filter_Code must be an Integer array and Filter_Value a Variant array.
In Visual Lisp, the coding would be written like this :
;create a 2 element integer array for the DXF Codes.
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 1)))
;create a 2 element variant array for the values.
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 1)))
;DXF Codes for Objects and Layer : " 0" for Object," 8" for Layer.
(vlax-safearray-fill filter_code '(0 8))
;Name of Object and Layer.
(vlax-safearray-fill filter_value '("CIRCLE" "2"))
;select ALL Circles on Layer 2.
(vla-select newsset acSelectionSetAll nil nil filter_code filter_value)
For more information on Selections Sets, pop along to my "Selection Sets" tutorial page
and get yourself even more confused.
The "vlax-safearray-put-element" function can be used to assign values to one or more
elements of a safearray. The number of arguments required by this function depends on
the number of dimensions in the array.
The first argument always names the safearray to which you are assigning a value. G
The next set of arguments identifies index values pointing to the element to which
you are assigning a value. For a single-dimension array, specify one index value:
for a two-dimension array, specify two index values, and so on.
G
The final argument is always the value to be assigned to the safearray element. G
Have a look at the following :
_$ (setq pt1 (vlax-make-safearray vlax-vbDouble '(1 . 3)))
#<safearray...>
_$ (vlax-safearray-put-element pt1 1 100)
100
_$ (vlax-safearray-put-element pt1 2 100)
100
_$ (vlax-safearray-put-element pt1 3 75)
75
Arrays
http://www.afralisp.com/vl/array.htm (3 of 6) [23/03/2005 05:57:58 p.m.]
_$ (vlax-safearray->list pt1)
(100.0 100.0 75.0)
_$ (vlax-safearray-put-element pt1 1 50)
50
_$ (vlax-safearray->list pt1)
(50.0 100.0 75.0)
Now let's populate a two-dimension array of strings :
_$ (setq two_dim (vlax-make-safearray vlax-vbString '(0 . 1) '(1 . 3)))
#<safearray...>
_$ (vlax-safearray-put-element two_dim 0 1 "a")
"a"
_$ (vlax-safearray->list two_dim)
(("a" "" "") ("" "" ""))
_$ (vlax-safearray-put-element two_dim 0 2 "b")
"b"
_$ (vlax-safearray-put-element two_dim 0 3 "c")
"c"
_$ (vlax-safearray-put-element two_dim 1 1 "d")
"d"
_$ (vlax-safearray-put-element two_dim 1 2 "e")
"e"
_$ (vlax-safearray-put-element two_dim 1 3 "f")
"f"
_$ (vlax-safearray->list two_dim)
(("a" "b" "c") ("d" "e" "f"))
You can use "vlax-safearray-get-element" to get the value of any element in any array.
Here we'll use "vlax-safearray-get-element" to retrieve the second element in the first
dimension of the array:
_$ (vlax-safearray-get-element matrix 1 2)
"b"
(vlax-safearray-get-l-bound) returns the lower boundary (starting index) of a dimension of
an array :
Get the starting index value of the second dimension of the array:
_$ (vlax-safearray-get-l-bound two_dim 2)
1
The second dimension starts with index 1.
Conversley, "vlax-safearray-get-u-bound" returns the upper boundary (end index) of a
dimension of an array
Get the end index value of the second dimension of the array:
_$ (vlax-safearray-get-u-bound two_dim 2)
3
The second dimension ends with index 3.
You can use "vlax-safearray-get-dim" to get the number of dimensions in a safearray
Arrays
http://www.afralisp.com/vl/array.htm (4 of 6) [23/03/2005 05:57:58 p.m.]
object :
Get the number of dimensions in "two_dim":
_$ (vlax-safearray-get-dim two_dim)
2
There are 2 dimensions in "two_dim".
Let's have a look at putting some of this to good use :
(vl-load-com)
(defun c:Line_VL ( / acApp acDoc mspace p1 p2 sp ep lineObj)
(setq acApp (vlax-get-acad-object))
(setq acDoc (vla-get-activedocument acApp))
(setq mspace (vla-get-modelspace acDoc))
(setq p1 (getpoint "\nFirst Point : "))
(setq p2 (getpoint p1 "\nSecond Point : "))
(setq sp (vlax-make-safearray vlax-vbdouble '(0 . 2)))
(setq ep (vlax-make-safearray vlax-vbdouble '(0 . 2)))
(vlax-safearray-fill sp p1)
(vlax-safearray-fill ep p2)
(setq lineObj (vla-addline mspace sp ep))
(princ)
);defun
There is an easier way of writing this routine :
(vl-load-com)
(defun c:Line_VL ( / acApp acDoc mspace p1 p2 lineObj)
(setq acApp (vlax-get-acad-object))
(setq acDoc (vla-get-activedocument acApp))
(setq mspace (vla-get-modelspace acDoc))
(setq p1 (getpoint "\nFirst Point : "))
(setq p2 (getpoint p1 "\nSecond Point : "))
(setq lineObj (vla-addline mspace (vlax-3d-point p1) (vlax-3d-point p2)))
(princ)
);defun
For methods that require you to pass a three-element array of doubles (typically to
specify a point), you can use the "vlax-3d-point" function.
Well, that's it with Arrays. I haven't covered absolutely everything pertaining to Arrays,
but you should now have enough to get you started. I hope that you understood
everything I was warbling on about, and that I didn't confuse you too much!!!!
Adios for now, amigo........
Arrays
http://www.afralisp.com/vl/array.htm (5 of 6) [23/03/2005 05:57:58 p.m.]

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Arrays
http://www.afralisp.com/vl/array.htm (6 of 6) [23/03/2005 05:57:58 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and Errors
In standard AutoLisp, if your program encounters an error of any sort, it passes to the *error*
function only one thing, a description of the error, and your program then ends (refer to "Error
Trapping" for more details).
Let's have a quick look at this in action. Load and run this little routine :
(defun error-test1 ()
(setq int (getint "\nEnter Number : "))
(setq result (apply 'sqrt (list int)))
(alert (strcat "Result = " (rtos result)))
(princ)
);defun
Enter "4" at the command prompt. This should result in an alert dialog displaying the answer "Result = 2".
Now, run it again and enter "- 4".
Your program will come up with an error :
_$ (error-test1)
; error: function undefined for argument: -4
The reason being of course, is that you cannot determine the square root of a negative number. Now let's
add our error trap :
(defun error-test1 ()
(setq temperr *error*)

(setq *error* trap)
(setq int (getint "\nEnter Number : "))
(setq result (apply 'sqrt (list int)))
(alert (strcat "Result = " (rtos result)))
(princ)
);defun
(defun trap (errmsg)

Visual Lisp and Errors
http://www.afralisp.com/vl/vlerror.htm (1 of 5) [23/03/2005 05:58:01 p.m.]
(setq *error* temperr)
(alert errmsg)

(alert "There was an error!!")

(princ)

);defun
Load and run the program again. The error will be encountered and control will pass to the error trap
which will display two alert dialogs, one displaying the error message, and one displaying a user defined
error message :
Your program will now stop. In a properly designed program, the error trap function would reset the
system to the state it was in before your program started. (eg. snaps would be reset, system variables would
be reset, etc).
Now this fine if you're using standard AutoLisp, but if you are using Visual Lisp function, this is another
matter. Many of the Visual Lisp functions are designed to be used in the "programming by exception" style.
This means they either return useful values if they succeed, or raise an exception if they fail (instead of
returning an error value). If your program uses Visual Lisp functions, you must prepare it to catch
exceptions, otherwise the program halts, leaving the user at the command prompt.
The advantage of this though, is that your program can intercept and attempt to process errors instead of
allowing control to pass to the *error* function.
For this we would use the "vl-catch-all-apply" function which is designed to invoke any function, return the
value from the function, and trap any error that may occur. You could call it an "inline local error
function."
The function requires two arguments :
a symbol identifying a function or "lambda" expression G
a list or arguments to be passed to the calling function G
Here's how we would use it in our program :
(setq result (vl-catch-all-apply 'sqrt (list int)))
Almost exactly the same as the "apply" function hey!
Now load and run the following, entering "- 4" at the command prompt to force and error :
(defun error-test2 ()
(setq int (getint "\nEnter Number : "))
(setq result (vl-catch-all-apply 'sqrt (list int)))
(alert (strcat "Result = " (rtos result)))
(princ)
);defun
An error message should appear at the Console prompt :
_$ (error-test2)
; error: bad argument type: numberp: #<%catch-all-apply-error%>
Visual Lisp and Errors
http://www.afralisp.com/vl/vlerror.htm (2 of 5) [23/03/2005 05:58:01 p.m.]
Have a look at the variable "result" in the Watch window :
The variable contains an "error object"!!
If the program runs correctly, "vl-catch-all-apply" stores the return value in "result". If the call is
unsuccessful, "vl-catch-all-apply" stores an error object in "result".
Using the "vl-catch-all-error-p" function, we can test for this "error object" :
(defun error-test2 ()
(setq int (getint "\nEnter Number : "))
(setq result (vl-catch-all-apply 'sqrt (list int)))
(if (vl-catch-all-error-p result)
(progn
(setq int (abs int))
(setq result (vl-catch-all-apply 'sqrt (list int)))
);progn
);if

(alert (strcat "Result = " (rtos result)))
(princ)
);defun

Load and run this routine entering "- 4" at the command prompt. This should have caused an error, but
because we used the "vl-catch-all-apply" function, the error was trapped and by testing for the error using
"vl-catch-all-error-p", we were able to rectify the problem by using the "abs" function.
Let's add our normal error function :
(defun error-test2 ()
(setq temperr *error*)

(setq *error* trap)

(setq int (getint "\nEnter Number : "))
(setq result (vl-catch-all-apply 'sqrt (list int)))
(if (vl-catch-all-error-p result)
(progn
(setq int (abs int))
Visual Lisp and Errors
http://www.afralisp.com/vl/vlerror.htm (3 of 5) [23/03/2005 05:58:01 p.m.]
(setq result (vl-catch-all-apply 'sqrt (list int)))
);progn
);if

(alert (strcat "Result = " (rtos result)))
(princ)
);defun
(defun trap (errmsg)

(setq *error* temperr)
(alert errmsg)

(alert "There was an error!!")

(princ)

);defun

Load and run the program, again entering "- 4" at the command prompt.
No error, everything runs smoothly. Now run the program again, but this time hitting "Esc" at the
command prompt. This error is not an ActiveX error, therefore the error is passed to our conventional
error trap to be processed.
Hey, we've got two "error" functions to play with now!
Another good example of when to us the "vl-catch-all-apply" function, is when dealing with "Selection Sets"
using Visual Lisp.
When you first create a selection set in Visual Lisp, all is well and good. But, if you try to create a selection
set that already exists, you will raise an error. Here's a way around that problem :
(defun selset_test1 ()
(vl-load-com)
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets acadDocument))
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if

);defun

If the selection sets does not exists, the selection set is created. If it does exist, it is first deleted and then
Visual Lisp and Errors
http://www.afralisp.com/vl/vlerror.htm (4 of 5) [23/03/2005 05:58:01 p.m.]
created.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Errors
http://www.afralisp.com/vl/vlerror.htm (5 of 5) [23/03/2005 05:58:01 p.m.]
Search
SelectAtPoint Method
Back to Methods Reference
Selects an object passing through a given point and places it into a selection set.
Signature
VBA : object.SelectAtPoint Point, FilterType, FilterData
VL : (vla-SeletAtPoint object Point FilterType FilterData)
(vla-SelectatPoint newSet thepoint)
Object SelectionSet
The object or objects this method applies to.
G
Point Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the point to use for the selection.
G
FilterType Integer; input-only; optional
A DXF group code specifying the type of filter to use.
G
FilterData Variant; input-only; optional
The value to filter on.
G
Remarks
This method supports the filtering mechanism.
For more selection mode options, see the Select, SelectByPolygon, and SelectOnScreen methods.
Refer to Visual Lisp - Selection Objects for more details.
Example :
(defun c:al-selectatpoint ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq util (vla-get-utility thisdrawing))

(setq thepoint (vla-GetPoint util nil "\nSelect Point : "))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if
(vla-SelectatPoint newSet thepoint)
(princ)
SelectAtPoint Method
http://www.afralisp.com/methods/list/selectatpoint_method.htm (1 of 2) [23/03/2005 05:58:02 p.m.]
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SelectAtPoint Method
http://www.afralisp.com/methods/list/selectatpoint_method.htm (2 of 2) [23/03/2005 05:58:02 p.m.]
Search
SelectByPolygon Method
Back to Methods Reference
Selects entities within a fence and adds them to the selection set.
Signature
VBA : object.SelectByPolygon Mode, PointsList, FilterType, FilterData
VL : (vla-SelectByPolygon object Mode PointsList FilterType FilterData)
(vla-SelectByPolygon newSet acSelectionSetFence tmp)
Object : SelectionSet
The object or objects this method applies to.
G
Mode : AcSelect enum; input-only
acSelectionSetFence
acSelectionSetWindowPolygon
acSelectionSetCrossingPolygon
G
PointsList : Variant (array of doubles); input-only
An array of 3D WCS coordinates specifying the selection fence.
G
FilterType : Integer; input-only; optional
A DXF group code specifying the type of filter to use.
G
FilterData : Variant; input-only; optional
The value to filter on.
G
Remarks
The following selection modes are available:
Fence : Selects all entities crossing a selection fence. The fence is defined by coordinates in
Point1.
G
WindowPolygon : Selects objects within a polygon defined by Point1. G
CrossingPolygon : Selects objects within and crossing an area defined by a polygon. Use Point1
to define the coordinates of the polygon. AutoCAD will close the last vector of the polygon. A
polygon definition cannot cross itself.
G
This method supports the filtering mechanism.
For more selection mode options, see the Select, SelectAtPoint, and SelectOnScreen methods.
Example :
(defun c:al-selectbypolygon ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

SelectByPolygon Method
http://www.afralisp.com/methods/list/selectbypolygon_method.htm (1 of 3) [23/03/2005 05:58:03 p.m.]
(setq newSet (vla-add ssets "$Set"))

);progn
);if
(setq pt (getpoint "\nSpecify start point: "))
(setq ptlist (cons pt ptlist))
(while (setq pt (getpoint "\nSpecify next point: " pt))
(setq ptlist (cons pt ptlist))
);while
(setq ptlist (apply 'append ptlist))
(if (= (rem (length ptlist) 3) 0)
(progn
(setq
tmp (vlax-make-safearray
vlax-vbDouble
(cons 0 (- (length ptlist) 1))
)
)
(vlax-safearray-fill tmp ptlist)
(vla-SelectByPolygon newSet acSelectionSetFence tmp)
);progn
);if
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
SelectByPolygon Method
http://www.afralisp.com/methods/list/selectbypolygon_method.htm (2 of 3) [23/03/2005 05:58:03 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SelectByPolygon Method
http://www.afralisp.com/methods/list/selectbypolygon_method.htm (3 of 3) [23/03/2005 05:58:03 p.m.]
SelectOnScreen Method
Back to Methods Reference
Prompts the user to pick an object from the screen.
Signature
VBA : object.SelectOnScreen [FilterType][, FilterData]
VL : (vla-SelectOnScreen object FilterType FilterData)
(vla-selectOnScreen newsset filter_code filter_value)
Object : SelectionSet
The object or objects this method applies to.
G
FilterType Integer; input-only; optional
A DXF group code specifying the type of filter to use.
G
FilterData Variant; input-only; optional
The value to filter on.
G
Remarks
This method supports the filtering mechanism.
AutoCAD's default prompt for picking an object will be used automatically.
For more selection mode options, see the Select, SelectByPolygon, and SelectAtPoint methods.
Refer to Visual Lisp - Selection Objects for more details.
Example :
(defun al-selectonscreen
( / ssets acadDocument newsset ctr item
filter_code filter_value)
;load the visual lisp extensions
(vl-load-com)
;retrieve a reference to the documents object
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
;retrieve a reference to the selection sets object
(setq ssets
(vla-get-selectionsets acadDocument))
;add a new selection set
(setq newsset (vla-add ssets "SS1"))
;create a single element array for the DXF Code
(setq filter_code
(vlax-make-safearray vlax-vbinteger '(0 . 0)))
;create a single element array for the value
(setq filter_value
(vlax-make-safearray vlax-vbvariant '(0 . 0)))
;DXF Code for layers
(vlax-safearray-fill filter_code '(8))
;the filter value
(vlax-safearray-fill filter_value '("7"))
SelectOnScreen Method
http://www.afralisp.com/methods/list/selectonscreen_method.htm (1 of 3) [23/03/2005 05:58:04 p.m.]
;Use Select on Screen to select objects on Layer 7
(vla-selectOnScreen newsset filter_code filter_value)
;set the counter to zero
(setq ctr 0)
;count the number of objects and loop
(repeat (vla-get-count newsset)
;retrieve each object
(setq item (vla-item newsset ctr))
;check if the entity has a color property
;and it can be updated
(setq check (vlax-property-available-p
item "Color" T))
;if it can
(if check

;change it's color
(vlax-put-property item 'Color 5)
);if
;increment the counter
(setq ctr (1+ ctr))
);repeat
;delete the selection set
(vla-delete (vla-item ssets "SS1"))
(princ)
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
SelectOnScreen Method
http://www.afralisp.com/methods/list/selectonscreen_method.htm (2 of 3) [23/03/2005 05:58:04 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SelectOnScreen Method
http://www.afralisp.com/methods/list/selectonscreen_method.htm (3 of 3) [23/03/2005 05:58:04 p.m.]
SendCommand Method
Back to Methods Reference
Sends a command string to the document for processing.
Signature
VBA : object.SendCommand(Command)
VL : (vla-SendCommand object Command)
(vla-SendCommand thisdrawing (strcat "Zoom" " " "e" " "))
Object : Document
The object or objects this method applies to.
G
Command : String; input-only
The command to send to the document.
G
Remarks
This method processes any AutoCAD command-line function, including LISP expressions.
If the drawing specified is not active, it will be made active.
This method is generally synchronous. However, if the command sent with this method requires any
user interaction (such as picking a point on the screen), then this method will return as soon as the
user input begins. The command will then continue to be processed asynchronously.
When this method is called from an event handler it is processed asynchronously.
You should never use this method to issue a command for which there is an ActiveX method available.
For example, do not use SendCommand "VBALOAD ". Instead, use the LoadDVB method.
Example :
(defun c:al-sendcommand ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(vla-SendCommand thisdrawing (strcat "Zoom" " " "e" " "))
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
SendCommand Method
http://www.afralisp.com/methods/list/sendcommand_method.htm (1 of 2) [23/03/2005 05:58:04 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SendCommand Method
http://www.afralisp.com/methods/list/sendcommand_method.htm (2 of 2) [23/03/2005 05:58:04 p.m.]
SetVariable Method
Back to Methods Reference
Sets the value of an AutoCAD system variable.
Signature
VBA : object.SetVariable Name, Value
VL : (vla-SetVariable Name Value)
(vla-SetVariable thisdrawing "OSMODE" 0)
Object : Document
The object or objects this method applies to.
G
Name : String; input-only
The name of the system variable to set.
G
Value : Variant; input-only
The new value for the specified system variable.
G
Remarks
When setting system variables, AutoCAD may require integers, text, or double values. Passing the
wrong data type (for example, passing a variant of type double when an integer is required) will
generate an error. The easiest way to avoid this is to explicitly type your data before passing it.
For a list of all AutoCAD system variables and their types, please refer toSystem Variables.
Example :
(defun c:al-setvariable ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(vla-SetVariable thisdrawing "OSMODE" 0)
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
SetVariable Method
http://www.afralisp.com/methods/lista/setvar_method.htm (1 of 2) [23/03/2005 05:58:05 p.m.]
Search
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
SetVariable Method
http://www.afralisp.com/methods/lista/setvar_method.htm (2 of 2) [23/03/2005 05:58:05 p.m.]
StartUndoMark Method
Back to Methods Reference
Marks the start of a block of operations.
Signature
VBA : object.StartUndoMark
VL : (vla-StartUndoMark object)
(vla-startundomark thisdrawing)
Object : Document
The object or objects this method applies to.
G
Remarks
This method allows AutoCAD to close the environment so operations from StartUndoMark to
EndUndoMark can be treated as a group of operations.
Example :
(defun c:al-undomark ()
;This example creates a series of lines, each one with an undo marker
;defined for it. After lines are created you can switch to AutoCAD
;and type the Undo command, and only one line at a time will be undone.
;If StartUndoMark call is not made, an undo in AutoCAD will undo
;all the lines at once.
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq mspace (vla-get-modelspace thisdrawing))
(repeat 3
(setq pt1 (getpoint "\nSpecify First Point: "))
(setq pt2 (getpoint "\nSpecify Second Point: " pt1))
(vla-startundomark thisdrawing)
(setq myline (vla-addline mspace
(vlax-3d-point pt1)(vlax-3d-point pt2)))
(vla-endundomark thisdrawing)
);repeat
(princ)
);defun

StartUndoMark Method
http://www.afralisp.com/methods/lista/startundomark_method.htm (1 of 2) [23/03/2005 05:58:06 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
StartUndoMark Method
http://www.afralisp.com/methods/lista/startundomark_method.htm (2 of 2) [23/03/2005 05:58:06 p.m.]
Search
UnloadARX Method
Back to Methods Reference
Unloads the specified AutoCAD ARX application.
Signature
VBA : object.UnloadARX Name
VL : (vla-UnloadARX object Name)
(vla-UnLoadARX applic "c:/test.arx")
Object : Application
The object or objects this method applies to.
G
Name : String; input-only
The name of the application to unload.
G
Remarks
If the specified application is locked when this method is called, the method will fail.
NOTE Do not attempt to unload the file acadvba.arx.
Example :
(defun c:al-unloadarx ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(vla-UnLoadARX applic "c:/test.arx")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
UnloadARX Method
http://www.afralisp.com/methods/lista/unloadarx_method.htm [23/03/2005 05:58:07 p.m.]
Search
UnloadDVB Method
Back to Methods Reference
Unloads the specified AutoCAD VBA project file.
Signature
VBA : object.UnloadDVB Name
VL : (vla-UnloadDVB object Name)
(vla-UnLoadDVB applic "c:/test.dvb")
Object : Application
The object or objects this method applies to.
G
Name : String; input-only
The name of the .dvb project to unload.
G
Example :
(defun c:al-unloaddvb ()
(vl-load-com)
(setq applic (vlax-get-acad-object))

(vla-UnLoadDVB applic "c:/test.dvb")
(princ)
);defun

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
UnloadDVB Method
http://www.afralisp.com/methods/lista/unloaddvb_method.htm [23/03/2005 05:58:08 p.m.]
Search
WBlock Method
Back to Methods Reference
Writes out the given selection set as a new drawing file.
Signature
VBA : object.WBlock FileName, SelectionSet
VL : (vla-WBlock object FileName SelectionSet)
(vla-WBlock thisdrawing "c:/test.dwg" newSet)
Object : Document
The object or objects this method applies to.
G
FileName : String; input-only
The file name to write the selection set to.
G
SelectionSet : SelectionSet object; input-only
The name of the selection set.
G
Example :
(defun c:al-wblock ()
(vl-load-com)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(setq ssets (vla-get-selectionsets thisdrawing))
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-item (list ssets "$Set")))
(setq newSet (vla-add ssets "$Set"))

(progn

(vla-delete (vla-item ssets "$Set"))

(setq newSet (vla-add ssets "$Set"))

);progn
);if
;select all objects in the drawing
(vla-Select newSet acSelectionSetAll)
(vla-WBlock thisdrawing "c:/test.dwg" newSet)
(princ)
);defun

WBlock Method
http://www.afralisp.com/methods/list/wblock_method.htm (1 of 2) [23/03/2005 05:58:08 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
WBlock Method
http://www.afralisp.com/methods/list/wblock_method.htm (2 of 2) [23/03/2005 05:58:08 p.m.]
Search
ZoomAll Method
Back to Methods Reference
Zooms the current viewport to display the entire drawing.
Signature
VBA : object.ZoomAll ()
VL : (vla-ZoomAll object)
(vla-ZoomAll acadapplic)
Object : Application
The object or objects this method applies to.
Remarks
In a plan view, AutoCAD zooms to the drawing limits or current extents, whichever is greater. In
a 3D view, ZoomAll is equivalent to the ZoomExtents method. The display shows all objects
even if the drawing extends outside the drawing limits.
This method applies only to the current active viewport (paper space viewport or model space
viewport).
G
Example :
;Get a reference to the Application object
(setq acadapplic (vlax-get-acad-object))
(vla-ZoomAll acadapplic)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomAll Method
http://www.afralisp.com/methods/list/zoomall_method.htm [23/03/2005 05:58:09 p.m.]
Search
ZoomCenter Method
Back to Methods Reference
Zooms the current viewport to a specified center point and magnification.
Signature
VBA : object.ZoomCenter Center, Magnify
VL : (vla-ZoomCenter object Center Magnify)
(vla-ZoomCenter acadapplic PT1 SC)
Object : Application
The object or objects this method applies to.
G
Center : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the center of the zoom.
G
Magnify : Double; input-only
The magnification level of the window. A value smaller than the current value increases the
magnification. A larger value decreases the magnification.
G
Remarks
This method applies only to the current active viewport (paper space viewport or model space
viewport).
Example :
(defun c:al-zc ()
(vl-load-com)
;get reference to the Application Object
(setq acadapplic (vlax-get-acad-object))
;get reference to the Utility object
(setq util (vla-get-utility (vla-get-activedocument acadapplic)))
;get the first point
(setq PT1 (vla-getpoint util nil "\nSpecify center point: "))
;get the magniofication
(setq SC (vla-getreal util "\nEnter magnification or height : "))
;zoom center
(vla-ZoomCenter acadapplic PT1 SC)
(princ)
);defun
(princ)

ZoomCenter Method
http://www.afralisp.com/methods/list/zoomcenter_method.htm (1 of 2) [23/03/2005 05:58:10 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomCenter Method
http://www.afralisp.com/methods/list/zoomcenter_method.htm (2 of 2) [23/03/2005 05:58:10 p.m.]
Search
ZoomExtents Method
Back to Methods Reference
Zooms the current viewport to the drawing extents.
Signature
VBA : object.ZoomExtents
VL : (vla-ZoomExtents object)
(vla-ZoomExtents acadapplic)
Object : Application
The object or objects this method applies to.
Remarks
This method applies only to the current active viewport (paper space viewport or model space
viewport).
G
Example :
;Get a reference to the Application object
(setq acadapplic (vlax-get-acad-object))
(vla-ZoomExtents acadapplic)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomExtents Method
http://www.afralisp.com/methods/list/zoomextents_method.htm [23/03/2005 05:58:11 p.m.]
Search
ZoomPickWindow Method
Back to Methods Reference
Zooms the current viewport to a window defined by points picked on the screen.
Signature
VBA : object.ZoomPickWindow
VL : (vla-ZoomPickWindow object)
(vla-ZoomPickWindow acadapplic)
Object : Application
The object or objects this method applies to.
G
Remarks
This method applies only to the current active viewport (paper space viewport or model space
viewport).
Example :
;Get a reference to the Application object
(setq acadapplic (vlax-get-acad-object))
(vla-ZoomPickWindow acadapplic)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomPickWindow Method
http://www.afralisp.com/methods/list/zoompickwindow_method.htm [23/03/2005 05:58:12 p.m.]
Search
ZoomPrevious Method
Back to Methods Reference
Zooms the current viewport to its previous extents.
Signature
VBA : object.ZoomPrevious
VL : (vla-ZoomPrevious object)
(vla-ZoomPrevious acadapplic)
Object : Application
The object or objects this method applies to.
Remarks
This method applies only to the current active viewport (paper space viewport or model space
viewport).
This method zooms to display the previous view. You can restore up to 10 previous views.
NOTE! If you change the shading with the SHADEMODE command the view is changed. If you
perform a ZoomPrevious after changing the shading, it restores the previous view which is
shaded differently, but not zoomed differently.
G
Example :
;Get a reference to the Application object
(setq acadapplic (vlax-get-acad-object))
(vla-ZoomPrevious acadapplic)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomPrevious Method
http://www.afralisp.com/methods/list/zoomprevious_method.htm [23/03/2005 05:58:12 p.m.]
Search
ZoomScaled Method
Back to Methods Reference
Zooms the current viewport to given scale factor.
Signature
VBA : object.ZoomScaled Scale, ScaleType
VL : (vla-ZoomScaled object Scale ScaleType)
(vla-ZoomScaled acadapplic SC acZoomScaledRelative)
Object : Application
The object or objects this method applies to.
G
Scale : Double; input-only
The zoom factor for the zoom.
G
ScaleType : AcZoomScaleType enum, input-only; optional
acZoomScaledAbsolute
acZoomScaledRelative
acZoomScaledRelativePSpace
G
Remarks
The ScaleType value determines how the scale factor is applied:
Relative to the drawing limitsuse acZoomScaledAbsolute
Relative to the current viewuse acZoomScaledRelative
Relative to paper space unitsuse acZoomScaledRelativePSpace
This method applies to the current active viewport (paper space viewport or model space viewport).
Example :
(defun c:al-zs ()
(vl-load-com)
;get reference to the Application Object
(setq acadapplic (vlax-get-acad-object))
;get reference to the Utility object
(setq util (vla-get-utility (vla-get-activedocument acadapplic)))
;get the scale factor
(setq SC (vla-getreal util "\nEnter a scale factor : "))
;zoom Scaled
(vla-ZoomScaled acadapplic SC acZoomScaledRelative)
(princ)
);defun
(princ)

ZoomScaled Method
http://www.afralisp.com/methods/list/zoomscaled_method.htm (1 of 2) [23/03/2005 05:58:13 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomScaled Method
http://www.afralisp.com/methods/list/zoomscaled_method.htm (2 of 2) [23/03/2005 05:58:13 p.m.]
Search
ZoomWindow Method
Back to Methods Reference
Zooms the current viewport to the area specified by two opposite corners of a rectangle.
Signature
VBA : object.ZoomWindow LowerLeft, UpperRight
VL : (vla-ZoomWindow Lowerleft UpperRight)
(vla-ZoomWindow acadapplic PT1 PT2)
Object : Application
The object or objects this method applies to.
G
LowerLeft Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the lower-left corner of the window to display.
G
UpperRight Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the upper-right corner of the window to display.
G
Remarks
This method applies to the current active viewport (paper space viewport or model space viewport).
Example :
(defun c:al-zw ()
;get reference to the Application Object
(setq acadapplic (vlax-get-acad-object))
;get reference to the Utility object
(setq util (vla-get-utility (vla-get-activedocument acadapplic)))
;get the first point
(setq PT1 (vla-getpoint util nil "\nFirst Point : "))
;get the second point
(setq PT2 (vla-getcorner util PT1 "\nSecond Point : "))
;zoom window
(vla-ZoomWindow acadapplic PT1 PT2)
(princ)
);defun
(princ)

ZoomWindow Method
http://www.afralisp.com/methods/list/zoomwindow_method.htm (1 of 2) [23/03/2005 05:58:14 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
ZoomWindow Method
http://www.afralisp.com/methods/list/zoomwindow_method.htm (2 of 2) [23/03/2005 05:58:14 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home Page II
Collections
All Objects in AutoCAD are grouped into collections. If you have a look at the AutoCAD
Object Model, you will find all the Layers within the Layers collection, all the Blocks
within the Blocks collection, etc. etc.
This tutorial will show you how to first, create a reference to the required collection,
secondly, extract objects stored within the collection, and last but not least, manipulate
these Objects.
Let's start right at the bottom of the Object Model with the Documents collection. Open
any two drawings in AutoCAD then open the Visual List Editor and enter this :
_$ (vl-load-com)
_$ (setq acadObject (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00adc088>
Let's have a look at the "acadObject" in the Inspect window :
The object that we are interested in at this stage is the Documents object. Let's drill down to it :
_$ (setq acadDocuments (vla-get-documents acadObject))
#<VLA-OBJECT IAcadDocuments 01f585d0>
Have look at the variable "acadDocuments" in the inspect window :
Collections
http://www.afralisp.com/vl/collect1.htm (1 of 3) [23/03/2005 05:58:17 p.m.]
As you can see, this collection contains 2 objects. But how do we access these objects? Copy and
paste the following coding and save it as "tempList .lsp" :
(defun tempList (theObject / item dwgName)
(vl-load-com)
(setq theList '())
(vlax-for item theObject
(setq dwgName (vlax-get-property item 'Name))
(setq theList (append (list dwgName) theList))
);
(setq theList (reverse theList))
(princ)
);defun

Don't worry to much at this stage about how this function works. We'll get to that later. Load the
function and then type the following :
_$ (tempList acadDocuments)
Now examine the variable "theList" :
_$ theList
("Kenny.dwg" "is handsome.dwg")
This list now holds the contents of the Documents collection, or in other words, all the drawings you
have open within AutoCAD..
Let's go further in the Object Model and have a look at the Layers collection.
We first get a reference to the "Active Document" :
_$ (vl-load-com)
_$ (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00ee0f84>
Next, a reference to the Layer's collection :
(setq theLayers (vla-get-layers acadDocument))
#<VLA-OBJECT IAcadLayers 01f5b0a4>
Now, let's extract all the Layer names into a list :
_$(tempList theLayers)
_$ theList
("0" "1" "2" "3" "4" "5" "6" "7" "DEFPOINTS" "8" "9" "10")
Great, we now have a list of all our Layers within the current drawing.
To manipulate objects within a collection, we first need to iterate through the collection and extract
a reference to the object, or objects that we are interested in. Visual Lisp provides us with a few
functions to help us with this task. Let's say for example that we wanted to change all the Layers in
the drawing to Color 3. Consider this :
(defun laycol ()
Collections
http://www.afralisp.com/vl/collect1.htm (2 of 3) [23/03/2005 05:58:17 p.m.]
(vl-load-com)

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq i 0)

(repeat (vla-get-count theLayers)

(setq aLayer (vla-item theLayers i))

(vla-put-color alayer 3)
(setq i (1+ i))

);repeat
(princ)
);defun

Here we've used the standard AutoLisp function "repeat" to loop through the collection. We used
the "vla-get-count" function to count the number of objects in the collection, and the function
"vla-item" function to extract each object from the collection.
On the next page we'll have a look at a few more functions that will make your life a lot easier when
dealing with collections.
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Collections
http://www.afralisp.com/vl/collect1.htm (3 of 3) [23/03/2005 05:58:17 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home Page I
Collections - Page II
On the first page we looked at changing all the Layers Color property using the "repeat"
command. Here's a much easier and quicker way :
(defun laycol1 ()
(vl-load-com)

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-for item theLayers
(vla-put-color item 3)

)
(princ)
);defun

"vlax-for" allows you to loop through each item in the collection, without having to count the
number of objects and doing away with the need for loop control. This is the same method I used in
the "tempList" function that we used earlier on in this tutorial.
Here's another example. Would you like to ensure that all your Layers are On before performing a
certain function? Have a look at this :
(defun layeron ()
(vl-load-com)

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-for item theLayers
(vlax-put-property item "LayerOn" ':vlax-true)

)
(princ)
);defun
Collections II
http://www.afralisp.com/vl/collect2.htm (1 of 4) [23/03/2005 05:58:18 p.m.]

One word of warning. DO NOT Add or Remove objects whilst iterating through a collection. This
can and will cause errors.
One of the most powerful commands in our collections arsenal is the "vlax-map-collection"
function. If you are not familiar with the "mapcar" and "lambda" functions, I suggest you read my
tutorial on these functions which you can find here.
Load and run this in the Visual Lisp Editor :
(defun layer-dump ()
(vl-load-com)
(setq theList '())

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'vlax-dump-object)
(princ)
);defun

This will dump all properties of all the Layer objects in your drawing to the console screen.
You are not limited to Visual Lisp functions within a "vlax-map-collection" call. You can also use
your own user defined function. Let's say for some reason we wanted to make a list of all Layers in
your drawing, switch all Layers On and change every Layer in the drawing to Color "5". This is
how you could do it :
(defun layerMap ()
(vl-load-com)
(setq theList '())

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'layer-mod)
(princ)
);defun
(defun layer-mod (theLayer)
(setq dwgName (vlax-get-property theLayer 'Name))
(setq theList (append (list dwgName) theList))
(setq theList (reverse theList))
Collections II
http://www.afralisp.com/vl/collect2.htm (2 of 4) [23/03/2005 05:58:18 p.m.]
(vlax-put-property theLayer "LayerOn" ':vlax-true)
(vla-put-color thelayer 5)
);defun

As you can see, each Layer object is passed to the function "layer-mod" as the argument. You could
also write this as an inline function using "lambda" :
(defun layerMap1 ()
(vl-load-com)
(setq theList '())

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers
'(lambda (theLayer)
(setq dwgName (vlax-get-property theLayer 'Name))
(setq theList (append (list dwgName) theList))
(setq theList (reverse theList))
(vlax-put-property theLayer "LayerOn" ':vlax-true)
(vla-put-color thelayer 5)
);lambda
);vlax-map-collection
(princ)
);defun
Want to add to a collection? Let's add a new Layer to our drawing :
(defun layerAdd ()
(vl-load-com)
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq newLayer (vla-add theLayers "Steel"))
(vla-put-color newLayer 5)
(vla-put-linetype newLayer "Dashed2")
Collections II
http://www.afralisp.com/vl/collect2.htm (3 of 4) [23/03/2005 05:58:18 p.m.]
(princ)
);defun
This routine creates a new Layer named "Steel" with Color "5" and a Linetype of "Dashed2". If
the Layer already exists, this routine simply does nothing.
To delete a Layer from the collection, simply use the "delete" method :
_$ (vla-delete newLayer)
Be careful though, if any objects within your drawing are referencing this Layer, you will get an
error :
_$ (vla-delete newLayer)
; error: Automation Error. Object is referenced by other object(s)
Right, I've had enough of talking about collections. Now I'm going to check out my beer collection.
It's not very big as I only collect the full ones. The empty ones I throw away. Ta, ta for now.......
Home Page I

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Collections II
http://www.afralisp.com/vl/collect2.htm (4 of 4) [23/03/2005 05:58:18 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II. Page III.
Reactors
"What the heck is a reactor?
I asked myself exactly the same question when I first came across the phrase. "It must be
another name for an Event", I said to myself. I was wrong, again!!!
A reactor is an Object you attach to AutoCAD Objects to have AutoCAD notify your
application when a particular event, or events occur.
(Remember, that an AutoCAD Object can be an Object within your drawing, the drawing
itself, or even AutoCAD, the application - just thought I'd tell you).
This is the general procedure :
An Event occurs in your drawing. G
AutoCAD notifies the Reaction associated with that Event. G
The reaction then notifies your application, known as a callback function, passing
to it certain information applicable to the Event in the form of arguments.
G
Your application then does it's thing using the information passed to it from the
Reactor.
G
So, in simple terms, a Reactor is the "link" between the Event and the callback function.
Before we get into looking at the different types of AutoCAD Reactors and Events, let's
have a look at a fairly straightforward Reactor to give you an idea of how simple they can
be. Before you start though, you must ask yourself two questions :
Before, after or during what Event do you want your function to occur? 1.
What do you want your function to do? 2.
For this example, I will answer both these questions on your behalf.
"I want my function to run every time a drawing Save is completed". 1.
"I want the function to tell me what the name of the drawing is, and how big the
drawing is".
2.
O.K. Looking at the Reactor listings, (Refer to Visual Lisp Reference), under the Editor
Reactor Types, I find a reactor called "vl-dwg-reactor". This reactor, I am led to believe,
responds to the "Save Complete" event of a drawing, and returns callback data of a
string containing the actual file name used for the save.
Hey, this is just what we are looking for. Let's order two to take-away.
Enough of this childish wit!!
Let's have a look at the reactor definition and syntax first :
vlr-dwg-reactor - Constructs an editor reactor object that notifies of a drawing event.
(vlr-dwg-reactor data callbacks)
Arguments :
data : AutoLisp data to be associated with the reactor object, or nil, if no data
callbacks : A list of pairs of the following form :
(event-name . callback_function)
Reactors I
http://www.afralisp.com/vl/reactors1.htm (1 of 4) [23/03/2005 05:58:22 p.m.]
where event-name is one of the symbols listed in the "DWG reactor events"
table, and callback_function is a symbol representing the function to be called
when the event fires. Each callback function will accept two arguments :
reactor_object - the VLR object that called the callback function,
list - a list of extra data elements associated with the particular event.
I don't know about you? But, whew.........!!!
Right, let's try and put this into simple English. Let's look at the syntax again :
(vlr-dwg-reactor data callbacks)
The first part "vlr-dwg-reactor" is easy. This is the name of the reactor type. This name
will be sent to your call back function.
The first argument "data", is User Application Data. We usually set this to a reactor name
of our choosing. This way we can distinguish between reactors if an Objects has multiple
reactors attached.
The second argument "callbacks" is a straightforward list of dotted pairs.
The first element of the list is the name of the reactor "event" that will trigger the
reactor and then call your callback function.
G
The second element, is the name of your Callback function. G
This is what our reactor function will look like :
(vlr-dwg-reactor "Save Complete" '((:vlr-savecomplete . savedrawinginfo)))
Or, graphically :
Let's have a look at our Reactor Function in action. Copy and Paste this coding into the
Visual Lisp Editor and save it as "SaveDrawingInfo.Lsp".
Next Load the application, but DO NOT run it.
(vl-load-com)
;**************************************************************
;setup and intilise the reactor
(vlr-dwg-reactor "Save Complete" '((:vlr-savecomplete . savedrawinginfo)))
;**************************************************************
Reactors I
http://www.afralisp.com/vl/reactors1.htm (2 of 4) [23/03/2005 05:58:22 p.m.]
(defun saveDrawingInfo (calling-reactor commandInfo / dwgname filesize
reactType reactData reactCall
reactEvent reactCallback)
;get the reactor Object
(setq reactInfo calling-reactor
;get the reactor Type
reactType (vl-symbol-name (vlr-type reactInfo))
;get the Application Data
reactData (vlr-data reactInfo)
;get the Callback list
reactCall (car (vlr-reactions reactInfo))
;extract the Event Reactor
reactEvent (vl-symbol-name (car reactCall))
;extract the Callback Function
reactCallback (vl-symbol-name (cdr reactCall))
);setq
;get the Drawing Name
(setq dwgname (cadr commandInfo)
;extract the filesize
filesize (vl-file-size dwgname)

);setq
;display the Drawing Name and Size
(alert (strcat "The file size of " dwgname " is "

(itoa filesize) " bytes."))
;Display the Reactor Information
(alert
(strcat
"A " "\"" reactType "\"" " named " "\"" reactData "\"" "\n"
"was triggered by a " "\"" reactEvent "\"" " event call." "\n"
"Callback Data was passed to the" "\n"
"\"" reactCallback "\"" " call back function."))
(princ)
);defun
;********************************************************
(princ)
;********************************************************
Once the application is loaded, return to AutoCAD and save the drawing.
This dialog will appear :
Reactors I
http://www.afralisp.com/vl/reactors1.htm (3 of 4) [23/03/2005 05:58:22 p.m.]
Followed by this dialog :
Do you notice the "calling-reactor" and "commandInfo" argument declarations? This
information, the Reactor Object Name and the Event Parameter Information is passed to
our Callback Function from the Reactor.
Clever hey?
On the next Page, we'll have a look at some Drawing Reactors.
Home. Page II. Page III.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Reactors I
http://www.afralisp.com/vl/reactors1.htm (4 of 4) [23/03/2005 05:58:22 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page III.
Reactors - Page II
Another Editor Type of reactor is the "VLR-Command-Reactor". This reactor notifies us
of a Command Event. In this instance we will make use of the "vlr-commandEnded"
reactor event which returns a event parameter list containing a string identifying the
command that has been cancelled.
Every time a drawing is plotted, our call back function will first, save the drawing, and
secondly save the drawing to a backup directory, namely C:/Backup. Let's have a look at
the coding :
(prompt " \nLoad Only....Do NOT Run...")
(vl-load-com)
;*******************************************************
(vlr-command-reactor
"Backup After Plot" '((:vlr-commandEnded . endPlot)))
;*******************************************************
(defun endPlot (calling-reactor endcommandInfo /
thecommandend drgName newname)
(setq thecommandend (nth 0 endcommandInfo))
(if (= thecommandend "PLOT")
(progn
(setq acadDocument (vla-get-activedocument
(vlax-get-acad-object)))
(setq drgName (vla-get-name acadDocument))
(setq newname (strcat "c:\\backup\\" drgName))
(vla-save acadDocument)
(vla-saveas acadDocument newname)
);progn
);if

(princ)

Reactors II
http://www.afralisp.com/vl/reactors2.htm (1 of 3) [23/03/2005 05:58:23 p.m.]
);defun
;*********************************************************
(princ)
A word of warning!!! Did you notice how I used ActiveX statements and functions to "Save" and
"SaveAs". You cannot use interactive functions from within a reactor as AutoCAD may still be
processing a command at the time the event is triggered. Therefore, avoid the use of
input-acquisition methods such as "getPoint", "ensel", and "getkword", as well as "selection set"
operations and the "command" function.
Here's another interesting command event reactor :
When a user adds Text or Hatch to the drawing, the layer will automatically change to Layer "4"
or Layer "6" respectively. When the command is completed, or cancelled, the user is returned to
the original Layer he was on before he started the command. Save the file as "LayMan.lsp", BUT
please remember, that as this routine contains reactors, you must only Load it and NOT Run it. If
you want to use this routine on a permanent basis, you'll have to ensure that it is loaded at startup.
There is also no checking to ensure that the layers exist, are frozen, switched off, etc. and no other
form of error checking. I've got to leave something for you to do!!!
(prompt " \nLoad Only....Do NOT Run...")
(vl-load-com)
;****************************************
(vlr-command-reactor
nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor
nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor
nil '((:vlr-commandCancelled . cancelCommand)))
;******************************************************
(defun startCommand (calling-reactor startcommandInfo /
thecommandstart)
(setq OldLayer (getvar "CLAYER"))
(setq thecommandstart (nth 0 startcommandInfo))
(cond
((= thecommandstart "TEXT") (setvar "CLAYER" "4"))
((= thecommandstart "MTEXT") (setvar "CLAYER" "4"))
((= thecommandstart "DTEXT") (setvar "CLAYER" "4"))
((= thecommandstart "HATCH") (setvar "CLAYER" "6"))
((= thecommandstart "BHATCH") (setvar "CLAYER" "6"))
);cond
(princ)
);defun
;****************************************************
(defun endCommand (calling-reactor endcommandInfo /
thecommandend)
(setq thecommandend (nth 0 endcommandInfo))
(cond
((= thecommandend "TEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "MTEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "DTEXT") (setvar "CLAYER" OldLayer))
((= thecommandend "HATCH") (setvar "CLAYER" OldLayer))
((= thecommandend "BHATCH") (setvar "CLAYER" OldLayer))
Reactors II
http://www.afralisp.com/vl/reactors2.htm (2 of 3) [23/03/2005 05:58:23 p.m.]
);cond
(princ)
);defun
;********************************************************
(defun cancelCommand (calling-reactor cancelcommandInfo /
thecommandcancel)
(setq thecommandcancel (nth 0 cancelcommandInfo))
(cond
((= thecommandcancel "TEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "MTEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "DTEXT") (setvar "CLAYER" OldLayer))
((= thecommandcancel "HATCH") (setvar "CLAYER" OldLayer))
((= thecommandcancel "BHATCH") (setvar "CLAYER" OldLayer))
);cond
(princ)
);defun
;*********************************************************
(princ)
Did you notice that this application used three command reactors with three different command
events. We could have incorporated all three reactor events and call back functions under one
command reactor type, but I prefer to leave them separate for clarity and ease of debugging.
O.K. that's enough of command reactors. Let's have a look at Object Reactors.
See you on Page III

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Reactors II
http://www.afralisp.com/vl/reactors2.htm (3 of 3) [23/03/2005 05:58:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I. Page II.
Reactors - Page III
Object Reactors, or "VLR-Object-Reactor", fall under general reactor types. They are
almost identical in functionality to Drawing and Command reactors except for a couple of
things! They need to include a reference to the Object that will be reacted upon, (Crikey,
that sounds terrible!!) and the reference to the Object needs to be created before the
reactor is called. Let's have a look at the syntax of an Object reactor :
(vlr-object-reactor owners data callback)
The "data" and "callback" arguments, we are familiar with. But what is the "owner"
argument? This is an AutoLisp list of Visual Lisp Objects identifying the drawing Objects
to be watched. In other words, a reference to the Object that contains the reactor.
The reactor event we are going to use is the ":vlr-modified event", and our Callback function will be
named "print-length".
Have a look at the coding for our reactor :
(vlr-object-reactor (list myLine) "Line Reactor" '((:vlr-modified . print-length)))
As I mentioned earlier though, we need to have a reference to the Object before we can
call this statement. Consider the following :
(vl-load-com)
;*************
(defun line-draw ()
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace acadDocument))
(setq apt (getpoint "Specify First Point: "))
(setq pt (getpoint "Specify next point: " apt))
(setq myLine (vla-addline mspace (vlax-3d-point apt)(vlax-3d-point pt)))
(setq lineReactor (vlr-object-reactor (list myLine)
"Line Reactor" '((:vlr-modified . print-length))))
(princ)
);defun
We started off by drawing a line. As the line was created from scratch, and created using Visual Lisp
functions, we already have a reference to the line Object. (myLine). We can now safely run our
reactor function and attach it to our Line.
"But where is the Callback function?"
Reactors III
http://www.afralisp.com/vl/reactors3.htm (1 of 3) [23/03/2005 05:58:24 p.m.]
Hah, I was waiting for that. We've made the Callback function a separate function for one main
reason. If we didn't, every time we ran the application it would prompt us to draw a new line. So,
what we have to do now, is link the reactor function to our Callback function so that when our line is
modified, only the Callback function is put into motion. The reactor sends three arguments to the
Callback function, the notifier-object (our line), the reactor-object (:vlr-modified), and the event
parameter-list which in this case is nil.
Here's the coding for the Callback function :
(defun print-length (notifier-object reactor-object parameter-list)
(cond
((vlax-property-available-p notifier-object "Length")
(alert (strcat "The length is now "
(rtos (vla-get-length notifier-object)))))
);cond
(princ)
);defun
(princ)
Copy all of this coding into one file and save it as "Line-Draw.Lsp". Now load "Line-Draw.Lsp" and
then run (line-draw). Draw a single line when prompted. Now stretch the line so that it's length
changes. A dialog will appear displaying the new length of the line :
In essence, this is what happened :
We loaded "Line-draw.Lsp" and all functions contained within were placed into memory. G
We ran (line-draw) which prompted us to draw a line. The reactor was then loaded and linked
to both the line Object and the Callback function.
G
As the Callback function "print-length" was also loaded into memory, every time we modify
the line Object, the Callback function is processed and the length of the line is displayed.
G
Did you notice how we checked that our Object had a "Length" Property before continuing? Good
idea, as this validation can save lot's of problems.
"But what happens when I close my drawing? Will I lose all my reactors?"
Good questions. Reactors can be transient or persistent. Transient reactors are lost when the
drawing closes and this is the default reactor mode. Persistent reactors are saved with the drawing
and exist when the drawing is next open.
You can use the "vlr-pers" function to make a reaction persistent. To remove a persistence from a
reactor and make it transient, use the "vlr-pers-release" function. To determine whether a reactor is
persistent or transient, use the "vlr-pers-p" function. Each function takes the reactor Object as it's
only argument :
_$(vlr-pers lineReactor)
#<VLR-Object-Reactor>
If successful "vlr-pers" returns the specified reactor Object.
Note : A reactor is only a link between an event and a Callback function. The Callback function is
Reactors III
http://www.afralisp.com/vl/reactors3.htm (2 of 3) [23/03/2005 05:58:24 p.m.]
not part of the reactor, and is normally not part of the drawing. The reactors saved in the drawing
are only usable if their associated Callback functions are loaded in AutoCAD.
In other words, if we made our reactor "lineReactor" persistent, we would have to ensure that the
Callback function "print-length" was loaded every time the drawing containing our lines with
reactors was opened.
If you would like the source coding for all the example in this tutorial, then you can download them
from here.
Home. Page I. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Reactors III
http://www.afralisp.com/vl/reactors3.htm (3 of 3) [23/03/2005 05:58:24 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and Layers
I have had so many queries lately regarding Visual Lisp and Layer's, that I decided to dedicated a
complete section dedicated to this subject. Please remember though, that what you read here is not all
encompassing in regards to Layers and could possible be added to over time. (in other words, I'm
making excuses in case I miss anything).
Layer's in AutoCAD are contained within the Layer's Collection which is stored in the Document Object
which is part of the Documents Collection which is part of the Application Object or AutoCAD itself.
Confused? Have a look at an extract from the AutoCAD Object Model :
Application(Object)
|
|
|------- Documents[Collection]
| |
| |
| |
| Document(Object)
| |
| |
| |------ Layers-------Layer
| | [Collection] (Object)
| |
| |
| |
| |
To retrieve a Layer to play with, we first need to access the Layer's Collection.
Type this at the Console prompt :
_$ (vl-load-com)
_$ (setq acadobject (vlax-get-Acad-Object))
#<VLA-OBJ ECT IAcadApplication 00adc088>
We are now in the Application Object. Now let's sneak into the Document Object :
_$ (setq activedocument (vla-get-activedocument acadobject))
#<VLA-OBJ ECT IAcadDocument 01945554>
And into the Layers Collection we go!
_$ (setq LayerTable (vla-get-layers activedocument))
#<VLA-OBJ ECT IAcadLayers 01a070bc>
"But, hang on one second, you jumped from the Application Object straight to the Document Object!!"
Hey, well spotted. I'm glad to see that you're wide awake. OK, I suppose an explanation would be in
order.
Let's run a dump on the Application Object :
_$ (vlax-dump-object acadobject)
; IAcadApplication: An instance of the AutoCAD application
; Property values:
; ActiveDocument =#<VLA-OBJ ECT IAcadDocument 01945504>
; Application (RO) =#<VLA-OBJ ECT IAcadApplication 00adc088>
; Caption (RO) ="AutoCAD 2000 - [Drawing1.dwg]"
; Documents (RO) =#<VLA-OBJ ECT IAcadDocuments 02d06860>
; FullName (RO) ="C:\\ACAD2000\\acad.exe"
; Height =776
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (1 of 6) [23/03/2005 05:58:26 p.m.]
; LocaleId (RO) =1033
; MenuBar (RO) =#<VLA-OBJ ECT IAcadMenuBar 02d096c4>
; MenuGroups (RO) =#<VLA-OBJ ECT IAcadMenuGroups 015baf2c>
; Name (RO) ="AutoCAD"
; Path (RO) ="C:\\ACAD2000"
; Preferences (RO) =#<VLA-OBJ ECT IAcadPreferences 015bb9ec>
; StatusId (RO) =...Indexed contents not shown...
; VBE (RO) =#<VLA-OBJ ECT VBE 03404a04>
; Version (RO) ="15.0h (Hardware Lock)"
; Visible =-1
; Width =1032
; WindowLeft =-4
; WindowState =3
; WindowTop =-4
T
Do you see what I see? The Active Document Object is a Property of the Application Object. This means
that we can access it directly without having to retrieve it from the Documents Collection. Clever hey?
Still not convinced. OK, let's do it the long way around :
_$ (setq acadobject (vlax-get-Acad-Object))
#<VLA-OBJ ECT IAcadApplication 00adc088>
Again we've accessed the Application Object. Now let's get into the Documents Collection :
_$ (setq documentcollection (vla-get-documents acadobject))
#<VLA-OBJ ECT IAcadDocuments 01a03d30>
Now, we'll retrieve the Document Object for the drawing
_$ (setq thedocument (vla-item documentcollection 0))
#<VLA-OBJ ECT IAcadDocument 01a6f6a4>
And finally we retrieve the Layers Collection.
_$ (setq LayerTable (vla-get-layers thedocument))
#<VLA-OBJ ECT IAcadLayers 02fdca64>
But, what happens if we have two or more drawings open and we want to access the Layers Collection
of one of the other drawings?
Let's think about this. Where would the inactive documents (your other drawings) be stored?
I would say in the Documents Collection wouldn't you agree?
Let's try this out. First of all open two new drawings, Drawing1.dwg and Drawing2.dwg. Ensure that
Drawing1.dwg is the active drawing. Now type this at the Console prompt.
_$ (setq acadobject (vlax-get-Acad-Object))
#<VLA-OBJ ECT IAcadApplication 00adc088>
Again we've accessed the Application Object. Now let's get into the Documents Collection :
_$ (setq documentcollection (vla-get-documents acadobject))
#<VLA-OBJ ECT IAcadDocuments 01a03d30>
Now, we'll retrieve the Document Object for the specific inactive drawing
_$ (setq thedocument (vla-item documentcollection "Drawing2.dwg"))
#<VLA-OBJ ECT IAcadDocument 01a6f6a4>
And finally we retrieve the Layers Collection.
_$ (setq LayerTable (vla-get-layers thedocument))
#<VLA-OBJ ECT IAcadLayers 02fdca64>
Let's test this out. Let's change the current Layer in Drawing2.dwg to Layer 0. Ensure that Drawing1.dwg
is still the active drawing and enter this at the Console prompt :
_$ (vla-put-activelayer thedocument (vla-item LayerTable 0))
nil
Switch to Drawing2.dwg. Layer 0 should have become the current Layer.
To avoid confusing you any further by dealing with multiple workspaces, let's go back to just one active
drawing. Close all drawings and open a new drawing. Enter this at the Console prompt :
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (2 of 6) [23/03/2005 05:58:26 p.m.]
_$ (setq acadobject (vlax-get-Acad-Object))
#<VLA-OBJ ECT IAcadApplication 00adc088>
_$ (setq activedocument (vla-get-activedocument acadobject))
#<VLA-OBJ ECT IAcadDocument 01945554>
_$ (setq LayerTable (vla-get-layers activedocument))
#<VLA-OBJ ECT IAcadLayers 01a070bc>
No messing about this time! Straight to the Layers Collection.
Right, down to the nitty gritty. First create a Layer in your drawing named "TestLayer".
OK, now let's access "TestLayer" from the Layers Collection :
_$ (setq theLayer (vla-item LayerTable "TestLayer"))
#<VLA-OBJ ECT IAcadLayer 02fce56c>
Let's list the properties and methods of this Layer :
_$ (vlax-dump-object theLayer T)
; IAcadLayer: A logical grouping of data, similar to transparent acetate overlays on a drawing
; Property values:
; Application (RO) =#<VLA-OBJ ECT IAcadApplication 00adc088>
; Color =7
; Document (RO) =#<VLA-OBJ ECT IAcadDocument 01945554>
; Freeze =0
; Handle (RO) ="957"
; HasExtensionDictionary (RO) =0
; LayerOn =-1
; Linetype ="CONTINUOUS"
; Lineweight =-3
; Lock =0
; Name ="TestLayer"
; ObjectID (RO) =26864120
; ObjectName (RO) ="AcDbLayerTableRecord"
; OwnerID (RO) =26862608
; PlotStyleName ="Color_12"
; Plottable =-1
; ViewportDefault =0
; Methods supported:
; Delete ()
; GetExtensionDictionary ()
; GetXData (3)
; SetXData (2)
T
To create a new Layer, we simply add it to the Layers Collection :
_$ (setq aNewLayer (vla-add LayerTable "NewLayer"))
#<VLA-OBJ ECT IAcadLayer 02fce7bc>
You should have a new Layer in your drawing named "NewLayer".
But, our new Layer has been created with default colour and linetype values namely, 7 and Continuous.
Let's change them :
_$ (vla-put-color aNewLayer 2)
nil
Changes the colour of our Layer to 2 (yellow).
_$ (vla-put-linetype aNewLayer "Dashed2")
nil
Changes the linetype of our Layer to "Dashed2". "Dashed 2" of course, must be loaded within our
drawing.
Conversely, if you want to find the Colour and Linetype of a particular Layer you would do this :
_$ (vla-get-color aNewLayer)
2
_$ (vla-get-linetype aNewLayer)
"DASHED2"
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (3 of 6) [23/03/2005 05:58:26 p.m.]
Let's play around with our new Layer. First, change to any other Layer in your drawing.
OK, let's switch our Layer OFF and then back ON :
_$ (vla-put-layeron aNewLayer :vlax-false)
nil
_$ (vla-put-layeron aNewLayer :vlax-true)
nil
Next we'll FREEZE our Layer :
_$ (vla-put-freeze aNewLayer :vlax-true)
nil
And to THAW the Layer :
(vla-put-freeze aNewLayer :vlax-false)
nil
Right, now we'll LOCK it :
_$ (vla-put-Lock aNewLayer :vlax-true)
nil
And now UNLOCK the Layer :
_$ (vla-put-Lock aNewLayer :vlax-false)
nil
Should we now make the Layer UNPLOTTABLE?
_$ (vla-put-plottable aNewLayer :vlax-false)
nil
Now we'll make the Layer PLOTTABLE :
_$ (vla-put-plottable aNewLayer :vlax-true)
nil
Want to change the Layer's LINEWEIGHT? Let's change it to 0,35mm :
_$ (vla-put-LineWeight aNewLayer 35)
nil
Let's change the Lineweight back to DEFAULT :
_$ (vla-put-LineWeight aNewLayer -3)
nil
"ByLwDefault" = -3
"ByBlock" = -2
"ByLayer" = -1
Other Values are : 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200,
211.
In AutoCAD, make our new Layer the current Layer, and draw a line.
Now let's delete our new Layer :
_$ (vla-delete aNewLayer)
; error: Automation Error. Object is referenced by other object(s)
Oh, oh. We have an error. Think about it! How can we delete the Layer if it is being referenced by our
Line Object?
OK, Let's delete the Line and try again :
_$ (vla-delete aNewLayer)
; error: Automation Error. Object is referenced by other object(s)
What, still an error? That's because the Layer is current and is therefore referenced by the Document
Object.
Now make any other Layer current and try for a third time :
_$ (vla-delete aNewLayer)
nil
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (4 of 6) [23/03/2005 05:58:26 p.m.]
Hurray, success at last. The Layer is now an "Ex-Layer".
Here's a couple of Layer routines written using Visual Lisp that you may find useful.
Turn All Layers ON :
(defun C:Layeron ( / acadDocument theLayers)
(vl-load-com)
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-for item theLayers (vlax-put-property item "LayerOn" ':vlax-true) )
(princ)
);defun
(princ)
This routine will place a Prefix in front of all Layer names ;and rename them.
Of course, it will not rename Layer "0" or "Defpoints".
(prompt "\nType ChLayName to run.........")
(defun C:ChLayName ( / acadDocument theLayers layName pre)
(vl-load-com)
(setq pre (getstring "\nEnter Layer Prefix : "))
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(vlax-map-collection theLayers 'layer-mod)
(princ)
);defun
(defun layer-mod (theLayer)
(setq layName (vlax-get-property theLayer 'Name))
(if (not (member layName '("0" "Defpoints")))
(vla-put-Name thelayer (strcat pre layName))
) ;if
);defun
(princ)
Create a layer using Visual Lisp?
;;;Returns a layer object or nil
;;;on creation failure
(defun mLayer (LayerName)
(vl-load-com)
(setq LayerName
(vl-catch-all-apply
'vla-add
(list
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
Layername
)
)
)
(if (vl-catch-all-error-p LayerName)
nil
LayerName
)
)
This routine will return a list of all Layers in the active drawing :
(defun C:LayList ( / acadobject activedocument LayerTable thelist)
(vl-load-com)
(setq acadobject (vlax-get-Acad-Object))
(setq activedocument (vla-get-activedocument acadobject))
(setq LayerTable (vla-get-layers activedocument))
(vlax-for each LayerTable
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (5 of 6) [23/03/2005 05:58:26 p.m.]
(setq thelist (cons (vla-get-Name each) thelist))
)
(if thelist (reverse thelist))
);defun
(princ)

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Layers
http://www.afralisp.com/vl/layers.htm (6 of 6) [23/03/2005 05:58:26 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Sample Profile Utilities
Just a few Sample Profile Utilities.
Compliments of AutoDesk :
;;; DESCRIPTION:
;;; Sample profile manipulation utilities.
;;; All functions return T on success and nil
;;; on failure. See comments above each function
;;; for additional details.
;;;
;;; EXAMPLES:
;;;
;;; - Set active profile:
;;; (sample-profile-set-active "MyProfile")
;;;
;;; - Import a profile:
;;; (sample-profile-import
;;; "c:\\myExportedProfile.arg" "MyFavoriteProfile" T)
;;;
;;; - Delete a profile:
;;; (sample-profile-delete "unwanted")
;;;
;;;
;;; - Import a profile, even if it already exists, and set it active.
;;;
;;; (sample-profile-import "c:\\CompanyProfile.arg" "MyProfile" T)
;;; (sample-profile-set-active "MyProfile")
;;;
;;;
;;; - Import a profile, if not already present, and set it active
;;;
;;; (if (not (sample-profile-exists "myProfile"))
;;; (progn
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (1 of 8) [23/03/2005 05:58:27 p.m.]
;;; (sample-profile-import "c:\\CompanyProfile.arg" "MyProfile" T)
;;; (sample-profile-set-active "MyProfile")
;;; )
;;; )
;;;
;;;
;;; - Import a profile and set it active when AutoCAD is first started.
;;; Place the following code in acaddoc.lsp with the desired ".arg" filename
;;; and profile name...
;;;
;;; (defun s::startup ()
;;; (if (not (vl-bb-ref ':sample-imported-profile))
;;; ;;have we imported the profile yet?
;;; (progn
;;;
;;; ;; Set a variable on the bulletin-board
;;; ;; to indicate that we've been here before.
;;; (vl-bb-set ':sample-imported-profile T)
;;;
;;; ;; Import the profile and set it active
;;; (sample-profile-import
;;; "c:\\CompanyProfile.arg" "MyProfile" T)
;;; (sample-profile-set-active "MyProfile")
;;;
;;; );progn then
;;; );if
;;; );defun s::startup
;;;
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This helper function gets the profiles object.
;;
(defun sample-get-profiles-object ( / app pref profs )
(vl-load-com)
(and
(setq app (vlax-get-acad-object))
(setq pref (vla-get-preferences app))
(setq profs (vla-get-profiles pref))
)
profs
);defun sample-get-profiles-object
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (2 of 8) [23/03/2005 05:58:27 p.m.]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Determine if a profile exists.
;; Returns T if the specified profile name exists, and nil if not.
;;
(defun sample-profile-exists ( name / profs )
(and name
(setq names (sample-profile-names))
(member (strcase name) (mapcar 'strcase names))
)
);defun sample-profile-exists
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set the active profile.
;; NOTES:
;; - If the specified profile name is already active
;; then the function returns T and makes no additional
;; changes.
;;
;; - The specified profile must exist.
;; (You can import a profile using the 'sample-profile-import'
;; function.) If the specified profile does not exist, the
;; function returns nil.
;;
(defun sample-profile-set-Active ( name / profs )
(and
name
(setq profs (sample-get-profiles-object))
(or (equal (strcase name) (strcase (getvar "cprofile")))
(not (vl-catch-all-error-p (vl-catch-all-apply
'vla-put-activeProfile (list profs name))))
)
);and
);defun sample-profile-set-Active
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Delete the specified profile.
;; Fails if the specified profile is current.
;;
(defun sample-profile-delete ( name / profs )
(and
name
(setq profs (sample-get-profiles-object))
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (3 of 8) [23/03/2005 05:58:27 p.m.]
(not (vl-catch-all-error-p (vl-catch-all-apply
'vla-deleteprofile (list profs name))))
)
);defun sample-profile-delete

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Copy profile.
;;
(defun acad-pref-profile-copy ( source target / profs )
(and
source
target
(setq profs (sample-get-profiles-object))
(not (vl-catch-all-error-p (vl-catch-all-apply
'vla-CopyProfile (list profs source target))))
)
);defun sample-profile-copy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Get a list of profile names
;;
(defun sample-profile-names ( / profs result )
(and
(setq profs (sample-get-profiles-object))
(not (vl-catch-all-error-p (vl-catch-all-apply
'vla-GetAllProfileNames (list profs 'result))))
result
(setq result (vlax-safearray->list result))
)
result
);defun sample-profile-names
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Rename
;;
(defun sample-profile-rename ( oldName newName / profs )
(and
oldName
newName
(setq profs (sample-get-profiles-object))
(not (vl-catch-all-error-p (vl-catch-all-apply
'vla-RenameProfile (list profs oldName newName))))
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (4 of 8) [23/03/2005 05:58:27 p.m.]
)
);defun sample-profile-rename
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Get a unique profile name.
;; This function returns a unique profile name
;; that is guaranteed to not be present in the current
;; list of profiles.
;;
(defun sample-get-unique-profile-name ( / names n name )
(setq names (sample-profile-names)
names (mapcar 'strcase names)
name "TempProfileName"
n 1
)
(while (member (strcase (setq name (strcat name (itoa n)))) names)
(setq n (+ n 1))
)
name
);defun sample-get-unique-profile-name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Import
;; This function imports the specified .arg file and creates
;; a new profile with the provided profile name.
;; If the specified profile already exists, it will be overwritten.
;; If the 'bUsePathInfo' parameter is non-nil then path information
;; will be imported from the specified
;; file. Otherwise, path information will be ignored.
;;
;; NOTES:
;; This function does not set the active profile.
;; If you import a new profile it will not become active
;; unless it matches the name of the existing active profile.
;;
;; You can set the active profile by calling:
;; (sample-profile-set-active "ProfileName")
;;
(defun sample-profile-import ( filename profileName bUsePathInfo /
sample-old Error profs isCProfile
tempProfile result )
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (5 of 8) [23/03/2005 05:58:27 p.m.]
;; Set up an error handler so, if something goes wrong,
;;we can put things back the way we found them
(setq sample-oldError *error*)
(defun *error* ( msg / )
(if (and profileName
tempProfile
(equal tempProfile (getvar "cprofile"))
)
(progn
;; Something went wrong so put things back the way they were.
(sample-profile-rename tempProfile profileName)
(sample-profile-set-active profileName)
(sample-profile-delete tempProfile)
);progn then
);if
(setq *error* sample-oldError)
(if msg
(*error* msg)
(princ)
)
);defun *error*
(if (and bUsePathInfo
(not (equal :vlax-false bUsePathInfo))
)
(setq bUsePathInfo :vlax-true)
(setq bUsePathInfo :vlax-false)
)
(if (and filename
(setq filename (findfile filename))
profileName
(setq profs (sample-get-profiles-object))
);and
(progn
;; We can't import directly to the current profile,
;; so if the provided profile name matches
;; the current profile, we'll need to:
;; - rename the current profile to a unique name
;; - import
;; - set the new one current
;; - delete the old one with the temp name
(setq isCProfile (equal (strcase (getvar "cprofile"))
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (6 of 8) [23/03/2005 05:58:28 p.m.]
(strcase profileName)))
(if isCProfile
(progn
(setq tempProfile (sample-get-unique-profile-name))
(sample-profile-rename (getvar "cprofile") tempProfile)
);progn then
);if
;; Import
(setq result (not (vl-catch-all-error-p (vl-catch-all-apply
'vla-ImportProfile (list profs profileName
filename bUsePathInfo)))))
(if isCProfile
(progn
;; Handle current profile case...
;; If the import was successful,
;;then set the new profile active and delete the original
;; else if something went wrong, then put the old profile back
(if (and result
(setq result (sample-profile-set-Active profileName))
;; set the newly imported profile active
);and
(sample-profile-delete tempProfile)
;; then delete the old profile
(sample-profile-rename tempProfile profileName)
;; else rename the original profile back to its old name
);if
);progn then
);if
);progn then
);if
(*error* nil) ;; quietly restore the original error handler
result
);defun sample-profile-import
(princ)

Sample Profile Utilities


http://www.afralisp.com/vl/profile-samples.htm (7 of 8) [23/03/2005 05:58:28 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Sample Profile Utilities
http://www.afralisp.com/vl/profile-samples.htm (8 of 8) [23/03/2005 05:58:28 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and Attributes
You can find the VBA equivalent to this application here.
And the AutoLisp version here.
When you want to edit attributes in AutoCAD most of us use the "Attedit" command.
Firstly, we must select the attribute we would like to edit. Then the "Edit Attribute"
dialogue box appears which allows us to add or change the values of our attribute.
Personally, I think this dialogue leaves a lot to be desired. You cannot customise it in any
way, and it displays all attributes whether you want them or not. As well, if you have a lot
of attributes you need to page your way through numerous dialogues before reaching the
attribute you want to edit.
In this tutorial we are going to have a look at extracting attribute data from a block,
displaying the data in a custom dialogue box, and then updating the attribute data on
exit.
Right, what do we need to do?
1. Find the block containing the attribute data. (Why select it when we can get AutoCAD
to find it for us.)
2. Extract the attribute data and display it in a dialogue box.
3. Allow the user to change the data if he so wishes.
4. Update the attribute data with the new information entered into the dialogue box.
O.K. fire up AutoCAD and open the drawing Attab-vl.dwg.
Alright, I admit that it's not much of a title block, but it's enough to give you the general
idea.
Now, at the command prompt type (load "Addat-vl") and then enter.
Now, type "Addat-vl" and press enter again.
This dialogue should appear :
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (1 of 6) [23/03/2005 05:58:29 p.m.]
Change some of the data and then press the "OK" button.
The title block data should be updated. Clever hey?
You can expand on this routine as much as you like using the following coding as a
template.
Hint : You don't have to display all the attribute data stored in a block. Only display what
you want the user to modify. As well, you can split your data over multiple dialogue
boxes. eg. One for title block, one for revisions, one for reference drawings, etc. All the
data though is contained in one attribute.
Here's the coding, DCL code first :
attabvl : dialog {
label = "Drawing Title Block";
: edit_box {
label = "&Drawing Number";
key = "eb1";
edit_width = 30;
}
: edit_box {
label = "&Revision";
key = "eb2";
edit_width = 30;
}
: edit_box {
label = "Drawn &By";
key = "eb3";
edit_width = 30;
}
: edit_box {
label = "D&ate";
key = "eb4";
edit_width = 30;
}
: edit_box {
label = "&Title";
key = "eb5";
edit_width = 30;
}
ok_cancel ;
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (2 of 6) [23/03/2005 05:58:29 p.m.]
:text_part {
label = "AfraLisp - http://www.afralisp.com";
}

}
And now the Visual Lisp coding with plenty of in-line comments to assist you:
;CODING STARTS HERE
;
;All Tutorials and Code are provided "as-is" for purposes of instruction and
;utility and may be used by anyone for any purpose entirely at their own risk.
;Please respect the intellectual rights of others.
;All material provided here is unsupported and without warranty of any kind.
;No responsibility will be taken for any direct or indirect consequences
;resulting from or associated with the use of these Tutorials or Code.
;*******************************************************************************
; AfraLisp
; http://www.afralisp.com
; afralisp@afralisp.com
; afralisp@mweb.com.na
;*******************************************************************************
;This application will extract attributes from a block and display them in a
;dialog box. The attributes will then be updated.
;
;Dependencies : Attab-vl.dcl and Attab-vl.dwg are
;required and must be within the AutoCAD search path.
;
;Usage : Open Attab-vl.dwg then load and run Attab-vl.lsp.
;*******************************************************************************
(prompt "\nATTAB-VL Loaded....Type ATTAB-VL to run.....")
(defun c:attab-vl (/)
;load visual lisp extensions
(vl-load-com)
;retrieve reference to the active document
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
;retrieve reference to the selection set collection
(setq ssets (vla-get-selectionsets acadDocument))
;check if the selection set exists - $Set
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list ssets "$Set")))
;if it doesn't create a new one
(setq newsset (vla-add ssets "$Set"))

;if it does exist


(progn
;delete it
(vla-delete (vla-item ssets "$Set"))

;then create a new one


(setq newsset (vla-add ssets "$Set"))

);progn
);if
;create a single element array - integer
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 0)))
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (3 of 6) [23/03/2005 05:58:29 p.m.]
;create a single element array - variant
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 0)))
;filter for name - code 2
(vlax-safearray-fill filter_code '(2))
;filter for block name - attab-info
(vlax-safearray-fill filter_value '("attab-info"))
;filter the drawing for the block
(vla-select newsset acSelectionSetAll nil nil filter_code filter_value)
;if the block is found
(if (>= (vla-get-count newsset) 1)
;display the dialog
(ddisplay)
;if the block is not found
(alert
"\nIncorrect Drawing Sheet
\n Use Manual Edit"
)
);if
;finish clean
(princ)
);defun
;;;**********************************************************
(defun ddisplay (/)
;load the dialog
(setq dcl_id (load_dialog "attab-vl.dcl"))
;check it exists
(if (not (new_dialog "attabvl" dcl_id))
(exit)
);if
;retrieve the block reference
(setq item (vla-item newsset 0))
;retrieve the attributes
(setq theatts (vla-getattributes item))
;convert to a list
(setq attlist (vlax-safearray->list (variant-value theatts)))
;extract the attributes
(mapcar 'set '(theattribute1 theattribute2 theattribute3 theattribute4 theattribute5) attlist)
;extract the text strings from the attributes
(setq eb1 (vla-get-textstring theattribute1)
eb2 (vla-get-textstring theattribute2)
eb3 (vla-get-textstring theattribute3)
eb4 (vla-get-textstring theattribute4)
eb5 (vla-get-textstring theattribute5)
);setq
;put the info into the dialog
(set_tile "eb1" eb1)
(set_tile "eb2" eb2)
(set_tile "eb3" eb3)
(set_tile "eb4" eb4)
(set_tile "eb5" eb5)
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (4 of 6) [23/03/2005 05:58:29 p.m.]
;set the focus to the drawing number
(mode_tile "eb1" 2)
;if cancel selected exit
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
;if OK selected, retrieve the tile values
(action_tile
"accept"
(strcat
"(progn (setq eb1a (get_tile \"eb1\"))"
"(setq eb2a (get_tile \"eb2\"))"
"(setq eb3a (get_tile \"eb3\"))"
"(setq eb4a (get_tile \"eb4\"))"
"(setq eb5a (get_tile \"eb5\"))"
" (done_dialog)(setq userclick T))"
)
)
;start the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;if OK was selected
(if userclick
;do the following
(progn
;update the attribute textstrings
(vla-put-textstring theattribute1 eb1a)
(vla-put-textstring theattribute2 eb2a)
(vla-put-textstring theattribute3 eb3a)
(vla-put-textstring theattribute4 eb4a)
(vla-put-textstring theattribute5 eb5a)
;update the block
(vla-update newsset)
;regen the drawing
(command "REGEN")
);progn
);if
);defun
;;;***********************************************************
;load clean
(princ)
;;;**********************************************************
;
;CODING ENDS HERE
Please note that there is no error checking in this routine and I have left all variables as
global to assist you in checking their values whilst you are analyzing the code.
If you are too lazy to type, and don't know how to copy and paste, you can download the
coding and sample drawing by very gently placing your cursor here and clicking once.
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (5 of 6) [23/03/2005 05:58:29 p.m.]
"Hey, not so hard!!!!"

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Attributes
http://www.afralisp.com/vl/attab-vl.htm (6 of 6) [23/03/2005 05:58:29 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Loading VBA Files
There are two AutoCAD functions that can you would use to Load and Run VBA Applications namely,
VBALOAD and VBARUN. In a menu file you would use them like this :
[Test]^C^C^C^P-vbaload test.dvb -vbarun Module1.MyTest
Or, in an AutoLisp routine, you would write something like this :
(command "vbaload" "test.dvb")
(command "-vbarun" "Module1.MyTest")
The VBALOAD function has one serious flaw though!
If a VBA application is already loaded, and you run VBALOAD again, you get an error message. Try it
out :
Command: -vbaload
Initializing VBA System...
Open VBA Project: test.dvb
Now try and load it again.
Command: -vbaload
Open VBA Project: test.dvb
You should get an error message :
"File already loaded d:/drawings/test.dvb"
This is where Visual Lisp come into play.
The function (VL-VBALOAD) behaves much like the command VBALOAD. You need to supply the file
name of a project or DVB file. The complete file name should be provided along with the path and DVB
extension. For example, if you want to load a project named MyProject.dvb in the C:\MyWork\ folder, the
(VL-VBALOAD) function call would appear as follows.
(VL-VBALOAD "C:/MyWork/MyProject.DVB")
You should note a couple of things right away. Visual LISP makes use of forward slashes when
separating folder or directory names. Also, the parentheses are required and the extension DVB is
needed for the project to be properly located.
Unlike the VBALOAD command, this function will not generate an error if the project has already been
loaded into the current drawing environment. Thus, programs can proceed smoothly by just calling the
load function and then calling the run function without concern about the project already being loaded.
Another interesting feature is that the Enable Macros/Virus Warning message does not appear when
you use the Visual LISP approach.
Therefore, your menu macro :
[Test]^C^C^C^P-vbaload test.dvb -vbarun MyTest
can be replaced with the following one:
[Test]^C^C^C^P(vl-vbaload "test.dvb")(vl-vbarun "MyTest")
And of course, your AutoLisp coding should be replaced with this :
(vl-vbaload "test.dvb")
(vl-vbarun "MyTest")
Here's a little function that you could load at startup to help you locate, load and run VBA files:
;CODING START HERE
Visual Lisp and Loading VBA Files.
http://www.afralisp.com/vl/vl-vba.htm (1 of 4) [23/03/2005 05:58:31 p.m.]
(defun VBA-LOADIT (ProjName Macro)
(if (findfile ProjName)
(progn
(vl-vbaload ProjName)
(vl-vbarun Macro)
);progn
);if
(princ)
);defun
(princ)
;CODING ENDS HERE
Syntax : (vbaloadit "dvb-file" "macro")
Example : (vbaloadit "test.dvb" "MyTest")
You must keep some other considerations in mind when using (VL-VBALOAD) and (VL-VBARUN). For
example, after you invoke the (VL-VBARUN) function, the Visual LISP function will continue to run and
can (will) interfere with the VBA interface if you try to do too much. On the other hand, there are some
distinct advantages to using the Visual LISP approach to loading and launching VBA macros instead of
the command-line versions when programming a menu- or toolbar-based interface.
One thing to note is that the VBARUN is not a subroutine. That is, program execution will not be handed
to the VBA macro and the Visual LISP routine suspended as if it were running a function. Instead, the
Visual LISP function will continue to run as the VBA macro starts. The best thing to do is simply finish
the Visual LISP function as quickly as possible and let the VBA macro run the command interface from
that point forward. If you want to return to a Visual LISP function after running the VBA code, then use
the SendCommand method attached to the Document object in VBA. When you are ready to hand
control back to Visual LISP, call the function directly (remember to wrap parentheses around the
command start up for direct launches of Visual LISP functions). When you use this approach, the VBA
program should end and allow the Visual LISP function to proceed without interference. Similar to
starting the VBA macro in the first place, when you send commands to the AutoCAD document from
VBA, they will be run along with the VBA and sometimes this can result in confusion at the user level as
the two try to take turns. Note that you can pass parameters from VBA to the Visual LISP function by
sending them as part of the command stream. They will need to be converted to strings first, then sent
to the Visual LISP function as part of the function start up from the Send Command method.
NOTE : Sorry, but due to additions to the Object Model, this next section will only work in
AutoCAD 2002 :-(
Want to know what Projects are loaded in your drawing?
Type this at the console prompt :
_$ (vl-load-com)
_$ (setq oApp (vlax-get-acad-object))
#<VLA-OBJ ECT IAcadApplication 00ac8928>
_$ (setq oVbe (vlax-get oapp "VBE"))
#<VLA-OBJ ECT VBE 020b9c18>
_$ (vlax-dump-object oVBE T)
; VBE: nil
; Property values:
; ActiveCodePane =nil
; ActiveVBProject =#<VLA-OBJ ECT _VBProject 020ba620>
; ActiveWindow (RO) =nil
; CodePanes (RO) =#<VLA-OBJ ECT _CodePanes 00b1c2e0>
; CommandBars (RO) =#<VLA-OBJ ECT _CommandBars 030b2a24>
Visual Lisp and Loading VBA Files.
http://www.afralisp.com/vl/vl-vba.htm (2 of 4) [23/03/2005 05:58:31 p.m.]
; Events (RO) =#<VLA-OBJ ECT Events 020b9c94>
; MainWindow (RO) =#<VLA-OBJ ECT Window 020b8ce8>
; SelectedVBComponent (RO) =#<VLA-OBJ ECT _VBComponent 020ba748>
; VBProjects (RO) =#<VLA-OBJ ECT _VBProjects 020b9c4c>
; Version (RO) ="5.00"
; Windows (RO) =#<VLA-OBJ ECT _Windows 020b9d18>
; No methods
T
I presume you can see what I see? A "VBProjects" property.
Now that's interesting! But how do we extract the loaded Projects?
Load and run this small routine.
;CODING STARTS HERE
(defun Gvba ( /oApp oVBE oProjs N Nams oProj)
(vl-load-com) ;requires automation links
(if (and
;Drill down to the Projects object
(setq oApp (vlax-get-acad-object))
(setq oVBE (vla-get-vbe oApp))
(setq oProjs (vlax-get oVBE "VBProjects"))
)
;Loop through Projects object
(repeat (setq N (vla-get-count oProjs))
;get the item at position N
(setq oProj (vla-item oProjs N)
;get the name property,
;add it to the list.
Nams (cons
(list
(vlax-get oProj "Name")
(vlax-get oProj "FileName")
) Nams) N (1- N)))
)
; return list of names
Nams
);defun
;CODING ENDS HERE
You should have a list of Projects in the variable "Nams".
And, would you like to Unload all Projects within your drawing? Try this :
;CODING STARTS HERE
(defun C:UNLOADALLVBA ( / VBAProjs VBAProj)
(setq VBAProjs (Gvba))
(foreach VBAProj VBAProjs
(command "_VBAUNLOAD" (cadr VBAProj)))
)
;CODING ENDS HERE

Visual Lisp and Loading VBA Files.


http://www.afralisp.com/vl/vl-vba.htm (3 of 4) [23/03/2005 05:58:31 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and Loading VBA Files.
http://www.afralisp.com/vl/vl-vba.htm (4 of 4) [23/03/2005 05:58:31 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp - Directories and Files - Page I
Using plain old AutoLisp, we really only have two functions dealing with files and directories namely,
the (findfile) function, and the (getfiled) function. Both of these functions are useful but limited in there
scope.
Visual Lisp has introduced a whole host of new functions specifically designed to use with files and
directories. In this tutorial we're going to have a look at a few of them. Firstly, we'll have a look at
probably the most powerful Visual Lisp function for dealing with files and directories, the
(vl-directory-files) function. Fire up AutoCAD, open the Visual Lisp Editor, then type this at the console
prompt :
_$ (vl-load-com)
_$ (vl-directory-files)
("." ".." "X3426.dwg" "addshort.dvb" "ADMENU.DVB" "afralispURL.dvb" "afraLOGO.dwg"
"another-dump.lsp" "area.zip" "arrowkeyview.dvb" "ATTAB.DCL" "ATTAB.DWG" "ATTAB.LSP")
This will return a list containing every file and sub-directory within your current directory.
Let's have a look at the syntax of (vl-directory-files) and a few other Visual Lisp File/Directory functions.
VL-DIRECTORY-FILES
Lists all files in a given directory
(vl-directory-files [directory pattern directories])
Arguments :
directory
A string naming the directory to collect files for; if nil or absent, vl-directory-files uses the current
directory.
G
pattern
A string containing a DOS pattern for the file name; if nil or absent, vl-directory-files assumes
"*.*"
G
directories
An integer that indicates whether the returned list should include directory names. Specify one of
the following :
-1 List directories only.
0 List files and directories (the default).
1 List files only.
G
Return Values
A list of file and path names, or nil, if no files match the specified pattern. G
Let's try it again, but this time with some arguments. Type this at the console prompt :
_$ (vl-directory-files "d:/drawings" "*.dwg")
("X3426.dwg" "afraLOGO.dwg" "ATTAB.DWG" "Drawing1.dwg" "Drawing4.dwg" "is handsome.dwg"
"tem5.dwg" "X3374.dwg" "X3375.dwg" "dwgdata.dwg" "Drawing2.dwg" "X3359.dwg" "tblock.dwg"
"kenny.dwg" "Adaptor.dwg" "Drg-1.dwg" "drg-2.dwg" "attab-vl.dwg" "matlist.dwg")
This will return a list of all drawings residing in the directory "d:/drawings".
Let's try something else :
_$ (vl-directory-files "d:/drawings" "*.lsp")
("another-dump.lsp" "ATTAB.LSP" "BAREA.LSP" "bick.lsp" "acad.lsp" "mted.lsp" "circle-react.lsp"
"clay.lsp" "DC-Delete.lsp" "endPlot.lsp")
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (1 of 6) [23/03/2005 05:58:33 p.m.]
This, of course, will return a list of all AutoLisp files.
Now let's get clever. Let's try and get a list of just the subdirectories :
_$ (vl-directory-files "d:/drawings1" nil -1)
("." ".." "Purge-Export" "Office" "3D" "Extext" "VBA" "DrawingExfiles")
Easy hey. Now let's have a look at some of the other Visual Lisp file handling functions.
VL-FILE-COPY
Copies or appends the contents of one file to another file
(vl-file-copy source-file destination-file [append])
Copy or append the contents of one file to another file. The vl-file-copy function will not overwrite an
existing file, only append to it.
Arguments :
source-file
A string naming the file to be copied. If you do not specify a full path name, vl-file-copy looks in
the AutoCAD start-up directory.
G
destination-file
A string naming the destination file. If you do not specify a path name, vl-file-copy writes to the
AutoCAD start-up directory.
G
append
If specified and not nil, source-file is appended to destination-file (that is, copied to the end of the
destination file).
G
Return Values
An integer, if the copy was successful, otherwise nil.
Some typical reasons for returning nil are:
source-file is not readable
source-file is a directory
append? is absent or nil and destination-file exists
destination-file cannot be opened for output (that is, it is an illegal file name or a write-protected
file)
source-file is the same as destination-file
G
Examples
Copy autoexec.bat to newauto.bat:
_$ (vl-file-copy "c:/autoexec.bat" "c:/newauto.bat")
1417
Copy test.bat to newauto.bat:
_$ (vl-file-copy "c:/test.bat" "c:/newauto.bat")
nil
The copy fails because newauto.bat already exists, and the append argument was not specified.
Repeat the previous command, but specify append:
_$ (vl-file-copy "c:/test.bat" "c:/newauto.bat" T)
185
The copy is successful because T was specified for the append argument.
VL-FILE-DELETE
Deletes a file
(vl-file-delete filename)
Arguments :
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (2 of 6) [23/03/2005 05:58:33 p.m.]
filename
A string containing the name of the file to be deleted. If you do not specify a full path name,
vl-file-delete searches the AutoCAD start-up directory.
G
Return Values
T, if successful, nil if delete failed. G
Examples
Delete newauto.bat:
_$ (vl-file-delete "newauto.bat")
nil
Nothing was deleted because there is no newauto.bat file in the AutoCAD start-up directory.
Delete the newauto.bat file in the c:\ directory:
_$ (vl-file-delete "c:/newauto.bat")
T
The delete was successful because the full path name identified an existing file.
VL-FILE-DIRECTORY-P
Determines if a file name refers to a directory
(vl-file-directory-p filename)
Arguments :
filename
A string containing a file name. If you do not specify a full path name, vl-file-directory-p searches
only the AutoCAD start-up directory.
G
Return Values
T, if filename is the name of a directory, nil if it is not. G
Examples
_$ (vl-file-directory-p "sample")
T
_$ (vl-file-directory-p "yinyang")
nil
_$ (vl-file-directory-p "c:/program files/acad2000")
T
_$ (vl-file-directory-p "c:/program files/acad2000/vlisp/yinyang.lsp")
nil
VL-FILE-RENAME
Renames a file
(vl-file-rename old-filename new-filename)
Arguments :
old-filename
A string containing the name of the file you want to rename. If you do not specify a full path name,
vl-file-rename looks in the AutoCAD start-up directory.
G
new-filename
A string containing the new name to be assigned to the file.
NOTE If you do not specify a path name, vl-file-rename writes the renamed file to the AutoCAD
start-up directory.
G
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (3 of 6) [23/03/2005 05:58:33 p.m.]
Return Values
T, if renaming completed successfully, nil if renaming failed. G
Examples
_$ (vl-file-rename "c:/newauto.bat" "c:/myauto.bat")
T
VL-FILE-SYSTIME
Returns last modification time of the specified file
(vl-file-systime filename)
Arguments :
filename
A string containing the name of the file to be checked. G
Return Values
A list containing the modification date and time, or nil, if the file is not found.
The list returned contains the following elements :
year
month
day-of-week
day-of-month
hours
minutes
seconds
G
Note that Monday is day 1 of day-of-week, Tuesday is day 2, etc.
Examples
_$ (vl-file-systime "c:/program files/acad2000/sample/visuallisp/yinyang.lsp")
(1998 4 3 8 10 6 52 0)
The returned value shows that the file was last modified in 1998, in the 4th month of the year (April), the
3rd day of the week (Wednesday), on the 10th day of the month, at 6:52:0.
VL-FILENAME-BASE
Returns the name of a file, after stripping out the directory path and extension
(vl-filename-base filename)
Arguments :
filename
A string containing a file name. The vl-filename-base function does not check to see if the file
exists.
G
Return Values
A string containing filename in uppercase, with any directory and extension stripped from the
name.
G
Examples
_$ (vl-filename-base "c:\\acadwin\\acad.exe")
"ACAD"
_$ (vl-filename-base "c:\\acadwin")
"ACADWIN"
VL-FILENAME-DIRECTORY
Returns the directory path of a file, after stripping out the name and extension
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (4 of 6) [23/03/2005 05:58:33 p.m.]
(vl-filename-directory filename)
Arguments :
filename
A string containing a complete file name, including the path. The vl-filename-directory function
does not check to see if the specified file exists. Slashes (/) and backslashes (\) are accepted as
directory delimiters.
G
Return Values
A string containing the directory portion of filename, in uppercase. G
Examples
_$ (vl-filename-directory "c:\\acadwin\\acad.exe")
"C:\\ACADWIN"
_$ (vl-filename-directory "acad.exe")
""
VL-FILENAME-EXTENSION
Returns the extension from a file name, after stripping out the rest of the name

(vl-filename-extension filename)
Arguments :
filename
A string containing a file name, including the extension. The vl-filename-extension function does
not check to see if the specified file exists.
G
Return Values
A string containing the extension of filename. The returned string starts with a period (.) and is in
uppercase. If filename does not contain an extension, vl-filename-extension returns nil.
G
Examples
_$ (vl-filename-extension "c:\\acadwin\\acad.exe")
".EXE"
_$ (vl-filename-extension "c:\\acadwin\\acad")
nil
VL-FILENAME-MAKETEMP
Calculates a unique file name to be used for a temporary file
(vl-filename-mktemp [pattern directory extension])
Arguments :
pattern
A string containing a file name pattern; if nil or absent, vl-filename-mktemp uses "$VL~~". G
directory
A string naming the directory for temporary files; if nil or absent, vl-filename-mktemp chooses a
directory in the following order:
The directory specified in pattern, if any.
The directory specified in the TMP environment variable.
The directory specified in the TEMP environment variable.
The current directory.
G
extension
A string naming the extension to be assigned to the file; if nil or absent, vl-filename-mktemp uses
the extension part of pattern (which may be an empty string).
G
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (5 of 6) [23/03/2005 05:58:33 p.m.]
Return Values
A string containing a file name, in the following format :
directory\base<XXX><.extension>
where:
base is up to 5 characters, taken from pattern
XXX is a 3 character unique combination
All file names generated by vl-filename-mktemp during a VLISP session are deleted when you exit
VLISP.
G
Examples
_$ (vl-filename-mktemp)
"C:\\TMP\\$VL~~004"
_$ (vl-filename-mktemp "myapp.del")
"C:\\TMP\\MYAPP005.DEL"
_$ (vl-filename-mktemp "c:\\acadwin\\myapp.del")
"C:\\ACADWIN\\MYAPP006.DEL"
_$ (vl-filename-mktemp "c:\\acadwin\\myapp.del")
"C:\\ACADWIN\\MYAPP007.DEL"
_$ (vl-filename-mktemp "myapp" "c:\\acadwin")
"C:\\ACADWIN\\MYAPP008"
_$ (vl-filename-mktemp "myapp" "c:\\acadwin" ".del")
"C:\\ACADWIN\\MYAPP00A.DEL"
OK, enough of this theoretical nonsense! Let's do something practical.
How do you fancy creating your own personalised file list box?
You do? Great! I'll see you in Part II.
Page I Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp - Directories and Files - Page I.
http://www.afralisp.com/vl/vl-dir.htm (6 of 6) [23/03/2005 05:58:33 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp - Directories and Files - Page II
Right, are you ready to create your own file list box? OK here we go. First I'll give you a wee peek at
what our dialog will look like :
Looks good hey!
To run this function you must pass it two arguments :
A string containing a directory path. G
A list of file types. G
Syntax : (fileselect [directory file_ types])
Example : (fileselect "d:/drawings" '("*.dwg" "*.lsp" "*.dvb"))
Return : A list of selected files.
Oh, by the way, you CAN select multiple files.
The first thing we need to do is write a bit of DCL to create our File Dialog. Copy and paste this into
Notepad and save it as "AfraFiles.dcl".
FILES : dialog {
label="AfraLisp File Dialog";

: text {
key="CDIR";
}
: row {
: list_box {
key="DIR";
label="Select Directory :";
width=25;
fixed_width_font = true;
}
Visual Lisp - Directories and Files - Page II.
http://www.afralisp.com/vl/vl-dir1.htm (1 of 5) [23/03/2005 05:58:36 p.m.]
: list_box {
key="FIL";
label="Select Files :";
width = 30;
tabs = "20 31 40";
multiple_select = true;
fixed_width_font = true;
}
}
: row {
: text {
key="DIRS";
}
: text {
key="FILS";
}
}
: popup_list {
key="EXT";
label="Select File Type :";
fixed_width_font = true;
}
ok_cancel;
}
And now the AutoLisp Coding. Save this as AfraFile.lsp :

;CODING STARTS HERE


;;Syntax : (fileselect "d:/drawings" '("*.dwg" "*.lsp" "*.dvb"))
(defun FileSelect (Dir Pat)
(setq DH (load_dialog "afrafiles"))
(if (and DH (new_dialog "FILES" DH))
(progn
(setq iExt 0)
(Refresh_Display)
(start_list "EXT")
(mapcar 'add_list Pat)
(end_list)
;
(action_tile "DIR" "(new_dir $value)")
(action_tile "EXT" "(new_mask $value)")
(action_tile "FIL" "(picked $value)")
;
(if (= (start_dialog) 0)
(setq File_List nil)
)
(unload_dialog DH)
)
)
File_List
)
;------------------------------------------------
(defun Refresh_Display ()
(start_list "FIL")
(end_list)
(set_tile "CDIR" "Working...")
(setq FL (VL-Directory-Files
;Dir Pat 1)
Dir (nth iExt Pat) 1)
DR (VL-Directory-Files
Dir nil -1)
Visual Lisp - Directories and Files - Page II.
http://www.afralisp.com/vl/vl-dir1.htm (2 of 5) [23/03/2005 05:58:36 p.m.]
FL (VL-Sort FL 'str_compare)
DR (VL-Sort DR 'str_compare)
)
(start_list "DIR")
(mapcar 'add_list DR)
(end_list)
(start_list "FIL")
(if Show_the_details
(mapcar
'(lambda (F)
(setq Dt (VL-File-SysTime
(strcat Dir F))
F1 (if Dt
(strcat
F
"\t"
(itoa_f (nth 1 Dt) 2)
"/"
(itoa_f (nth 3 Dt) 2)
"/"
(itoa_f (nth 0 Dt) 4)
"\t"
(itoa_f (nth 4 Dt) 2)
":"
(itoa_f (nth 5 Dt) 2)
":"
(itoa_f (nth 6 Dt) 2)
)
(strcat F "\t\t")
)
Sz (VL-File-Size (strcat Dir F))
F1 (strcat
F1
"\t"
(rtos Sz 2 0))
)
(add_list F1))
FL)
(mapcar 'add_list FL)
)
(end_list)
(set_tile "DIRS"
(strcat
"Directories = "
(itoa (length DR))))
(set_tile "FILS"
(strcat
"Files = "
(itoa (length FL))))
(set_tile "CDIR" Dir)
)
(defun New_Dir (Pth)
(setq Pth (nth (atoi Pth) DR))
(cond
((= Pth ".")
nil
)
((= Pth "..") ;;back up a directory
;;remove directory name up one
(setq L (1- (strlen Dir))
Dir (substr Dir 1 L)
)
(while (/= (substr Dir L 1) "/")
(setq L (1- L)))
(setq Dir (substr Dir 1 L))
)
('T
(setq Dir (strcat Dir Pth "/"))
)
)
(Refresh_Display)
Visual Lisp - Directories and Files - Page II.
http://www.afralisp.com/vl/vl-dir1.htm (3 of 5) [23/03/2005 05:58:36 p.m.]
)
;------------------------------------------------
;; Call back function to handle new file mask
;; selection by the user.
;;
(defun New_Mask (II)
(setq iExt (atoi II))
(Refresh_Display)
)
;
;------------------------------------------------
;; Call back function for saving the selected
;; file list in the variable FILE_LIST.
;;
(defun Picked (val / V)
(setq val (read (strcat "(" Val ")"))
File_List
(mapcar '(lambda (V)
(strcat
Dir
(nth V FL)))
Val)
)
)
;;-----------------------------------------------
;; Convert integer to padded ASCII string
;;
(defun Itoa_F (I Digs)
(setq I (itoa I))
(while (< (strlen I) Digs)
(setq I (strcat "0" I)))
I
)
;;-----------------------------------------------
(defun Str_Compare (T1 T2)
(< (strcase T1)
(strcase T2)))
(princ)
;;-----------------------------------------------
;CODING ENDS HERE
I just like to thank Bill Kramer from whom I "stole" a lot of this coding from.
(Shush, don't say anything as he doesn't know yet!!!)
I can just hear you now. "But Kenny, why do we have to copy and paste the coding? Can't you give us a
nice little Zip file to download like you normally do?"
Oh all right then, just click here. Now please stop whining!!!

Page I Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Visual Lisp - Directories and Files - Page II.
http://www.afralisp.com/vl/vl-dir1.htm (4 of 5) [23/03/2005 05:58:36 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp - Directories and Files - Page II.
http://www.afralisp.com/vl/vl-dir1.htm (5 of 5) [23/03/2005 05:58:36 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Compiling AutoLisp Files - Page I
Before we start with various methods of compiling AutoLisp files, let's have a look at the different file
types we'll encounter during this Tutorial :
lsp AutoLisp Program Source file G
dcl Contains definitions of AutoCAD Dialog Boxes G
fas Compiled AutoLisp Program G
vlx Executable Visual Lisp Module G
prv Defines the files and options used to build a vlx module G
Each time you load AutoLISP source code, the code is translated into instructions the computer
understands (executable code). The advantage of having source code translated each time you load it is
that you can make a change and immediately try it out. This is useful for quickly testing new code, and
for debugging that code.
Once you are sure your program is working correctly, translating AutoLISP source code each time it
loads is time-consuming. VLISP provides a compiler that generates executable machine code files from
your source files. These executable files are known as FAS files. Because the executable files contain
only machine-readable code, the source code you spent weeks or months developing remains hidden
even if you distribute your program to thousands of users. Even strings and symbol names are
encrypted by the VLISP file compiler.
VLISP also provides features for packaging more complex AutoLISP applications into VLISP executable
(VLX) files. VLX files can include additional resources files, such as VBA, DCL and TXT files, as well as
compiled AutoLISP code.
So, let's try and give you a digest of what we've just discussed :
If you have a single AutoLisp file, compile it as a fas file. G
If you have an AutoLisp file with dependencies such as DCL or TXT files, compile it as an
Executable Visual Lisp Module vlx file.
G
Let's start off this Tutorial by compiling a single AutoLisp file.
Copy and paste this into Notepad and save it as "Slot.lsp" :
(defun C:SLOT (/ oldsnap diam lngth pt1 pt2 pt3 pt4 pt5 pt6)
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq oldsnap (getvar "OSMODE"))
(setq diam (getdist "\nSlot Diameter : ")
lngth (getdist "\nSlot Length : "))
(while
(setq pt1 (getpoint "\nInsertion point: "))
(setvar "OSMODE" 0)
(setq pt2 (polar pt1 0.0 (/ (- lngth diam) 2.0))
pt3 (polar pt2 (/ pi 2.0) (/ diam 4.0))
pt4 (polar pt3 pi (- lngth diam))
pt5 (polar pt4 (* pi 1.5) (/ diam 2.0))
pt6 (polar pt5 0.0 (- lngth diam)))
(command "PLINE" pt3 "W" (/ diam 2.0) "" pt4
"ARC" pt5 "LINE" pt6 "ARC" "CLOSE")
(setvar "OSMODE" oldsnap)
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-comp.htm (1 of 3) [23/03/2005 05:58:37 p.m.]
);while
(princ)
);defun
(princ)
Now fire up AutoCAD and open the Visual Lisp Editor. Type this at the console prompt :
_$ (vlisp-compile 'st "slot.lsp")
T
Have look at the Build Output window :
; (COMPILE-FILES st (D:/drawings/slot.lsp))
[Analyzing file "D:/drawings/slot.lsp"]
..
[COMPILING D:/drawings/slot.lsp]
;;C:SLOT
;
[FASDUMPING object format ->"D:/drawings/slot.fas"]
; Compilation complete.
During compilation, the compiler prints function names and various messages about each stage of
compilation. The first stage is syntax and lexical checking of the source code. If the compiler
encounters errors, it issues messages and halts the compilation process. The compiler issues warnings
if it encounters expressions it considers dangerous, such as redefining existing AutoLISP functions or
assigning new values to protected symbols. If the compiler displays warning or error messages, you
can view and edit the source code that caused these messages by double-clicking on the message in
the Build Output window.
If compilation is successful, as in the example above, the Build Output window displays the name of the
compiled output file. This file should be located in the same directory as your AutoLisp source file. Let's
have a look at the syntax for (vlisp-compile) :
VLISP-COMPILE
Compiles AutoLISP source code into a FAS file
(vlisp-compile 'mode filename [out-filename])
NOTE The Visual LISP IDE must be open in order for vlisp-compile to work.
Arguments :
mode
The compiler mode, which can be one of the following symbols:
st Standard build mode
lsm Optimize and link indirectly
lsa Optimize and link directly
G
filename
A string identifying the AutoLISP source file. If the source file is in the AutoCAD Support File
Search Path, you can omit the path when specifying the file name. If you omit the file extension,
.lsp is assumed.
G
out-filename
A string identifying the compiled output file. If you do not specify an output file, vlisp-compile
names the output with the same name as the input file, but replaces the extension with .fas.
Note that if you specify an output file name but do not specify a path name for either the input or
the output file, vlisp-compile places the output file in the AutoCAD install directory.
G
Return Values :
T, if compilation is successful, nil otherwise. G
Examples
Assuming that slot.lsp resides in a directory that is in the AutoCAD Support File Search Path, the
following command compiles this program :
_$ (vlisp-compile 'st "slot.lsp")
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-comp.htm (2 of 3) [23/03/2005 05:58:37 p.m.]
T
The output file is named slot.fas and resides in the same directory as the source file.
The following command compiles slot.lsp and names the output file Slot-1.fas :
(vlisp-compile 'st "slot.lsp" "slot-1.fas")
Note that the output file from the previous command resides in the AutoCAD install directory, not the
directory where slot.lsp resides. The following command compiles slot.lsp and directs the output file to
the c:\my documents directory :
(vlisp-compile 'st "slot.lsp" "c:/my documents/slot-1.fas)
This last example identifies the full path of the file to be compiled :
(vlisp-compile 'st "c:/program files/acad2000/Sample/slot.lsp")
The output file from this command is named slot.fas and resides in the same directory as the input file.
On Page II we'll be having a look at creating compiled AutoLisp files using multiple AutoLisp files and
dependency files such as DCL files.
Page I Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-comp.htm (3 of 3) [23/03/2005 05:58:37 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Compiling AutoLisp Files - Page II
Visual Lisp provides you with the ability to create a single, standalone executable module for your
application. This module incorporates all your application's compiled files, and can include DCL, DVB,
and other files that your application may need. Executable Visual Lisp modules are known as VLX files,
and are stored in files named with a .vlx extension.
A Make Application wizard guides you through the application building process in Visual Lisp. The
result of this process is a Make file, which is often referred to by its file extension, .prv. The Make file
contains all the instructions Visual Lisp needs to build the application executable.
To test this out, I've provided an AutoLisp Application that consists of an AutoLisp file, and a DCL file.
From these 2 files we will compile one vlx executable module. (Just click here to download the source
files). Unzip these files and save them in any directory within your AutoCAD Support Path.
OK, fire up AutoCAD and open the Visual Lisp Editor. Now select "Files" - "Make Application" - "New
Application" from the pulldown menu :
This dialog will appear :
Compiling AutoLisp Files - Page II.
http://www.afralisp.com/vl/vl-comp2.htm (1 of 6) [23/03/2005 05:59:00 p.m.]
Select "Expert" mode as we want to compile multiple file types, and then press "Next" :
Enter the path to the directory you would like to store the files in. Select the same directory that you
stored the AutoLisp source files.
Then, give your application a name. It does not have to be the same as your AutoLisp source file, but to
spare any confusion, let's keep it the same.
The select "Next" :
No, we do not want our application to run in a separate namespace.
Just select "Next" :
Compiling AutoLisp Files - Page II.
http://www.afralisp.com/vl/vl-comp2.htm (2 of 6) [23/03/2005 05:59:00 p.m.]
Now we need to select our AutoLisp source file. Select "refl.lsp" then press "Next" :
In this dialog, we select and add any dependency files that our application needs to run correctly. Select
"refl.dcl" and then "Next" :
Compiling AutoLisp Files - Page II.
http://www.afralisp.com/vl/vl-comp2.htm (3 of 6) [23/03/2005 05:59:00 p.m.]
No need to confuse you now, just go with the "Standard" option. Select "Next" :
OK, that's us about done. To build your compiled application, just select "Finish".
VLISP executes instructions in a Make file to build an application. Output messages from this process
appear in two VLISP windows: the Build Output window and the Console window. The Build Output
window contains messages relating to any compilation of AutoLISP source code into .fas files. In a
successful compile, the output looks like the following :
; (COMPILE-FILES st (D:/drawings/refl.lsp))
[Analyzing file "D:/drawings/refl.lsp"]
..
......
[COMPILING D:/drawings/refl.lsp]
;
;;C:REFL
;CCC
;;MKLIST
;;SPINBAR
;;INITERR
;;TRAP
;;RESET
;
[FASDUMPING object format ->"D:/drawings/refl.fas"]
; Compilation complete.
The compiler messages identify the following items:
The name and directory path of the source files being compiled. G
Compiling AutoLisp Files - Page II.
http://www.afralisp.com/vl/vl-comp2.htm (4 of 6) [23/03/2005 05:59:00 p.m.]
The functions defined in the source file. Seven functions are identified: C:REFL, CCC, MKLIST,
SPINBAR, INITERR, TRAP and RESET.
G
The name and path of the output .fas files. G
The VLISP Console window displays messages relating to the creation of the application executable, the
.vlx file. If the Make Application process succeeds, the Console window displays the path and file name
of the .vlx, as in the following example:
VLX-Application packed D:/drawings/refl.VLX
_$
Have a look in the directory where you stored the source files. You should now have 5 "refl" files :
refl.lsp - AutoLisp source file G
refl.dcl - DCL source file G
refl.fas - Compiled AutoLisp Program G
refl.vlx - Executable Visual Lisp Module G
refl.prv - Application Make file. G
You can now distribute "refl.vlx" as a compiled application.
Note!!! You CANNOT edit a vlx file. These 5 files need to be kept in a safe location if you intend to edit or
revise your vlx file.
Loading Compiled AutoLisp Applications :
Loading compiled applications is exactly the same as for normal AutoLisp functions :
(load "refl")
Here's a couple of things to keep in mind :
If you do not specify a file extension, load first looks for a file with the name you specified (for example,
"refl"), and an extension of .vlx. If no .vlx file is found, load searches next for a .fas file, and finally, if no
.fas file is found, load searches for a .lsp file.
Tip of the Day :
To aid you in the process of maintaining multiple-file applications, VLISP provides a construct called a
Project. A VLISP Project contains a list of AutoLISP source files, and a set of rules on how to compile
the files.
Using the Project definition, VLISP can do the following :
Check which .lsp files in your application have changed, and automatically recompile only the
modified files. This procedure is known as a Make procedure.
G
Simplify access to source files by listing all source files associated with a project, making them
accessible with a single-click.
G
Help you find code fragments by searching for strings when you do not know which source files
contain the text you're looking for. VLISP limits the search to files included in your project.
G
Optimize compiled code by directly linking the corresponding parts of multiple source files. G
Have a look at the Visual Lisp Help for further information on Projects.
Page I Page II

Compiling AutoLisp Files - Page II.


http://www.afralisp.com/vl/vl-comp2.htm (5 of 6) [23/03/2005 05:59:00 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Compiling AutoLisp Files - Page II.
http://www.afralisp.com/vl/vl-comp2.htm (6 of 6) [23/03/2005 05:59:00 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
VLAX Enumeration Constants
Constant Symbol Value
:vlax-false :vlax-false
:vlax-null :vlax-null
:vlax-true :vlax-true
vlax-vbAbort 3
vlax-vbAbortRetryIgnore 2
vlax-vbApplicationModal 0
vlax-vbArchive 32
vlax-vbArray 8192
vlax-vbBoolean 11
vlax-vbCancel 2
vlax-vbCritical 16
vlax-vbCurrency 6
vlax-vbDataObject 13
vlax-vbDate 7
vlax-vbDefaultButton1 0
vlax-vbDefaultButton2 256
vlax-vbDefaultButton3 512
vlax-vbDirectory 16
vlax-vbDouble 5
vlax-vbEmpty 0
vlax-vbError 10
vlax-vbExclamation 48
vlax-vbHidden 2
vlax-vbHiragana 32
vlax-vbIgnore 5
vlax-vbInformation 64
vlax-vbInteger 2
vlax-vbKatakana 16
vlax-vbLong 3
vlax-vbLowerCase 2
vlax-vbNarrow 8
vlax-vbNo 7
vlax-vbNormal 0
vlax-vbNull 1
vlax-vbObject 9
vlax-vbOK 1
vlax-vbOKCancel 1
vlax-vbOKOnly 0
vlax-vbProperCase 3
vlax-vbQuestion 32
vlax-vbReadOnly 1
vlax-vbRetry 4
vlax-vbRetryCancel 5
vlax-vbSingle 4
vlax-vbString 8
vlax-vbSystem 4
vlax-vbSystemModal 4096
VLAX Enumeration Constants
http://www.afralisp.com/vl/enum.htm (1 of 2) [23/03/2005 05:59:01 p.m.]
vlax-vbUpperCase 1
vlax-vbVariant 12
vlax-vbVolume 8
vlax-vbWide 4
vlax-vbYes 6
vlax-vbYesNo 4
vlax-vbYesNoCancel 3

Thanks to David Stein from whom I "borrowed" this listing.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
VLAX Enumeration Constants
http://www.afralisp.com/vl/enum.htm (2 of 2) [23/03/2005 05:59:01 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home Page II
Visual Lisp and Polylines
Dealing with polylines using straight forward AutoLisp can be quite a pain. But, believe it or not, using
Visual Lisp they are a breeze to modify and manipulate. Let's have a look shall we?
First of all, fire up AutoCAD and draw a polyline but do not close it :
Now, type the following in the Visual Lisp editor :
_$ (vl-load-com)
_$ (setq theobj (car (entsel "\nSelect a Polyline: ")))
<Entity name: 14e35f8>
_$ (setq theobj (vlax-ename->vla-object theobj))
#<VLA-OBJ ECT IAcadLWPolyline 01ea16d4>
_$ (vlax-dump-object theobj T)
; IAcadLWPolyline: AutoCAD Lightweight Polyline Interface
; Property values:
; Application (RO) =#<VLA-OBJ ECT IAcadApplication 00ac8928>
; Area (RO) =16178.7
; Closed =0
; Color =256
; ConstantWidth =0.0
; Coordinate =...Indexed contents not shown...
; Coordinates =(540.98 557.623 640.815 449.587 453.624 403.879 ... )
; Document (RO) =#<VLA-OBJ ECT IAcadDocument 00ec89b4>
; Elevation =0.0
; Handle (RO) ="957"
; HasExtensionDictionary (RO) =0
; Hyperlinks (RO) =#<VLA-OBJ ECT IAcadHyperlinks 01ea1ec4>
; Layer ="7"
; Linetype ="BYLAYER"
; LinetypeGeneration =0
; LinetypeScale =1.0
; Lineweight =-1
; Normal =(0.0 0.0 1.0)
; ObjectID (RO) =21902840
; ObjectName (RO) ="AcDbPolyline"
; OwnerID (RO) =21901504
; PlotStyleName ="ByLayer"
; Thickness =0.0
; Visible =-1
; Methods supported:
; AddVertex (2)
; ArrayPolar (3)
; ArrayRectangular (6)
PolyLines
http://www.afralisp.com/vl/poly1.htm (1 of 5) [23/03/2005 05:59:03 p.m.]
; Copy ()
; Delete ()
; Explode ()
; GetBoundingBox (2)
; GetBulge (1)
; GetExtensionDictionary ()
; GetWidth (3)
; GetXData (3)
; Highlight (1)
; IntersectWith (2)
; Mirror (2)
; Mirror3D (3)
; Move (2)
; Offset (1)
; Rotate (2)
; Rotate3D (3)
; ScaleEntity (2)
; SetBulge (2)
; SetWidth (3)
; SetXData (2)
; TransformBy (1)
; Update ()
T
This is a listing of all the Properties and Methods belonging to our polyline object.
Let's close the polyline:
_$ (vla-put-closed theobj :vlax-true)
nil
Now let's change the width of all the segments :
_$ (vla-put-ConstantWidth theobj 2.0)
nil
Let's "bulge" the third segment :
_$ (vla-setbulge theobj 2 0.5)
nil
Let's change the starting and ending width of the fourth segment :

PolyLines
http://www.afralisp.com/vl/poly1.htm (2 of 5) [23/03/2005 05:59:03 p.m.]
_$ (vla-setwidth theobj 3 10.0 0.0)
nil
Let's get the area :
_$ (vla-get-area theobj)
14505.9
Now, we'll make it invisible :
_$ (vla-put-visible theobj :vlax-false)
nil
See it's gone. Let's bring it back :
_$ (vla-put-visible theobj :vlax-true)
nil
Now we'll explode it :

_$ (vla-explode theobj)
#<variant 8201 ...>
And delete the original :

_$ (vla-delete theobj)
nil
We are left with an exploded copy of our polyline :
Right, let's have a look at extracting some information from a polyline.
This program will extract the X and Y coordinates from any polyline.

(prompt "\nType \"VL-POLY\" to run........")


(defun c:vl-poly ( / theobj thelist n xval yval fname fn)
;load the visual lisp extensions
(vl-load-com)
;get the entity and entity name
(setq theobj (car (entsel "\nSelect a Polyline: ")))
;convert to vl object
(setq theobj (vlax-ename->vla-object theobj))
;check if it's a polyline
(if (= (vlax-get-property theobj 'ObjectName) "AcDbPolyline")
;if it is, do the following
(progn
PolyLines
http://www.afralisp.com/vl/poly1.htm (3 of 5) [23/03/2005 05:59:03 p.m.]
;retrieve the coordinates
(setq thelist (vlax-get-property theobj 'coordinates))
;convert to a list
(setq thelist (vlax-safearray->list (variant-value thelist)))
;zero the counter
(setq n 0)
;create a text file
(setq fname "coord.txt")
;open it to write
(setq fn (open fname "w"))
;write the header
(write-line "PolyLine X and Y Coordinates" fn)
;underline the header
(write-line "*****************************************" fn)
;start the loop
(repeat (/ (length thelist) 2)
;get the x coordinate
(setq xval (rtos (nth n thelist)))
;increase the counter
(setq n (1+ n))
;get the y coordinate
(setq yval (rtos (nth n thelist)))
;write the x coordinate to the file
(write-line (strcat "X-Value : " xval) fn)
;write the x coordinate to the file
(write-line (strcat "Y-Value : " yval) fn)
;add a seperator
(write-line "-----------------------------" fn)
;increase the counter
(setq n (1+ n))
);repeat
;close the file
(close fn)
);progn
;it's not a polyline, inform the user
(alert "This is not a Polyline!! - Please try again.")
);if
(princ)
);defun
;------------------------
;clean loading
(princ)
;---------------------------
;End of VL-POLY.LSP
;---------------------------

Save this as "VL-Poly.lsp" and then load and run it. Select any polyline.
PolyLines
http://www.afralisp.com/vl/poly1.htm (4 of 5) [23/03/2005 05:59:03 p.m.]
The X and Y coordinates of each vertex will be output and written to a file named "Coord.txt"
It should look something like this :
PolyLine X and Y Coordinates
*****************************************
X-Value : 478.6
Y-Value : 622
-----------------------------
X-Value : 815.5
Y-Value : 349.9
-----------------------------
X-Value : 636.7
Y-Value : 291.7
-----------------------------
X-Value : 586.7
Y-Value : 437.1
-----------------------------
X-Value : 516
Y-Value : 310.4
-----------------------------
X-Value : 349.6
Y-Value : 304.2
-----------------------------

In the next section, we'll have a look at creating polylines and adding one or two "bulges".
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PolyLines
http://www.afralisp.com/vl/poly1.htm (5 of 5) [23/03/2005 05:59:03 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home Page I
Visual Lisp and Polylines
This is the VBA method to create a lightweight polyline from a list of vertices.
RetVal =object.AddLightweightPolyline(VerticesList)
Object : ModelSpace Collection, PaperSpace Collection, Block.
The object or objects this method applies to.
G
VerticesList : Variant (array of doubles)
The array of 2D OCS coordinates specifying the vertices of the polyline. At least two points (four
elements) are required for constructing a lightweight polyline. The array size must be a multiple of
2.
G
RetVal : LightweightPolyline object.
The newly created LightweightPolyline object.
G
In Visual Lisp, the syntax would be as follows :
(vla-addLightweightPolyline Object VerticesList)
and would return RetVal.
Let's try this out. First we need a reference to Model Space :
_$ (setq mspace (vla-get-modelSpace (vla-get-activeDocument (vlax-get-acad-object))))
#<VLA-OBJ ECT IAcadModelSpace 01ea5064>
Get the first point :
_$ (setq pt1 (getpoint))
(424.505 252.213 0.0)
Extract the X and Y coordinates
_$ (setq pt1 (list (car pt1) (cadr pt1)))
(424.505 252.213)
And now the second point :
_$ (setq pt2 (getpoint))
(767.689 518.148 0.0)
Extract the X and Y coordinates :
_$ (setq pt2 (list (car pt2) (cadr pt2)))
(767.689 518.148)
Join the the two lists together :
_$ (setq pt1 (append pt1 pt2))
(424.505 252.213 767.689 518.148)
Construct a 4 element safearray :
_$ (setq anarray (vlax-make-safearray vlax-vbDouble '(0 . 3)))
#<safearray...>
Fill it with our point X and Y values :
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (1 of 7) [23/03/2005 05:59:06 p.m.]
_$ (vlax-safearray-fill anarray pt1)
#<safearray...>
Draw the polyline :
_$ (setq myobj (vla-addLightweightPolyline mspace anarray))
#<VLA-OBJ ECT IAcadLWPolyline 01ea5914>
Let's now have a look how we could apply this to a practical example :
;CODING STARTS HERE
(prompt "\nType \"VL-Steel\" to run......")
;set up default rotation angle
(if (= rot nil) (setq rot 0))
;define the function and declare all local variables
(defun C:VL-Steel ( / ptlist oldsnap oldecho oldblip
acaddoc util mspace names sizes dcl_id siza userclick
dlist H B T1 T2 R1 IP IPA P1 ptlisp tmp myobj fname
fn pts)
;load VL functions
(vl-load-com)
;obtain reference to the Active Document
(setq acaddoc (vla-get-activeDocument (vlax-get-acad-object)))
;obtain reference to Utilities
(setq util (vla-get-utility acaddoc))
;obtain reference to Model Space
(setq mspace (vla-get-modelSpace acaddoc))
;store system variables
(setq oldsnap (vla-getvariable acaddoc "OSMODE")
oldecho (vla-getvariable acaddoc "CMDECHO")
oldblip (vla-getvariable acaddoc "BLIPMODE")
);setq
;switch off system variables
(vla-setvariable acaddoc "CMDECHO" 0)
(vla-setvariable acaddoc "BLIPMODE" 0)
;create list of steel sections for the list box
(setq names '("100x55x8" "120x64x10" "140x73x13" "160x82x16"
"180x91x19" "200x100x22" "203x133x25" "203x133x30" "254x146x31"
"254x146x37" "254x146x43" ) )
;create list of steel section values
(setq sizes '((100.0 55.0 4.1 5.7 7.0)
(120.0 64.0 4.4 6.3 7.0) (140.0 73.0 4.7 6.9 7.0)
(160.0 82.0 5.0 7.4 9.0) (180.0 91.0 5.3 8.0 9.0)
(200.0 100.0 5.6 8.5 12.0) (203.2 133.4 5.8 7.8 7.6)
(206.8 133.8 6.3 9.6 7.6) (251.5 146.1 6.1 8.6 7.6)
(256.0 146.4 6.4 10.9 7.6) (259.6 147.3 7.3 12.7 7.6)))
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (2 of 7) [23/03/2005 05:59:06 p.m.]
;construct the dialog
(create_dialog)
;load the dialog
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "ubeam" dcl_id))
(exit)
)
;setup the list box
(start_list "selections")
(mapcar 'add_list names)
(end_list)
;default rotation angle
(set_tile "rot" (rtos rot))
;setup the Cancel button
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
;setup the OK button
(action_tile
"accept"
(strcat
"(progn (setq siza (atof (get_tile \"selections\")))
(setq rot (atof (get_tile \"rot\")))"
"(done_dialog) (setq userclick T))" )
)
;display the dialog
(start_dialog)
;unload the dialog
(unload_dialog dcl_id)
;delete the temp DCL file
(vl-file-delete fname)
;if the OK button was selected
(if userclick
;do the following
(progn
;retrieve the steel section values
(setq dlist (nth (fix siza) sizes))
;place them into variables
(mapcar 'set '(H B T1 T2 R1) dlist)
;switch on the intersection snap
(vla-setvariable acaddoc "OSMODE" 32)
;get the insertion point
(setq IP (vla-getpoint util nil "\nInsertion Point : "))
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (3 of 7) [23/03/2005 05:59:06 p.m.]
;switch off the snaps
(vla-setvariable acaddoc "OSMODE" 0)
;calculate the points and store them in a list
(setq pts (list
(setq P1 (vla-polarpoint util IP 0 (/ T1 2)))
(setq P1 (vla-polarpoint util P1 (DTR 90.0)
(/ (- H (+ T2 T2 R1 R1)) 2)))
(setq P1 (vla-polarpoint util P1 (DTR 45.0)
(sqrt (* R1 R1 2.0))))
(setq P1 (vla-polarpoint util P1 0
(/ (- B (+ T1 R1 R1)) 2)))
(setq P1 (vla-polarpoint util P1 (DTR 90.0) T2))
(setq P1 (vla-polarpoint util P1 (DTR 180.0) B))
(setq P1 (vla-polarpoint util P1 (DTR 270.0) T2))
(setq P1 (vla-polarpoint util P1 0
(/ (- B (+ T1 R1 R1)) 2)))
(setq P1 (vla-polarpoint util P1 (DTR 315.0)
(sqrt (* R1 R1 2.0))))
(setq P1 (vla-polarpoint util P1 (DTR 270.0)
(- H (+ T2 T2 R1 R1))))
(setq P1 (vla-polarpoint util P1 (DTR 225.0)
(sqrt (* R1 R1 2.0))))
(setq P1 (vla-polarpoint util P1 (DTR 180.0)
(/ (- B (+ T1 R1 R1)) 2)))
(setq P1 (vla-polarpoint util P1 (DTR 270.0) T2))
(setq P1 (vla-polarpoint util P1 0 B))
(setq P1 (vla-polarpoint util P1 (DTR 90.0) T2))
(setq P1 (vla-polarpoint util P1 (DTR 180.0)
(/ (- B (+ T1 R1 R1)) 2)))
(setq P1 (vla-polarpoint util P1 (DTR 135.0)
(sqrt (* R1 R1 2.0))))
(setq P1 (vla-polarpoint util IP 0 (/ T1 2)))
));setq
;extract only the X and Y values of each point list
(mapcar
'(lambda (pt)
;convert to lists
(setq pt (vlax-safearray->list (variant-value pt)))
;X and Y values only
(setq ptlist (cons (list (car pt) (cadr pt)) ptlist))
);lambda
pts
);mapcar
;break the point list up into elements
(setq ptlist (apply 'append ptlist))
;create a safearray to store the elements
(setq tmp (vlax-make-safearray vlax-vbDouble
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (4 of 7) [23/03/2005 05:59:06 p.m.]
(cons 0 (- (vl-list-length ptlist) 1))))
;fill the safearray
(vlax-safearray-fill tmp ptlist)
;draw the steel section
(setq myobj (vla-addLightweightPolyline mspace tmp))
;radius the corners
(vla-setbulge myobj 1 0.4142)
(vla-setbulge myobj 7 0.4142)
(vla-setbulge myobj 9 0.4142)
(vla-setbulge myobj 15 0.4142)
;rotate the object
(vla-rotate myobj ip (dtr rot))
);progn
);if
;reset system variables
(vla-setvariable acaddoc "OSMODE" oldsnap)
(vla-setvariable acaddoc "CMDECHO" oldecho)
(vla-setvariable acaddoc "BLIPMODE" oldblip)
;release all objects
(vlax-release-object mspace)
(vlax-release-object util)
(vlax-release-object acaddoc)
;finish clean
(princ)
);defun
;--------------------------
(defun create_dialog ()
;create a temp DCL file
(setq fname (vl-filename-mktemp "dcl.dcl"))
;open it to write
(setq fn (open fname "w"))
;write the dialog coding
(write-line
"ubeam : dialog {
label = \"VL-Steel\";
: list_box {
label = \"Choose Section :\";
key = \"selections\";
allow_accept = true;
height = 8;
}
: edit_box {
label = \"Rotation Angle :\";
key = \"rot\";
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (5 of 7) [23/03/2005 05:59:06 p.m.]
edit_limit = 4;
edit_width = 4;
}
spacer;
ok_cancel ;
:text_part {
label = \"Designed and Created\";
}
:text_part {
label = \"by Kenny Ramage\";
}
}" fn)
;close the temp DCL file
(close fn)
);defun
;------------------------------
;convert degrees to radians
(defun DTR (a)
(* pi (/ a 180))
);defun
;---------------------------------
;load clean
(princ)
;CODING ENDS HERE
Save this as "VL-Steel.lsp" and then load and run it. A dialog like this will appear :
Choose the section size you would like, choose a rotation angle, select an insertion point, and voila,
your steel section is drawn using a polyline.
"OK Kenny, now we give in. HOW do you calculate a bulge?"
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (6 of 7) [23/03/2005 05:59:06 p.m.]
Bulge = TAN ( / Included Angel 4)
In our case Bulge = TAN ( / 90 4) = 0.4142
Thanks to Stig Madsen for the insight into some of this coding.
Click here to download the sample coding from this tutorial.
If you would like to have a look at a similar application, but written in VBA, just click here.
Home Page I

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
PolyLines - Page II
http://www.afralisp.com/vl/poly2.htm (7 of 7) [23/03/2005 05:59:06 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Utilities
Whilst looking around the web at other peoples coding, I noticed that nearly everyone still uses the
traditional AutoCAD "get" functions to retrieve entities and values.
In this tutorial, we're going to have a look at the Visual Lisp methods that are available to us to achieve
the same results. We find these methods in the "Utility" object.
Note! Most of the Visual Lisp "get" methods do not flip to the AutoCAD screen from the Visual Lisp
Editor. You need to activate AutoCAD manually and then return to the Visual Lisp Editor.
Let's first have a look at the "standard" way of retrieving points and the drawing a line. Type the
following in the console :
(vl-load-com)
_$ (setq acaddoc (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJ ECT IAcadDocument 00b94e14>
_$ (setq mspace (vla-get-modelspace acaddoc))
#<VLA-OBJ ECT IAcadModelSpace 01e42494>
_$ (setq PT1 (getpoint "\nSpecify First Point: "))
(228.279 430.843 0.0)
_$ (setq PT2 (getpoint "\nSpecify next point: " apt))
(503.866 538.358 0.0)
_$ (setq myline (vla-addline mspace (vlax-3d-point PT1)(vlax-3d-point PT2)))
#<VLA-OBJ ECT IAcadLine 00f9da94>
First we referenced Model Space, then we retrieved two points using the (getpoint) function.
We then used the (addline) method to draw our line, firstly converting the two point lists into variant
arrays.
We can though, use Visual Lisp to obtain our two points. Try this :
_$ (setq util (vla-get-utility acaddoc))
#<VLA-OBJ ECT IAcadUtility 00f9e014>
_$ (setq PT1 (vla-getpoint util nil "\nSpecify First Point : "))
#<variant 8197 ...>
_$ (setq PT2 (vla-getpoint util PT1 "\nSpecify Second Point : "))
#<variant 8197 ...>
$ (setq myline (vla-addline mspace PT1 PT2))
#<VLA-OBJ ECT IAcadLine 00f9da94>
Because we used the Visual Lisp method to retrieve our points, the values were not returned as list, but
as variant arrays. This means that we don't have to use (vlax-3d-point) to convert our points into
variable arrays.
As you probably noticed from the line
(setq util (vla-get-utility acaddoc))
the (vla-get) method, is a method of the "Utilitity" object.
Let's have a closer look.
Application
(Object)
|
|
|------------- Active Document
| (Object)
|
Visual Lisp - The Utilities Object
http://www.afralisp.com/vl/Utilities.htm (1 of 4) [23/03/2005 05:59:10 p.m.]
|
|
|------------- Utility
| (Object)
_$ (vl-load-com)
_$ (setq acaddoc (vla-get-activeDocument (vlax-get-acad-object)))
#<VLA-OBJ ECT IAcadDocument 00f5db9c>
_$ (setq util (vla-get-utility acaddoc))
#<VLA-OBJ ECT IAcadUtility 00f9e014>
_$ (vlax-dump-object util T)
; IAcadUtility: A series of methods provided for utility
purposes
; No properties
; Methods supported:
; AngleFromXAxis (2)
; AngleToReal (2)
; AngleToString (3)
; CreateTypedArray (3)
; DistanceToReal (2)
; GetAngle (2)
; GetCorner (2)
; GetDistance (2)
; GetEntity (3)
; GetInput ()
; GetInteger (1)
; GetKeyword (1)
; GetOrientation (2)
; GetPoint (2)
; GetReal (1)
; GetRemoteFile (3)
; GetString (2)
; GetSubEntity (5)
; InitializeUserInput (2)
; IsRemoteFile (2)
; IsURL (1)
; LaunchBrowserDialog (6)
; PolarPoint (3)
; Prompt (1)
; PutRemoteFile (2)
; RealToString (3)
; TranslateCoordinates (5)
T
Well, the Utility object doesn't seem to have any Properties,
but it's got a treasure trove of Methods. We'll now have a
wee look at a few of them.
First though, let's recap on the way we convert VBA
methods to Visual Lisp methods.
Let's look at the VBA "GetDistance" method :
GetDistance Method
Gets the distance from the prompt line or a selected set of points on the screen.
Syntax
RetVal =Object.GetDistance([Point][, Prompt])
Object -Utility - The object or objects this method applies to. G
Point - Variant (three-element array of doubles); input-only; optional
The 3D WCS coordinates specifying the base point. If this point is not provided, the user must
input two points.
G
Prompt - Variant (string); input-only; optional G
Visual Lisp - The Utilities Object
http://www.afralisp.com/vl/Utilities.htm (2 of 4) [23/03/2005 05:59:10 p.m.]
The text to display to prompt the user for input.
RetVal - Variant (double or array of doubles)
The distance from the prompt line or a selected set of points on the screen.
G
Remarks
AutoCAD pauses for user input of a linear distance and sets the return value to the value of the selected
distance. The Point parameter specifies a base point in WCS coordinates. The Prompt parameter
specifies a string that AutoCAD displays before it pauses. Both Point and Prompt are optional.
The AutoCAD user can specify the distance by entering a number in the current units format. The user
can also set the distance by specifying two locations on the graphics screen. AutoCAD draws a
rubber-band line from the first point to the current crosshair position to help the user visualize the
distance. If the Point parameter is provided, AutoCAD uses this value as the first of the two points.
By default, GetDistance treats Point and the return value as three-dimensional points. A prior call to the
InitializeUserInput method can force Point to be two-dimensional, ensuring that this method returns a
planar distance.
Regardless of the method used to specify the distance or the current linear units (for example, feet and
inches), this method always sets the return value to a double-precision floating-point value.
In Visual Lisp, the syntax would be :
RetVal =(vla-getdistance object [point] [prompt])
Example :
_$ (setq dist (vla-getdistance util nil "\nFirst Point : \n"))
535.428
Sometimes you retrieve a distance value as a string. Here's how you could convert it :
_$ (setq dist "123.45")
"123.45"
_$ (setq dist (vla-DistancetoReal util dist acDecimal))
123.45
Let's have a look at a few more "get" examples :
_$ (setq s (vla-getstring util 0 "Enter String: "))
"Kenny"
Note the "0" argument that disallows spaces.
Let's allow spaces this time :
_$ (setq s (vla-getstring util 1 "Enter String: "))
"Kenny Ramage is brilliant"
Let's get some Integers :
_$ (setq i (vla-getinteger util "\nEnter an Integer: "))
2
Now enter a real number for example 6.3
"Requires An Integer Value"
"Enter an Integer: "
Try it with a letter such as "A"
Same message.
Now we'll get some real's :
_$ (setq i (vla-getreal util "\nEnter and Integer: "))
5.7
Again, try it with a letter such as "C"
"Requires Numeric Value"
"Enter a Real: "
Now for an angle :
Visual Lisp - The Utilities Object
http://www.afralisp.com/vl/Utilities.htm (3 of 4) [23/03/2005 05:59:10 p.m.]
_$ (setq a (vla-getangle util nil "\nSelect Angle: "))
0.473349
Let 's give it a base point :
_$ (setq bpt (vla-getpoint util nil "/nSelect Base Point: "))
#<variant 8197 ...>
And use it to "rubber band" :
_$ (setq a (vla-getangle util bpt "\nSelect Angle: "))
0.707583
Now here is a couple of VERY interesting methods.
Want to select just one entity on the screen?
_$ (vla-getentity util 'obj 'ip "\nSelect Object: ")
nil
_$ obj
#<VLA-OBJ ECT IAcadLine 01ea57c4>
_$ ip
#<safearray...>
The reference to the Object is stored in the variable "obj" and the pickpoint is stored in variable "ip" in
the form of a safearray.
Would you like to create a safearray very easily and quickly :
_$ (vla-createtypedarray util 'thearray vlax-vbDouble 1.2 2.3 0.0)
nil
_$ thearray
#<safearray...>
Your safearray is stored in the variable "thearray"
On the next page we'll continue our discussion on Visual Lisp Utilities.
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp - The Utilities Object
http://www.afralisp.com/vl/Utilities.htm (4 of 4) [23/03/2005 05:59:10 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Utilities - Page II
Home Page I
Let's now have a look at getting some keywords from the user.
The following example forces the user to enter a keyword by setting the first parameter of
InitializeUserInput to 1, which disallows NULL input (pressing ENTER).
_$ (vla-InitializeUserInput util 1 "Line Arc Circle")
nil
_$ (setq kword (vla-GetKeyword util "Enter an Option (Line/Circle/Arc) : "))
"Line"
Let's have a closer look at "InitiliazeUserInput.
"InitiliazeUserInput" :
Syntax :
(vla-InitiliazeUserInput Object Bits Keyword)
Object : The object or objects this method applies to. In this case, the object is the Utility Object.
Bits : Integer; input-only
To set more than one condition at a time, add the values together in any combination. If this value is not
included or is set to 0, none of the control conditions apply.
1 Disallows NULL input. This prevents the user from responding to the request by entering only
[Return] or a space.
2 Disallows input of zero (0). This prevents the user from responding to the request by entering 0.
4 Disallows negative values. This prevents the user from responding to the request by entering a
negative value.
8 Does not check drawing limits, even if the LIMCHECK system variable is on. This enables the
user to enter a point outside the current drawing limits. This condition applies to the next
user-input function even if the AutoCAD LIMCHECK system variable is currently set.
16 Not currently used.
32 Uses dashed lines when drawing rubber-band lines or boxes. This causes the rubber-band line
or box that AutoCAD displays to be dashed instead of solid, for those methods that let the user
specify a point by selecting a location on the graphics screen. (Some display drivers use a
distinctive color instead of dashed lines.) If the POPUPS system variable is 0, AutoCAD ignores
this bit.
64 Ignores Z coordinate of 3D points (GetDistance method only). This option ignores the Z
coordinate of 3D points returned by the GetDistance method, so an application can ensure this
function returns a 2D distance.
128 Allows arbitrary inputwhatever the user types.
Keyword : Variant (array of strings); input-only; optional
The keywords that the following user-input method will recognize.
Remarks : Keywords must be defined with this method before the call to GetKeyword. Certain
user-input methods can accept keyword values in addition to the values they normally return, provided
that this method has been called to define the keyword. The user-input methods that can accept
keywords are: GetKeyword, GetInteger, GetReal, GetDistance, GetAngle, GetOrientation, GetPoint, and
GetCorner.
Visual Lisp - The Utilities Page IIObject
http://www.afralisp.com/vl/Utilities1.htm (1 of 4) [23/03/2005 05:59:12 p.m.]
Let's have a look at another example :
A more user-friendly keyword prompt is one that provides a default value if the user presses ENTER
(NULL input). Notice the minor modifications to the following example:
(vla-InitializeUserInput util 0 "Line Arc Circle")
nil
_$ (setq kword (vla-GetKeyword util "Enter an Option (Line/Circle/<Arc>) : "))
""
_$ (if (=kword "") (setq kword "Arc"))
"Arc"
Now we'll look at something very simple. Try this :
(vla-prompt util "\nPress any key to continue.....")
nil
And another interesting one :
_$ (setq pt1 (vla-getpoint util nil "\nFirst Point :"))
#<variant 8197 ...>
_$ (setq pt2 (vla-getpoint util pt1 "\nSecond Point :"))
#<variant 8197 ...>
_$ (setq theangle (vla-AngleFromXAxis util pt1 pt2))
0.459321
Of course, the result is returned in radians.
The Polar function, as you are probably well aware, is one of the most powerful function in the AutoLisp
arsenal. Because of this, we are going to have a close look at the PolarPoint method. Lets have a look at
the syntax first :
"PolarPoint"
Syntax :
RetVal =(vla-PolarPoint Object Point Angle Distance)
Example : (setq pt3 (vla-polarpoint pt2 0.5 20.0))
Object : Utility - The object or objects this method applies to. G
Point : Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the start point.
G
Angle : Double; input-only
The angle in radians.
G
Distance : Double; input-only
The distance in current units.
G
RetVal : Variant (three-element array of doubles)
The 3D WCS coordinates at the specified angle and distance from a given point.
G
Here's a working example :
The following coding will draw slotted holes as per the above diagram.
It begins by asking the user for an insertion point, the slot length, and then the slot diameter using
Visual Lisp Get methods.
It then uses the PolarPoint method to calculate the other points required to draw the slot. Then, using
Visual Lisp - The Utilities Page IIObject
http://www.afralisp.com/vl/Utilities1.htm (2 of 4) [23/03/2005 05:59:12 p.m.]
the AddLine and AddArc methods, it draws the slotted hole.
;CODING STARTS HERE
(defun c:slot ( / acaddoc util mspace ip lg
dia P1 P2 P3 P4 P5 P6 P7)
;load VL functions
(vl-load-com)
;obtain reference to the Active Document
(setq acaddoc (vla-get-activeDocument (vlax-get-acad-object)))
;obtain reference to Utilities
(setq util (vla-get-utility acaddoc))
;obtain reference to Model Space
(setq mspace (vla-get-modelSpace acaddoc))
;get the insertion point
(setq ip (vla-getpoint util nil "\nInsertion Point: "))
;get the length
(setq lg (vla-getreal util "\nEnter Slot Length: "))
;get the diameter
(setq dia (vla-getreal util "\nEnter Slot Diameter: "))
;calculate all the points
(setq P1 (vla-polarpoint util IP (dtr 270.0) (/ dia 2)))
(setq P2 (vla-polarpoint util P1 (dtr 180.0) (/ lg 2)))
(setq P3 (vla-polarpoint util P2 (dtr 90.0) dia))
(setq P4 (vla-polarpoint util P3 0 lg))
(setq P5 (vla-polarpoint util P4 (dtr 270.0) dia))
(setq P6 (vla-polarpoint util P2 (dtr 90.0) (/ dia 2)))
(setq P7 (vla-polarpoint util P5 (dtr 90.0) (/ dia 2)))
;draw the lines
(vla-AddLine mspace p2 p5)
(vla-AddLine mspace p3 p4)
;add the arcs
(vla-AddArc mspace p6 (/ dia 2) (dtr 90.0) (dtr 270.0))
(vla-AddArc mspace p7 (/ dia 2) (dtr 270.0) (dtr 90.0))
(princ)
);defun
----------
;convert degrees to radians
(defun DTR (a)
(* pi (/ a 180))
);defun
----------
Visual Lisp - The Utilities Page IIObject
http://www.afralisp.com/vl/Utilities1.htm (3 of 4) [23/03/2005 05:59:12 p.m.]
(princ)
;CODING ENDS HERE

Home Page I

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp - The Utilities Page IIObject
http://www.afralisp.com/vl/Utilities1.htm (4 of 4) [23/03/2005 05:59:12 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and VBA
In this tutorial we are going to do something a bit different. We're going to look at how we can use
Visual Basic for Applications within our Visual Lisp code, especially in regards to dialog boxes. Firstly
though, let's have a look at how we are going to go about loading and running the VBA application that
we want to use. Copy and paste this into Notepad and save it as "Al-Eval.lsp" :
(defun c:al-eval ()
(vl-load-com)
(setq applic (vlax-get-acad-object))
(vla-eval applic (strcat "MsgBox \"Hello Everybody\"" ", "
"vbInformation" ", " "\"AfraLisp\""))
(vla-eval applic (strcat "MsgBox \"Are You Fine?\"" ", "
"vbQuestion" ", " "\"CAD Encoding\""))
(vla-eval applic (strcat "MsgBox \"Or, are you not Well?\"" ", "
"vbCritical" ", " "\"VBA Expresso\""))
(alert "\nAnd this is the boring\nAutoCAD message box!!")
(princ)
);defun
Now load and run the routine. Four dialog boxes should appear, one after the other.
The first three dialogs, similar to the above, are standard VBA message boxes, and the fourth the
AutoLisp alert box. By using the Visual Lisp "eval" method, we were able to "call" a standard VBA
function from within Visual Lisp.
Let's get a bit more clever now, and try and pass information backwards and forwards between Visual
Lisp and VBA.
Open the VBA Editor and create a new Project. Insert a UserForm and add a TextBox and two command
buttons, retaining their default names. Your UserForm should look something like this :
Visual Lisp and VBA - Page I.
http://www.afralisp.com/vl/vl-vba1.htm (1 of 3) [23/03/2005 05:59:15 p.m.]
Now add the following coding to the the Click events for the OK and Cancel buttons :
Private Sub CommandButton1_Click()
ThisDrawing.SetVariable "USERS1", TextBox1.Text
End
End Sub
'--------------------------------------------------------
Private Sub CommandButton2_Click()
End
End Sub
Save you Project as "Testdial.dvb".
Now open Notepad and copy and paste the following :
(defun c:testdial ()
(vl-load-com)
(setq applic (vlax-get-acad-object))
(if (findfile "testdial.dvb")
(progn
(vl-vbaload "testdial.dvb")
(vla-eval applic "userform1.show")
(alert (strcat "You entered : " (getvar "users1")))
);progn
(alert "\nCannot find DVB file")
);if
(princ)
);defun
(princ)
Load and run "Testdial.lsp". A dialog like this should appear :
Visual Lisp and VBA - Page I.
http://www.afralisp.com/vl/vl-vba1.htm (2 of 3) [23/03/2005 05:59:15 p.m.]
Enter something into the TextBox and select "OK".
An alert box like this should appear:
This is what happened :
First, we loaded and called the VBA dialog. G
Secondly, we entered the information. G
Still in VBA, we stored the information into a User system variable. G
We then closed the dialog. G
Back in Visual Lisp, we retrieved the information from the User system variable and displayed it in
an AutoLisp alert box.
G
On the next page, we'll have a look at a more practical use for this procedure.
Home Page II

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp and VBA - Page I.
http://www.afralisp.com/vl/vl-vba1.htm (3 of 3) [23/03/2005 05:59:15 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual Lisp and VBA - Page II
Home Page I
In this next exercise, we're going to design a drawing tile block application. The program will be written
in Visual Lisp, but we will call a VBA program and dialog to display and return our title block data.
OK, open up your VBA Editor and start a new Project. Insert a UserForm and add 5 TextBoxes, 5 Labels
and two command buttons. Retain their default names. Your dialog should look like this :
Now enter the following coding :
Option Explicit
'-----------------------------------------------------
Private Sub CommandButton1_Click()
'set the user system variable
ThisDrawing.SetVariable "UserI1", 1
'retrieve the text box values and store
'them in the user system variables
ThisDrawing.SetVariable "UserS1", TextBox1.Text
ThisDrawing.SetVariable "UserS2", TextBox2.Text
ThisDrawing.SetVariable "UserS3", TextBox3.Text
ThisDrawing.SetVariable "UserS4", TextBox4.Text
ThisDrawing.SetVariable "UserS5", TextBox5.Text
End
End Sub
'----------------------------------------------------------
Private Sub CommandButton2_Click()
'set the user system variable
ThisDrawing.SetVariable "UserI1", 0
End
End Sub
'------------------------------------------------------------
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-vba2.htm (1 of 5) [23/03/2005 05:59:19 p.m.]
Private Sub UserForm_Initialize()
'retrieve user system variables and populate
'the text boxes
TextBox1.Text = ThisDrawing.GetVariable("UserS1")
TextBox2.Text = ThisDrawing.GetVariable("UserS2")
TextBox3.Text = ThisDrawing.GetVariable("UserS3")
TextBox4.Text = ThisDrawing.GetVariable("UserS4")
TextBox5.Text = ThisDrawing.GetVariable("UserS5")
'set the focus to the first text box
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(UserForm1.TextBox1.Text)
End Sub
Save this Project as "AL-VBA.DVB".
Now copy and paste this into Notepad and save it as "VL-VBA.LSP" :
;CODING STARTS HERE
;
;All Tutorials and Code are provided "as-is" for purposes of instruction and
;utility and may be used by anyone for any purpose entirely at their own risk.
;Please respect the intellectual rights of others.
;All material provided here is unsupported and without warranty of any kind.
;No responsibility will be taken for any direct or indirect consequences
;resulting from or associated with the use of these Tutorials or Code.
;*******************************************************************************
; AfraLisp
; http://www.afralisp.com
; afralisp@afralisp.com
; afralisp@mweb.com.na
;*******************************************************************************
;This application will extract attributes from a block and display them in a
;VBA dialog box. The attributes will then be updated.
;
;Dependencies : VL-VBA.DVB and VL-VBA.DWG are
;required and must be within the AutoCAD search path.
;
;Usage : Open VL-VBA.DWG then load and run VL-VBA.LSP.
;*******************************************************************************
(prompt "\nVL-VBA Loaded....Type VL-VBA to run.....")
(defun C:VL-VBA ( / thisdrawing applic ssets newsset filter_code filter_value
item theatts attlist theattribute1 theattribute2 theattribute3
theattribute4 theattribute5)
;load visual lisp extensions
(vl-load-com)
;retrieve reference to the active document
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
;retrieve reference to the selection set collection
(setq ssets (vla-get-selectionsets thisdrawing))
;check if the selection set exists - $Set
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list ssets "$Set")))
;if it doesn't create a new one
(setq newsset (vla-add ssets "$Set"))

;if it does exist
(progn
;delete it
(vla-delete (vla-item ssets "$Set"))
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-vba2.htm (2 of 5) [23/03/2005 05:59:19 p.m.]

;then create a new one
(setq newsset (vla-add ssets "$Set"))

);progn
);if
;create a single element array - integer
(setq filter_code (vlax-make-safearray vlax-vbinteger '(0 . 0)))
;create a single element array - variant
(setq filter_value (vlax-make-safearray vlax-vbvariant '(0 . 0)))
;filter for name - code 2
(vlax-safearray-fill filter_code '(2))
;filter for block name - attab-info
(vlax-safearray-fill filter_value '("attab-info"))
;filter the drawing for the block
(vla-select newsset acSelectionSetAll nil nil filter_code filter_value)
;if the block is found
(if (>= (vla-get-count newsset) 1)
;display the dialog
(ddisplay)
;if the block is not found
(alert
"\nIncorrect Drawing Sheet
\n Use Manual Edit"
)
);if
;release all objects
(vlax-release-object thisdrawing)
(vlax-release-object applic)
;finish clean
(princ)
);defun
;;;**********************************************************
(defun ddisplay (/)
;retrieve the block reference
(setq item (vla-item newsset 0))
;retrieve the attributes
(setq theatts (vla-getattributes item))
;convert to a list
(setq attlist (vlax-safearray->list (variant-value theatts)))
;extract the attributes
(mapcar 'set '(theattribute1 theattribute2 theattribute3
theattribute4 theattribute5) attlist)
;extract the text strings from the attributes
;then put the strings into system variables
(vla-SetVariable thisdrawing "USERS1" (vla-get-textstring theattribute1))
(vla-SetVariable thisdrawing "USERS2" (vla-get-textstring theattribute2))
(vla-SetVariable thisdrawing "USERS3" (vla-get-textstring theattribute3))
(vla-SetVariable thisdrawing "USERS4" (vla-get-textstring theattribute4))
(vla-SetVariable thisdrawing "USERS5" (vla-get-textstring theattribute5))
;find the VBA file
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-vba2.htm (3 of 5) [23/03/2005 05:59:19 p.m.]
(if (findfile "vl-vba.dvb")
;if it's found, do the following
(progn
;load the VBA file
(vl-vbaload "vl-vba.dvb")
;get a reference to the application object
(setq applic (vlax-get-acad-object))
;display the VBA dialog
(vla-eval applic "userform1.show")
;if OK was selected
(if (= (getvar "USERI1") 1)
;do the following
(progn
;update the attribute textstrings
(vla-put-textstring theattribute1 (vla-GetVariable thisdrawing "USERS1"))
(vla-put-textstring theattribute2 (vla-GetVariable thisdrawing "USERS2"))
(vla-put-textstring theattribute3 (vla-GetVariable thisdrawing "USERS3"))
(vla-put-textstring theattribute4 (vla-GetVariable thisdrawing "USERS4"))
(vla-put-textstring theattribute5 (vla-GetVariable thisdrawing "USERS5"))
;update the block
(vla-update newsset)
;regen the drawing
(vl-cmdf "REGEN")
);progn
);if
);progn
;couldn't find the VBA file
(alert "\nCannot find VBA file.")
);if
);defun
;;;***********************************************************
;load clean
(princ)
;;;**********************************************************
;
;CODING ENDS HERE
Now, open the the drawing "AL-VBA.DWG".
A title block should appear :
Load and run "VL-VBA.LSP". Your dialog should appear in all it's glory containing the attribute data
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-vba2.htm (4 of 5) [23/03/2005 05:59:19 p.m.]
from the title block.
Change a few of the title block values and then press "OK". Your title block drawing should be updated
to reflect your new values. Good one hey?
To download the source Visual Lisp, VBA coding and sample drawing for this tutorial, just click here.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Compiling AutoLisp Files - Page I.
http://www.afralisp.com/vl/vl-vba2.htm (5 of 5) [23/03/2005 05:59:19 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Visual LISP Sample Files
This document supplements the code comments contained in the sample files that are included in
Visual LISP.
It details the uses for these files and the concepts they demonstrate.
This document expands on the code comments already included in the sample files that ship with
Visual LISP. The following sections explain the important concepts that these sample files are meant to
demonstrate.
Before reading further, please note that this document assumes you are already familiar with the Visual
LISP Integrated Development Environment (IDE) and the AutoLISP programming language.
Visual LISP Sample Files
If for some reason you do not have the Visual Lisp Sample files, you can download them from here.
Visual LISP contains a collection of sample LISP files that are located in <your Visual LISP
directory>\Sample. These files range in complexity from basic AutoLISP to advanced techniques in
implementing the Visual LISP connection to the AutoCAD ActiveX Object Model. You will also encounter
examples that use the special ActiveX Extension functions included in the Visual LISP function library.
You should be able to find the following files in your \SAMPLE directory:
<your Visual LISP directory>\Sample

afact.lsp regarx.lsp
drawline.lsp regdump.lsp
drawline-with-errors.lsp sym-exp.lsp
grafun.lsp timestamp.lsp
hello.lsp tmatrix.lsp
image.lsp Unload-VL-app.lsp
LispData1.lsp yinyang.lsp
LispData2.lsp
<your Visual LISP directory>\Sample\ActiveX

al-tst.lsp vla-tst.mkp
vla-tst.lsp vla-tst.prj
vla-tst.mkl
<your Visual LISP directory>\Sample\Reactors

acdbex.lsp a-mtext.lsp aap-reg.lsp


copyself.lsp ctie.lsp dimex.lsp
dumbells.lsp editex.lsp getparm.dcl
linkex.lsp objex.lsp pipe.lsp
sel-reac.lsp rctr.lsp rctr-tst.mkl
rctr-tst.mkp rctr-tst.prj reac-tst.prj
r-info.lsp r-init.lsp rolls.lsp
rsame.lsp rtie.lsp rtrans.lsp
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (1 of 11) [23/03/2005 05:59:23 p.m.]
rtransl.lsp rutils.lsp same-rcl.lsp
sel-reac.lsp toplevel.lsp getparm.lsp
Each of the following explanations includes a list of the functions in the sample files as well as the
syntax you should use to call them from the Visual LISP Console prompt. However, function names
preceded by a c: can be called from the AutoCAD command line as well. All other functions must be
called from the Visual LISP Console prompt unless you explicitly export them to AutoCAD as native
AutoLISP functions, at which point you could call them from the AutoCAD command line.
The executable function lists that accompany the sample file explanations follow the syntax as
described here:
Example of a non-exported function:
functionA
Executable syntax:
(functionA arg1 arg2 etc) (from the Visual LISP Console only)
Example of an exported function:
c:functionB
Executable syntax:
(c:functionB) (from the Visual LISP Console or AutoCAD command line)
functionB (from the AutoCAD Command Line only) This syntax will not be included later in this
document; it should be understood as a feature of preceding function names with a "c:".
Visual LISP Samples
afact.lsp
This file defines two functions that use recursion to factorize an integer. Each function requires one
argument which should be an integer between 1 and 31. For example, (fact1 5) returns 120 by calling
fact2 which in turn calls fact1, each time decreasing the value of the argument by 1 and multiplying it by
the product from the previous functions return value.
The range of 1 to 31 is based on a limitation of the ability of AutoLISP and Visual LISP to process any
value outside of its Integer data type range, a 32-bit signed value. The range is between -2,147,483,648
and 2,147,483,647 or -231 X (231 - 1).
However, with regard to the practice of recursion, the limitation on the depth of recursion for this
routine is far more lenient. In the AutoLISP environment, these functions can reach a depth of 144; in
the Visual LISP environment, these functions can reach a depth of 983. The maximum attainable depth
varies by the complexity of the routine.
Executable functions:
fact1
fact2
Executable syntax:
(fact1 n)
The argument n is an integer between 1 and 31.
(fact2 n)
The argument n is an integer between 1 and 31.
drawline.lsp
This sample file is used throughout the documentation to demonstrate Visual LISP concepts and
features. It is the corrected version of the drawline-with-errors.lsp file which this document describes
next.
This routine defines a simple function that draws a line with the AutoCAD LINE command using the
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (2 of 11) [23/03/2005 05:59:23 p.m.]
AutoLISP command function after it asks the user to specify a start point and end point. If the user does
not pass valid coordinate values for the start point and end point prompts, the routine will return a
predefined error message.
Executable functions:
drawline
Executable syntax:
(drawline)
drawline-with-errors.lsp
This file is the same as drawline.lsp, however, it contains deliberate errors. The focus of this routine is
to provide the user with the opportunity to become familiar with Visual LISP debugging tools. This
sample file is referenced in your online Help in:
Developing Programs With Visual LISP
Checking for Syntax Errors
Checking the Balance of Parentheses
Using Color Coding to Detect Syntax Errors
As explained earlier, this routine draws a line with the AutoCAD LINE command using the AutoLISP
command function after it asks the user to specify a start point and end point. The user will first need to
debug the program to make it functional. See Chapter 6 of your on-line Help documentation for
information on Visual LISPs debugging tools.
Executable functions:
drawline
Executable syntax:
(drawline)
grafun.lsp
This file contains two main functions that can be used to compare the speed of calling AutoCAD
commands with the AutoLISP command function verses implementation of ActiveX methods. Both
programs create a 3D mesh and return the time required to complete the task. The al-gf function uses
AutoCAD commands to create the 3D mesh, and the vla-gf function uses ActiveX methods to create the
3D mesh.
You will need to make sure that the User Elapsed Timer is on (see the TIME command in your AutoCAD
on-line Help).
Executable functions:
c:vla-gf (ActiveX methods)
c:al-gf (AutoCAD commands)
Executable syntax:
(c:vla-gf)
(c:al-gf)
Note: The first time an ActiveX function is executed, you may notice less of a speed
improvement than expected because the environment may need to be initialized or
AutoCAD may need to reclaim memory. Subsequent calls using that connection will be
significantly faster than calling AutoCAD commands using the AutoLISP command
function.
hello.lsp
This sample file demonstrates the difference between implicitly and explicitly exporting functions to
AutoCAD and AutoLISP from the Visual LISP environment.
The c:hello command is a Command defined function ("c:") and is therefore implicitly exported to
AutoLISP and can be called from the AutoCAD command line when loaded in Visual LISP.
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (3 of 11) [23/03/2005 05:59:23 p.m.]
The HELLO function passes an argument to a princ expression as the second part of a string that is
printed at the command line. It is called by the hello-autocad function which is explicitly exported to
AutoLISP using the vl-acad-defun function when loaded in Visual LISP.
A significant point that this routine demonstrates is that functions which are exported to AutoCAD or
AutoLISP from Visual LISP are not functions at all. They are simply references to functions which exist
as USUBR routines in the Visual LISP environment. For example, if you open and load hello.lsp in Visual
LISP and then enter (type hello-autocad) at the AutoCAD command line, it will return EXRXSUBR. This
signifies that hello-autocad is contained in an external ARX subroutine (in this case, vlide.arx).
Therefore, when you call the hello-autocad function, it is not being executed in the AutoLISP
environment; it is being executed in the Visual LISP environment.
Executable functions:
c:hello
hello-autocad
hello
Executable syntax:
(c:hello)
(hello-autocad s)
The s argument is the string the user passes to the function.
(hello s)
The s argument is the string the user passes directly when calling the hello function or indirectly
when calling the hello-autocad function. Note that (hello s) is only available from Visual LISP and
not AutoLISP since it was neither implicitly or explicitly exported to AutoLISP.
image.lsp
This sample file demonstrates a workaround for a limitation involving the AutoCAD IMAGE command
where you are not allowed to pass additional arguments when calling it with the AutoLISP command
function within Visual LISP. As an alternative, this file demonstrates how a user can insert an image
using ActiveX methods. A suggested example of executable syntax is included at the end of the
image.lsp file.
Executable functions:
insert-image
Executable syntax:
(insert-image image_file_name insertion_point scale rotation)
For example:
(insert-image ".\\Textures\\3ds.tga" '(0.0 0.0 0.0) 1 0.0)
LispData1.lsp
This sample file demonstrates two examples of the ability of Visual LISP to add and remove
non-graphical data in a drawing using Visual LISP vlax-ldata-xxx extension functions. These functions
are advanced solutions to the standard procedures for adding and removing dictionary data.
Upon executing the function, the routine runs through two examples using the
vlax-ldata-xxx functions. The first example creates and stores data to key "KEY1" in the named object
dictionary that it also creates called "MY-DICT". It then lists the data contained in the key and finishes
by removing the key, but it does not remove the dictionary entry.
The second example creates a Circle object, associates it with key "KEY2" which the routine stores in
the AutoCAD extension Dictionary (ACAD_XDICTIONARY), and lists the extension data which it stored
in that key using the vlax-ldata-put function. It then proceeds to remove the key and finally deletes the
Circle object.
Executable functions:
c:lispdata-test
Executable syntax:
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (4 of 11) [23/03/2005 05:59:23 p.m.]
(c:lispdata-test)
LispData2.lsp
Similar to the second section of LispData1.lsp, this sample file demonstrates the use of non-graphical
data in a drawing by allowing the user to add or change the value of key "LDT" associated with a
graphical object and located in the AutoCAD extension dictionary, using the vlax-ldata-xxx functions.
The "LDT" key value is not set on a selected object until you run the routine once. Afterwards, you can
use the routine to change the value associated with key "LDT" for that object.
Executable functions:
c:ldt
Executable syntax:
(c:ldt)
regarx.lsp
Please note that this description supplements the extensive comments contained in the Regarx.lsp file.
Furthermore, it supersedes the comments in the source code on the function arguments which are
incorrect.
The regarx.lsp sample file demonstrates how to register the Visual LISP IDE ARX application for
demand loading by designated commands. It also provides a thorough explanation of the information
necessary to implement this mechanism since the wrong information in any location of the registry can
completely disable AutoCAD and possibly your operating system. Please back up your registry before
running any commands that edit and change your registry entries.
Regarx.lsp also suggests code on how to unregister command demand loading. The register-VL-app
function defined in this routine is a replica of Visual LISPs vlax-reg-app function. With either of these
functions, you will be able to register the Visual LISP IDE ARX application by designating the correct
parameters for instructing AutoCAD to load the application on demand. The vlax-reg-app function is
more general and can be used to register any application. Please see the Visual LISP documentation for
a description of that function.
The register-VL-app function requires three arguments:
1. app-rp - The application name: a key to be entered in the Registry. It will need to look like this:
"SOFTWARE\\your_application_name"
2. cmds - A quoted list of the commands which you designate for the demand loading of Vlide.arx
when invoked (demand loading requires at least the 4 bit-code value to be set in the loadctrls
parameter below).
3. loadctrls - An integer flag that is equal to the sum of any combination of the following
possibilities (from the ObjectARX Developers Guide):
0 No action taken (do not load the application).
1 Load the application upon detection of proxy object.
2 Load the application upon AutoCAD start-up.
4 Load the application upon invocation of a command (defined in your cmds parameter).
8 Load the application upon request by the user or another application.
16 Do not load the application.
At the end of the file, you will find sample code that passes correct parameters to the register-VL-app
function.
Executable functions:
register-vl-app
Executable syntax:
(register-vl-app "SOFTWARE\\your_app_name
'("[command name]" "[command name]" etc)
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (5 of 11) [23/03/2005 05:59:23 p.m.]
[loadctrls]
)
For example to register Visual Lisp for demand loading:
register-vl-app (strcat "SOFTWARE\\Autodesk\\VisualLISP\\"
(_VLISP-VERSION))
'("Command1" "Command2")
4
)
regdump.lsp
This sample file provides an example of what can be accomplished with Visual LISP registry functions.
The dump-registered-apps function prints out a registry database subtree for every application that is
registered for demand loading in your AutoCAD Release 14 configuration.
One particular expression worth mentioning in the registry-tree-dump function (called by
dump-registered-apps) is the second occurrence of the foreach function which contains a recursive call
to registry-tree-dump. For each application that is registered for demand loading, there are three
subkeys: Commands, Loader, and Name. This particular foreach expression applies the
registry-tree-dump function to the string concatenation of each these three subkeys with the key for
each of the registered applications to build and print out its subtree.
Executable functions:
dump-registered-apps
Executable syntax:
(dump-registered-apps)
sym-exp.lsp
This sample file defines two functions and uses the Visual LISP vl-acad-defun function to explicitly
export them to the AutoLISP environment. Each of these two functions contain only one expression: a
call to one Visual LISP symbol function. These symbol functions, vlisp-import-symbol and
vlisp-export-symbol, are used to copy variables between the Visual LISP environment and the AutoLISP
environment.
It is important to recognize that vl-acad-defun does not actually copy the function to AutoLISP. What it
does is insert a reference to a function which exists as a USUBR routine in the Visual LISP environment.
Therefore, although you call the function in AutoLISP, it is still executed in Visual LISP.
It is also important to notice that the vl-acad-defun expressions appear outside of the defined functions.
If they were inside a non-command line function (no "c:"), it would be impossible to call either of the two
functions in sym-exp.lsp if you compiled it as an ARX routine because the vl-acad-defun expressions
could never be evaluated. Therefore, there are two rules to follow for explicitly exporting functions from
an ARX routine without using a command line function to evaluate vl-acad-defun expressions:
1. The vl-acad-defun expressions must be contained outside of the defined functions.
2. You must select "Initialize in load time" in step 7 of the Application Wizard.
Code is included at the end of the sample file which can be used to test these functions from the
AutoCAD command line.
Executable functions:
vlisp-to-acad-symbol
acad-to-vlisp-symbol
Executable syntax:
(vlisp-to-acad-symbol str)
The str argument represents the name of a variable in quotes.
(acad-to-vlisp-symbol str)
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (6 of 11) [23/03/2005 05:59:23 p.m.]
The str argument represents the name of a variable in quotes.
timestamp.lsp
This program utilizes Editor Reactors to update a "time-stamp" text entity each time the user completes
an instance of the PLOT command. Between the user pressing OK to begin the plotting procedure and
AutoCAD spooling to the plotter, the Editor Reactor fires off the callback function which adds or
updates a time-stamp text entity at a base point of 0,0,0.
This routine ties together several major concepts that other sample files cover individually:
The LDATA functions: Using vlax-ldata-put, it creates a global dictionary named "TIME-STAMP".
This dictionary contains a key named "TEXT-OBJECT" whose value is the "time-stamp" text entity
in the form of a Visual LISP ActiveX Object.
The REGISTRY functions: Using vlax-reg-app, entries are made in the Registry that associates
vlide.arx (the primary Visual LISP module) or whichever ARX application from which you first ran
the Register-Timestamp function in the AutoCAD application. The result is that until you run the
Unregister-Timestamp function, the associated ARX application will automatically be launched
the next time you start AutoCAD regardless of the drawing file that you open.
Furthermore, if you open the drawing in which you registered the Time-Stamp routine without the
associated ARX loaded, you will receive a notification dialog informing you that the required ARX
application is missing.
Please note that if you have already registered other commands to demand load the Visual LISP
IDE, once Register-TimeStamp is run, those commands will no longer demand load the Visual
LISP IDE. To return to other commands for demand loading of vlide.arx, you will have to
re-register your command since the UnRegister-TimeStamp function merely turns off demand
loading but leaves the registered application pointing to TimeStamp.
There is a workaround contained in this sample file which solves an "Object Open for Read" error which
you may receive in connection with associating a callback function with the PLOT command to modify a
graphical entity. The workaround is to add an additional graphical object to the drawing after creating
the object which the callback function modifies. This behavior is documented and explained in the
Visual LISP Readme file.
Executable functions:
c:register-timestamp
c:unregister-timestamp
Executable syntax:
(c:register-timestamp)
(c:unregister-timestamp)
tmatrix.lsp
Upon loading this sample file, it uses ActiveX function calls to draw a line. It then passes the line as a
VLA Object along with a 4 x 4 transformation matrix to the vla-TransformBy function in order to rotate
the line by 90 degrees. The file provides a total of five different matrices which can be used to rotate,
move, or scale the line. To switch to a different matrix, change the variable called in the
vla-TransformBy expression.
The use of matrices can be an excellent shortcut for manipulating graphical objects. Once created, the
code for a matrix can easily be reapplied in other functions. The following documentation can be found
in the Visual LISP online Help in the AutoLISP Function Reference under "nentselp":
The first three columns of the matrix specify scaling and rotation. The fourth column is a translation
vector.
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (7 of 11) [23/03/2005 05:59:23 p.m.]
The functions that use a matrix of this type treat a point as a column vector of dimension 4. The point is
expressed in homogeneous coordinates, where the fourth element of the point vector is a scale factor
that is normally set to 1.0. The final row of the matrix, the vector [M30 M31 M32 M33], has the nominal
value of [0 0 0 1]; it is currently ignored by the functions that use this matrix format. In this convention,
applying a transformation to a point is a matrix multiplication that appears as follows:
This multiplication gives us the individual coordinates of the point as follows:
As these equations show, the scale factor and the last row of the matrix have no effect and are ignored.
It is also noteworthy to mention a Visual LISP function called vlax-tmatrix which will accept a list of four
lists representing a 4 x 4 transformation matrix (each sub-list contains four numbers). Specifically, it will
process the lists, converting each number to a real and then returns the list in a format that is
compatible with ActiveX requirements. The return can then be passed to the vla-TransformBy function.
Executable functions:
none
Executable syntax:
none - simply open and load the file.
unload-VL-app.lsp
When run from the AutoCAD command line, this program ends your Visual LISP session by unloading
the vlide.arx module. Using Visual LISP functions not available in native AutoLISP, it creates a script file
in the Windows System Temp directory with the Visual LISP application path and name (vlide.arx) along
with the ARXUNLOAD command. It then uses the AutoCAD SCRIPT command to run the script.
Executable functions:
c:unvl
Executable syntax:
(c:unvl)
yinyang.lsp
This sample file is referenced throughout the Visual LISP online documentation. It is used as an
example for debugging in Chapter 6, building applications in Chapter 7, and defining some functions in
the Visual LISP AutoLISP Function Reference.
The routine asks for user input and draws a "Yin-Yang" symbol with basic AutoCAD geometry
commands. Using the vl-acad-defun function, it explicitly exports the yinyang function as a native
AutoLISP function so it can be called from within the AutoLISP environment in addition to the Visual
LISP environment. Please see the section on sym-exp.lsp for more information on the use of the
vl-acad-defun function.
Executable functions:
yinyang
Executable syntax:
(yinyang)
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (8 of 11) [23/03/2005 05:59:23 p.m.]
Visual LISP ActiveX Sample
vla-tst.prj
The ActiveX enabled sample programs demonstrate and test the speed enhancements with using the
Visual LISP "vla-" function connections to the ActiveX Object Model versus the conventional AutoLISP
function library. The al-tst function draws 2000 circles and changes their properties by means of the
native AutoLISP functions. The vla-tst function completes the same test using Visual LISP VLAX
functions and ActiveX methods and properties. You will need to make sure that the User Elapsed Timer
is on (see the TIME command in your AutoCAD online Help).
To Run the test:
Build the vla-tst.arx application.
Note: Because the contents of MKP files are dependent on the directory structure of the
system on which they originated, using the vla-tst.mkp file may generate error messages. It
is recommended you select the "New Application Wizard" option under File > Make
Application to create a new MKP file for your system.
There are several options for running the test command functions:
Load the resulting vla-tst.arx file in AutoCAD.
Run the ActiveX test using the vla-tst command.
Run the AutoLISP test using the al-tst command.
Run the native AutoLISP (uncompiled) test by unloading vla-tst.arx, loadingal-tst.lsp in AutoCAD
and using the al-tst command.
Load the vla-tst.prj files into Visual LISP, run the uncompiled vla-tst or al-tst functions from the
AutoCAD Command Line (or (c:vla-tst) and (c:al-tst) from the Visual LISP Console).
Each test prints the elapsed time for the procedure.
Executable functions:
c:vla-tst
c:la-tst
Executable syntax:
(c:vla-tst)
(c:la-tst)
Visual LISP Reactor Samples
Both of these reactor projects build upon Visual LISP code that is covered
in the preceding sample files. However, these two sample projects implement
Visual LISPs reactor functions. At this time, the only other way to accomplish
this in AutoCAD drawings is to write ObjectARX C++ applications.
If you are planning on implementing reactors within your Visual LISP code,
there is important documentation you will need to review in addition to the
sample code in these projects. Please carefully study Lessons 6 and 7 of the
Visual LISP Garden Path Tutorial as well as Chapter 9 in the Visual LISP
online Help documentation.
rctr-tst.prj
This project demonstrates how to create circles of equal radii which lie on a given curve,
have an equal step in distance along the curve, and maintain these relationships when
some of the objects are modified. The project also gives you examples of including DCL
files in your compiled applications, registration of LISP defined commands, and self
registration of an application or command.

Visual Lisp Sample Files


http://www.afralisp.com/vl/addoc.htm (9 of 11) [23/03/2005 05:59:23 p.m.]
Note: Before loading the Rctr-tst project into Visual LISP, you may need to set the Project
properties Build Options for the FAS directory and TMP directories for the appropriate directory
location on your hard drive. Otherwise you may receive this error when attempting to load the
project: ; *** ERROR: in project RCTR-TST: the FAS Directory does not exist: FAS.
There is one minor change which you will need to make in order for this sample code to work.
Please modify the following line in the Getparm.lsp file from:
(setq radius (get-radius (vlax-curve-getStartPoint aCurve)))
to:
(setq radius (get-radius-from-point (vlax-curve-getStartPoint aCurve)))
After loading the source files using the project file rctr-tst.prj, you can start the program using the
RCTR-TST command. This command will prompt you to choose between dialog or prompt mode.
In both cases, you will first select a circle that you have previously drawn before running this
command. Next, you will be asked to determine the circles initial radius, their number and color,
and finally if the reactors will be persistent. If you choose the persistent option, all reactors will be
restored automatically in subsequent drawing sessions (persistent reactors are saved with the
drawing, transient reactors are not). After the command ends, you can change the radii of the
circles, the parameters of the curve, and move the circles or curve all in a dynamic relationship to
each other.
The Rctr-tst project contains no c:RCTR-TST function defined in any of the source files. Instead, it
uses the vlax-add-cmd function and registers this command in the registry.
Note: If you wish to compile this as an application, it is important to note that because the
contents of MKP files are dependent on the directory structure of the system on which they
originated, using the Rctr-tst.mkp file may generate error messages. It is recommended you
select the "New Application Wizard" option under File Make Application to create a new MKP
file for your system.
Executable functions:
rctr-tst
Executable syntax:
(rctr-tst) (from the Visual LISP console only)
rctr-tst (from the AutoCAD command line only)
reac-tst.prj
This project comprises of a host of different functions which provide examples of what can be
accomplished using Reactors. These examples cover each of the four types of Reactors: Linker,
Editor, Database, and Object. For more information on the different reactor types, see Attaching
Reactors to AutoCAD Drawings in Chapter 9 of your Visual LISP online Help.
After opening the reac-tst.prj project, choose the "Load Source Files" button. This process will
print out the associated functions to the AutoCAD Text Window due to the contents of
toplevel.lsp. As you will see in the text window output after loading the source files (which is
included below), each function is associated with another function that will provide information
on how it works. Text Window contents:

To test: SAME-RCL-TST For information: SAME-RCL-INFO


To test: RTRANSL-TST For information: RTRANSL-INFO
To test: ROLLS-TST For information: ROLLS-INFO
To test: PIPE-TST For information: PIPE-INFO
To test: OBJEX-TST For information: OBJEX-INFO
To test: LINKEX-TST For information: LINKEX-INFO
To stop: STOP-LINKEX-TST
To test: EDITEX-TST For information: EDITEX-INFO
To stop: STOP-EDITEX-TST
To test: DUMBELLS-TST For information: DUMBELLS-INFO
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (10 of 11) [23/03/2005 05:59:23 p.m.]
To test: DIMEX-TST For information: DIMEX-INFO
To test: COPYSELF-TEST For information: COPYSELF-INFO
To test: ACDBEX-TST For information: ACDBEX-INFO
To stop: STOP-ACDBEX-TST
To test: A-MTEXT-TEST For information: A-MTEXT-INFO
It is important to load the entire project rather than individual source files because some of the
routines call functions that are defined in other files. Review the following table to see where you
can find examples of specific Reactor types.

Reactors: Linker Editor Database Object


a-mtext.lsp x
acdbex.lsp x
copyself.lsp x x
dimex.lsp x
dumbells.lsp x
editex.lsp x
linkex.lsp x
objex.lsp x
pipe.lsp x x
rolls.lsp x
rtransl.lsp x
same-rcl.lsp x

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Visual Lisp Sample Files
http://www.afralisp.com/vl/addoc.htm (11 of 11) [23/03/2005 05:59:23 p.m.]
Search
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page II.
Scripting objects - Page I
by Stig Madsen, 2003
Windows provides several script engines, most of which are primarily targeted for web development.
Among the engines are JScript, VBScript and PERL. When a script is run by Windows, it is handled by
Windows Script Host (WSH), which invokes the appropriate script engine.
WSH itself provides access to a range of administrative objects and services such as network drives,
the registry and printer connections. We'll only look at one particular object in WSH and only to retrieve
some limited information. Feel free to learn more about WSH and what it can do (especially the Shell
object can be useful).
Another part of scripting is the Script Runtime Library which provides some useful services for any
script or application running in Windows. It contains 3 main objects and we will use one of them to
retrieve information about disk drives via Visual Lisp. The object is called the FileSystemObject. It
provides access to the file system in a way that not only gives information but also offers standard file
manipulation.
The hardest thing about accessing objects outside AutoCAD with Visual Lisp is not using the VLAX- or
VLA-functions. It's knowing where to get the darn objects! If you never read anything about how to
access Excel from Visual Lisp, would you know that the class name to use is "Excel.Application"? Or
that the type library to import would be "Excel9.olb"? Probably not.
It's a lot easier to open VBAIDE, find the reference in Tools->References and check out the path
(actually, anything that has to do with objects is a lot easier in VBA, but don't tell that to anyone).
For accessing simple things like WSH or the Script Runtime Library, we won't import any type libraries -
it's too messy. We'll just create the objects on the fly and use the generic VLAX-INVOKE-METHOD and
VLAX-GET-PROPERTY functions to access them. To create the objects in the first place, we'll use
VLAX-CREATE-OBJECT.
Let's start it by accessing the Windows Script Host. This only runs on Windows 98 or higher, but of
course you are running at least Windows NT or 2000!
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (1 of 7) [23/03/2005 05:59:26 p.m.]
The class name for the WSH object we are interested in is "WScript.Network". So let's assign that object
to a variable:
(setq wscript (vlax-create-object "WScript.Network"))
#<VLA-OBJECT IWshNetwork2 0018ed40>
Now, I haven't figured this out yet, but trying to dump the object on screen reveals nothing of
importance:
Command: (vlax-dump-object wscript T)
; IWshNetwork2: Network Object
; No properties
; Methods supported:
; AddWindowsPrinterConnection (3)
T
It says that the object has no properties and that is not correct. In fact, here are the properties of a
WshNetwork object (again, using the object browser in VBAIDE can reveal these things much better
than Visual Lisp can):
- ComputerName
- UserDomain
- UserName
The methods are primarily used for mapping network drives and connecting to network printers. Feel
free to look them up (just search for WshNetwork on the internet). Here we will simply grab the three
properties for informative reasons.
(cond ((setq wscript (vlax-create-object "WScript.Network"))
(setq pcname (vlax-get-property wscript "ComputerName")
pcdom (vlax-get-property wscript "UserDomain")
pcuser (vlax-get-property wscript "UserName"))
)
So far, so good. Let's try to access the FileSystemObject and see what we can use it for. The class name
to access is "Scripting.FileSystemObject" (you are properly excused if you had to read it to find out):
(setq fso (vlax-create-object "Scripting.FilesystemObject"))
#<VLA-OBJECT IFileSystem3 0cf17148>
Whereas Visual Lisp has some obscure reason not to dump the entire properties/methods of a
WshNetwork object, there is no problem getting the information from the FileSystemObject:
Command: (vlax-dump-object fso T)
; IFileSystem3: FileSystemObject
; Property values:
; Drives (RO) = #<VLA-OBJECT IDriveCollection 0cf009c8>
; Methods supported:
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (2 of 7) [23/03/2005 05:59:26 p.m.]
; BuildPath (2)
; CopyFile (3)
; CopyFolder (3)
; CreateFolder (1)
; CreateTextFile (3)
; DeleteFile (2)
; DeleteFolder (2)
; DriveExists (1)
; FileExists (1)
; FolderExists (1)
; GetAbsolutePathName (1)
; GetBaseName (1)
; GetDrive (1)
; GetDriveName (1)
; GetExtensionName (1)
; GetFile (1)
; GetFileName (1)
; GetFileVersion (1)
; GetFolder (1)
; GetParentFolderName (1)
; GetSpecialFolder (1)
; GetStandardStream (2)
; GetTempName ()
; MoveFile (2)
; MoveFolder (2)
; OpenTextFile (4)
T
That the object only contains a single property is not a mistake. The Drives property is a collection
object that in turn holds information of each and every disk drive connected to the computer.
The vast amount of methods indicate that here we have a rather clever tool if it's file manipulation we're
looking for. Some of the methods could even give the impression that the VL engine uses a
FileSystemObject for many of its own routines:
(vlax-invoke-method fso 'CreateFolder "C:\\newdir")
(vl-mkdir "C:\\newdir)
(vlax-invoke-method fso 'GetBaseName "C:\\autoexec.bat")
(vl-filename-base "C:\\autoexec.bat")
(vlax-invoke-method fso 'CopyFile "C:\\somefile.txt" "C:\\somecopy.txt" :vlax-true)
(vl-file-copy "C:\\somefile.txt" "C:\\somecopy.txt")
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (3 of 7) [23/03/2005 05:59:26 p.m.]
And so on. Of course, some of the methods in the FileSystemObject aren't available in Visual Lisp and
many of the methods return more useful values or objects than their VL equivalents.
For our purpose, we won't use any of the methods. We will be humble and only build a routine to
retrieve information about each drive connected to the PC. For that we need the Drives collection:
(setq drives (vlax-get-property fso 'Drives))
#<VLA-OBJECT IDriveCollection 09529930>
(vlax-dump-object drives T)
; IDriveCollection: Drive Collection Interface
; Property values:
; Count (RO) = 12
; Item (RO) = ...Indexed contents not shown...
; No methods
T
Being a collection object, one would expect at least an Item method. But the dump says there are no
methods. Instead we can use the Item property to retrieve each drive:
(vlax-get-property drives 'Item "C:")
#<VLA-OBJECT IDrive 0956a138>
What's that, you ask. An argument to a property? Yes, is the short answer (for the extended answer, go
pick up some Visual Basic). The argument is the drive letter, with or without a colon, or the drive root
folder (e.g. "C:\\"). But what if we don't know all the drive letters of the drives connected? Well, being a
collection, we can use VLAX-FOR:
(vlax-for n drives
(princ (vlax-get-property n 'driveLetter))
(princ " ")
)
A C D E F G H I O P Q R " "
Wowsers!! Cool stuff. Now we know at least one property of the Drive object, i.e. the kind of object held
by the Drives collection. Let's look at all properties and methods of a Drive object:
(setq myDrive (vlax-get-property drives 'Item "C:"))
#<VLA-OBJECT IDrive 0956a138>
(vlax-dump-object myDrive T)
; IDrive: Drive Interface
; Property values:
; AvailableSpace (RO) = 2118037504
; DriveLetter (RO) = "C"
; DriveType (RO) = 2
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (4 of 7) [23/03/2005 05:59:26 p.m.]
; FileSystem (RO) = "NTFS"
; FreeSpace (RO) = 2118037504
; IsReady (RO) = -1
; Path (RO) = "C:"
; RootFolder (RO) = #<VLA-OBJECT IFolder 09558648>
; SerialNumber (RO) = -922880035
; ShareName (RO) = ""
; TotalSize (RO) = 6.98326e+009
; VolumeName = ""
; No methods
T
Ok, there are no methods (the methods of FileSystemObject are actually ample enough to manipulate
files, folders and drives), but there are lots of properties. There is only one property that is read-write -
it's the label that can also be freely set via Windows Explorer - all the others are read-only. There is one
property, though, that can be used to walk through the entire disk and as such can be used in a custom
built file-manipulation dialog, for example open or save. It's the RootFolder which gives access to all
other folders - and thereby files - on disk. We won't dwelve at how to do this because it's a topic by itself
(there are many sites around that can show recursive filesearch techniques). But there are plenty of
hurdles to deal with before we can build a routine to present all of this wonderful information in a
suitable way.
As you may be much too familiar with, the data types used by ActiveX are not so attractive to work with
in Visual Lisp. Properties for a disk drive show at least three data types that need to be "translated"
before they can be shown in, say, a dialog. They are variants, Boolean and enumerated values.
The latter are really no trouble by themselves - they are simply returned as integers - but we have no
way of accessing ActiveX constants (unless we import a type library where they may be defined), so we
have to invent a way to present them in clear text. The FileSystemObject is explained on many sites (no
less by the company who made the object), so the constants are not hard to get at. You could also enter
VBA, connect to Microsoft Scripting Runtime and check the enums in the object browser. They are:
0 = UnknownType
1 = Removable
2 = Fixed
3 = Remote
4 = CDRom
5 = RAMDisk
In order to convert the integer returned by the DriveType property, we could simply retrieve a textstring
from a list (where n is the integer):
(nth n '("Unknown" "Removable" "Fixed" "Network drive" "CD-Rom" "RAM disk"))
Another, more problematic type, is the variant returned by AvailableSpace, FreeSpace and TotalSize. Try
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (5 of 7) [23/03/2005 05:59:26 p.m.]
retrieve one of the properties and see what it returns:
(setq free (vlax-get-property myDrive 'FreeSpace))
#
Ok, so it's not that problematic. The type 3 indicates that it's a Long. We simply use
VLAX-VARIANT-VALUE to extract the value:
(vlax-variant-value free)
2117771264
Of course, it's probably not a good idea to show it in raw bytes, but divide it by 1024 and you get kBytes,
or divide it by 1024 in the power of 3 to get GigaBytes. The Boolean value of IsReady is in Visual Lisp
returned as :vlax-true or :vlax-false. We could use VL-PRINC-TO-STRING to print the value directly, but
that's not a nice way to present it. Instead we could use a very simple "convertion" (where n is the
Boolean):
(cond ((= n :vlax-true) "Yes")
((= n :vlax-false) "No")
)
Strings are, luckily enough, returned as strings, so we won't bother doing anything about them. To
present the iFolder object, do whatever you like. The code that follows simply accesses the path and
presents it to the user.
The code that follows?? Next page, dude.
Home. Page II.

You are visitor number



Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (6 of 7) [23/03/2005 05:59:26 p.m.]
Search
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Scripting Objects I
http://www.afralisp.com/lisp/script1.htm (7 of 7) [23/03/2005 05:59:26 p.m.]
The AutoLisp/Visual Lisp/VBA
Resource Website
Copyright 1999-Perpetuity by AfraLisp
Home Lisp Tutors Newsletter EuroTech Rubbish Lisp Tips Links Privacy
VBA Tutors Daily Cartoon Books Downloads VBA Tips CAD Vault IntelliCAD
Home. Page I.
Scripting Objects - Page II
Now we can set up a set of routines to access the FileSystemObject, ask it for the Drives, squeeze out every drive
(not literally - you can build a beer-can holder from the CD drive on your own spare time) and read information
on each.
Oh by the way, remember the WScript.Network object we accessed before? Why not include those pieces of
information along with the drives:
(defun getDiskInfo (/ driveList)
;; first access the WScript.Network and find some
;; useful information
(cond ((setq wscript (vlax-create-object "WScript.Network"))
(setq pcname (vlax-get-property wscript "ComputerName")
pcdom (vlax-get-property wscript "UserDomain")
pcuser (vlax-get-property wscript "UserName")
)
;; won't need wscript anymore, so release it
(vlax-release-object wscript)
;; then access the FileSystemObject and proceed if succesfull
(cond ((setq fso (vlax-create-object "Scripting.FilesystemObject"))
;; access the Drives collection
(setq drives (vlax-get-property fso 'Drives))
;; walk thru each drive while collecting information and
;; save each piece of information in a list
(vlax-for n drives
(setq driveList (cons (driveInfo n) driveList))
)
;; release objects in reversed sequence of creation
(vlax-release-object drives)
(vlax-release-object fso)
)
)
)
)
(list pcName pcDom pcUser driveList)
)
(defun driveInfo (driveObj / getProp)
;; each object given to this function represent one disk drive
;; first it checks if the property listed at the end of mapcar
;; is available. If so, it attempts to read the property, well
;; aware that it may fails - so we have to catch all errors on
;; the way. All properties that are not available is given a
;; value of nil
(mapcar
(function
(lambda (driveProp)
(cond ((vlax-property-available-p driveObj driveProp)
(if (not (vl-catch-all-error-p
(setq getProp (vl-catch-all-apply
'vlax-get-property
(list driveObj driveProp)
)
)
)
Scripting Object II
http://www.afralisp.com/lisp/script2.htm (1 of 6) [23/03/2005 05:59:29 p.m.]
)
getProp
)
)
)
)
)
'(DriveLetter Path RootFolder DriveType FileSystem
VolumeName ShareName IsReady TotalSize FreeSpace
AvailableSpace
)
)
)
Running getDiskInfo should print out a list similar to this:
( "DOGA-B243060" "NATMUS" "smd"
(D D: #<VLA-OBJECT IFolder 0158f6b0> 2 NTFS :vlax-true
#<variant 3 2138540032> #<variant 3 6432768> #<variant 3 6432768>)
(C C: #<VLA-OBJECT IFolder 09558648> 2 NTFS :vlax-true #<variant 5 6983262208>
#<variant 3 2117730304> #<variant 3 2117730304>)
(A A: nil 1 nil nil :vlax-false nil nil nil))
Here only three drives are shown (you may have more or less). The properties are in the sequence given by the list
in defun driveInfo: DriveLetter, Path, RootFolder etc
As can be seen from the output, the drive A: was not ready at the time of access, so almost all properties come out
as nil. We have to take that into account when translating the values.
First let's build a routine to show a dialog box and get it ready before translating the values. We'll define it as a
command because this will call all the other routines (including the translation routine that will follow next). For
the DCL setup, look below this routine.
(defun C:DiskInfo ()
;; PUTINFO is a subroutine that will be called each
;; time a disk drive is selected in "drives" list_box
(defun putInfo (sublst)
(set_tile "drivetxt"
(apply
'strcat
(mapcar (function (lambda (prop val)
(strcat "\n" prop "\t" val))
)
'("Drive letter: " "Path: "
"Root folder: " "Drive type: "
"File system: " "Volume name: "
"Shared name: " "Ready: "
"Total space: " "Free space: "
"Available space:"
)
sublst
)
)
)
)
;; get the driveList, translate the values to strings
;; and load the dialog file.
;; remember that the raw info holds three values from
;; WScript.Network in the first 3 places, so do a little
;; turning over to get at the last item which holds all
;; our drives in sublists
(setq info (getdiskInfo)
diskInfo (mapcar 'VBTranslate (reverse (car (reverse info))))
dcl_id (load_dialog "diskinfo.dcl")
)
;; here we just want to make sure that diskInfo holds only strings
;; so we apply a TYPE function to each element and checks if they
;; are all of type STR.
;; also, we won't proceed unless a new dialog can be loaded.
Scripting Object II
http://www.afralisp.com/lisp/script2.htm (2 of 6) [23/03/2005 05:59:29 p.m.]
(cond
((and diskInfo
(apply '= (apply 'append
(mapcar (function (lambda (v) (mapcar 'type v)))
diskinfo)
)
)
(new_dialog "diskInfo" dcl_id)
)
;; setup a list with drive letters - they are the second item
;; in each sublist for each drive
(setq drives (mapcar '(lambda (n) (nth 1 n)) diskInfo))
;; fill out the drive letters
(start_list "drives")
(mapcar 'add_list drives)
(end_list)
;; fill out the information from WScript.Network
(mapcar 'set_tile '("pcname" "pcdom" "pcuser") info)
;; set action when clicking in list_box with drive letter
(action_tile "drives" "(putInfo (nth (atoi $value) diskInfo))")
;; run the show
(start_dialog)
)
)
(princ)
)
// Dialog contents for use with diskinfo.lsp
// diskinfo.dcl
diskInfo : dialog {
label = "DiskInfo";
width = 42;
: boxed_row {
label = "PC info";
: column {
: text { label = "PC name"; }
: text { label = "Domain"; }
: text { label = "User name"; }
}
: column {
: text { key = "pcname"; label = ""; }
: text { key = "pcdom"; label = ""; }
: text { key = "pcuser"; label = ""; }
}
}
: boxed_row {
label = "Drive info";
: column {
: list_box {
key = "drives";
label = "Drives";
}
}
}
: boxed_row {
label = "Details";
: text {
label = "";
key = "drivetxt";
fixed_height = true;
width = 42;
height = 13;
}
Scripting Object II
http://www.afralisp.com/lisp/script2.htm (3 of 6) [23/03/2005 05:59:29 p.m.]
}
ok_button;
}
Now, to the last routine: to translate all values. It could look like this:
(defun VBTranslate (lst / tmp)
;; given a sublist from getDiskInfo, this routine will run
;; thru each item and attempt to translate it to a string
(mapcar (function
(lambda (n)
;; no need to run through this if n is a string
(if (= (type n) 'STR)
n
(cond
;; if n is nil then simply write a hyphen
((not n) "-")
;; if n is variant then get variant type. Because
;; some variant types are not supported, e.g.
;; OLEColor variant type 19, we'll check for valid
;; result.
((= (type n) 'VARIANT)
(if (not (vl-catch-all-error-p
(setq tmp (vl-catch-all-apply
'vlax-variant-value
(list n)
)
)
)
)
;; if the variant value of n is a number, we
;; have got a number of bytes on disk, so show
;; it in Kbytes and Gigabytes.
(if (numberp tmp)
(strcat (rtos (/ tmp 1024.0) 2 0)
" Kb ("
(rtos (/ tmp 1.07374e+009) 2 2)
" Gb)"
)
tmp
)
;; otherwise variant type is not supported
"Type not supported"
)
)
;; this can only be the iFolder object in FSO, so
;; we won't bother to check if Path is a valid
;; property. If the iFolder is not accessible, it
;; will already have been set to nil in
;; defun DRIVEINFO
((= (type n) 'VLA-OBJECT)
;; in FSO this is iFolder
(vlax-get-property n 'Path)
)
;; convert true/false to Yes/No clear text
((= n :vlax-true) "Yes")
((= n :vlax-false) "No")
;; this will most certainly hold the disk type value,
;; so look up it's enum value and convert to clear text
;; if, for some obscure reason, n is not an enum, just
;; convert number to text
((numberp n)
;; check if number is an integer
(cond ((zerop (rem n 1))
(nth n
'("Unknown" "Removable"
Scripting Object II
http://www.afralisp.com/lisp/script2.htm (4 of 6) [23/03/2005 05:59:29 p.m.]
"Fixed" "Network drive"
"CD-ROM" "RAM disk"
)
)
)
(T (rtos n))
)
)
;; n is nothing of the above - just return whatever
;; it evaluates to as a string
(T (vl-princ-to-string n))
)
)
)
)
lst
)
)
If no typos or any other error occurred during this sance, we should get a nice (well, me thinks it's very pretty)
dialog like this:
Click away and enjoy. Ohh, and correct those nasty bugs that most certainly hid themselves while writing this.
Don't know how? Have a look around the site and you are bound to find a tutor on debugging.
Home. Page I.

Scripting Object II
http://www.afralisp.com/lisp/script2.htm (5 of 6) [23/03/2005 05:59:29 p.m.]
You are visitor number

Web afralisp.com
Be it hereby known that all the Coding and Tutorials contained on this here site, together with but not excluding all those other parts and utterances thereunto, shall not be warranted
against all defects, failures and malfunctions as shall occur between now and Thursday afternoon shortly before 2:00 am, during which time AfraLisp will maybe, at no charge to you or
the other person who was here before you, send the Coding or Tutorial to our Programmers, who will emerge from their caves and engage in rituals designed to cleanse the Coding or
Tutorial of evil spirits. This warranty does not cover attractive blonde females (not male) who may happen to visit this site or establishment or whatever you would like to call it.
Please respect the intellectual rights of others, or we will hunt you down and perform nasty things upon your body and appendages!!!
Copyright 1999-Perpetuity by AfraLisp
All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage
Powered by CORBIMITE.com
Scripting Object II
http://www.afralisp.com/lisp/script2.htm (6 of 6) [23/03/2005 05:59:29 p.m.]
Search

Das könnte Ihnen auch gefallen