Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Requesting Layer LISP routine

147 views
Skip to first unread message

Scott Davis

unread,
Aug 5, 2004, 12:29:08 AM8/5/04
to
I'm looking for a LISP that does several things with layers. First, I need
to search existing drawings for specific layer names. If they are present,
it checks the color of the layer and changes it if it doesnt meet standards.
If not present, it creates the layer and assigns a color. If there are
layers in the drawing that aren't in the standard list, I need to rename
them to something like FIXME1 so that I know i need to do some additional
clean up.

I know its alot, but figured someone has run into something similar!

TIA

Chip Harper

unread,
Aug 5, 2004, 8:40:47 AM8/5/04
to
Are you looking for assistance to write your own or are you looking for the
finished product?

--

Chip Harper
Autodesk Discussion Group Facilitator

http://home.comcast.net/~hot4cad/

jclaidler

unread,
Aug 5, 2004, 8:42:50 AM8/5/04
to
The code below will create layer '27' if it doesn't exist, then set the color to yellow.


(if (not (tblsearch "LAYER" "27")) (command "LAYER" "N" "27" ""))
(command "-layer" "c" "yellow" "27" "")

Tom Smith

unread,
Aug 5, 2004, 10:12:15 AM8/5/04
to
> (if (not (tblsearch "LAYER" "27")) (command "LAYER" "N" "27" ""))
> (command "-layer" "c" "yellow" "27" "")

Not necessary if you use the layer "make" option -- it will change the
layer's properties is it exists or create if if necessary.

(command "layer" "make" "27" "c" "27" "")

The standards checker in 2004 can be used to check for non-conforming
layers.

jclaidler

unread,
Aug 5, 2004, 11:07:41 AM8/5/04
to
yeah.. that's another way to do it, but with the same result.

Scott Davis

unread,
Aug 5, 2004, 12:10:00 PM8/5/04
to
Thanks guys!

Is there an easy way to build a list, say from an Excel document or TXT
file, that would contain the layer names that would need to be checked?
Something like:

(command "layer" "make" "A-ANNO-DIMS" "c" "1" "")
(command "layer" "make" "A-ANNO-NOTE" "c" "2" "")
(command "layer" "make" "A-ANNO-SYMB" "c" "2" "")
(command "layer" "make" "A-ANNO-TEXT" "c" "3" "")
etc.
etc.

Where the layer names are compiled from a list? Hmmmm...I have an idea. An
Excel table, where:

cell A is (
cell B is command
cell C is "layer"
etc.

Then export the Excel to a TXT file, save as LAYERFIX.lsp I will need to
put the required spaces in the cells...but I think it will work.

Any other ideas? Thanks again for getting me going.

"jclaidler" <nos...@address.withheld> wrote in message
news:12587270.109171849...@jiveforum1.autodesk.com...

Scott Davis

unread,
Aug 5, 2004, 12:15:20 PM8/5/04
to
A little of both...I can write some code, or if someone has something
similar, I could borrow that. If someone is willing to share a finished
product, well that would be cool too!

"Chip Harper" <hot...@hotmail.com> wrote in message
news:41122acb$1_2@newsprd01...

j.buzbee

unread,
Aug 5, 2004, 3:34:07 PM8/5/04
to
What I use is a drawing as the database ( when it comes to resident AutoCAD
objects I don't see why people go to outside databases???). Here's how it
works:

In the "Standard" drawing I have all the layers I'm ever going to use.
Using the Layer State Manager object I've saved all the combinations of
those layers ( architecture: floor plan, reflected ceiling plan, etc. )
From the active document I can access the "standard" drawing using the
ObjectDBX activex object. I make two lists: one of the layers in the active
document and one from the standard drawing then compare. This appliqué
allows one to easily mange standard layers in an AutoCAD environment while
being easily accessed by other users. This approach could easily be
tailored to your needs.

What you'll need:
A collection of routines to "open" and "close" a dbx document. ( do a
search - Tony T. has some excellent examples)
A collection of routines for manipulating the Layer State object. ( the
AutoCAD help has some examples )
Some simple routines for manipulating layers in the active document. (
believe it or not I use "command -layer . . .")

Believe me, EVERYTHING you need to write this yourself is on the net.
You'll find a number of fishermen (fisherpersons?) willing to show you how
to catch the big fish but very few fish mongers willing to give you a fish.

jb

p.s. I've written some very powerful programs with the help of individuals
on the NG ( thanks again guys! )

"Scott Davis" <scott@wlc-architects*nospam*.com> wrote in message
news:41125ae6_1@newsprd01...

Mack Attack

unread,
Aug 5, 2004, 12:44:55 PM8/5/04
to
Just my $.02 but while you are doing this you might want to add the linetype
in also I had done one similar to what you have below and didn't add
linetypes and sure enough there were a few linetypes that had been changed.


Scott Davis

unread,
Aug 5, 2004, 2:12:01 PM8/5/04
to
Thanks for the help! I'll check it out.

"j.buzbee" <j...@alfonsoarchitects.com> wrote in message
news:411261b4$1_3@newsprd01...

Scott Davis

unread,
Aug 5, 2004, 2:12:42 PM8/5/04
to
cool! good idea, and thanks for the advice!

"Mack Attack" <ma...@mailinator.com> wrote in message
news:411263e3$1_2@newsprd01...

Tom Smith

unread,
Aug 5, 2004, 2:39:40 PM8/5/04
to
As I mentioned, the CAD standards utility which is built into 2004 does
exactly this, and it's standard. Prior to 2004, it was an extension
available to subscription customers. I don't believe in doing custom
programming which duplicates or very nearly duplicates a built-in
capability.

As has been hinted, another way to accomplish the same thing, using a
built-in methodology, is to use the layer manager to export a list of
standard layers from a "clean" drawing. Import this layer state into a
non-standard drawing, and you're done. Existing layers will have all their
properties corrected, missing layers will be created, and the only things
remaining to fix will be the non-standard extraneous layers.

Unless there are very many of these, or hundreds of drawings to process, I
think it ought to be easy enough to spot the nonconforming layers and fix
them manually.


Tom Smith

unread,
Aug 5, 2004, 2:48:24 PM8/5/04
to
> yeah.. that's another way to do it, but with the same result.

What a gracious way of saying "gosh, I didn't know that."

Yeah, it's "another" way, that's shorter, more direct, and devoid of
unnecessary and redundant code, taking advantage of the way the layer
command has always worked.


jclaidler

unread,
Aug 5, 2004, 3:03:19 PM8/5/04
to
But with lisp, it can be done 'behind the scenes' without any need for user input.

Scott Davis

unread,
Aug 5, 2004, 4:09:50 PM8/5/04
to
I checked into the Standards Checker. Seems like this just 'notifies' you
of violations of the standards.....or does it actually fix them? Any
insight into how this works? I thought about the layer manager thing, too.


"Tom Smith" <nospam> wrote in message news:41127eed_1@newsprd01...

Tom Smith

unread,
Aug 5, 2004, 9:42:34 PM8/5/04
to
All we use is the built-in layer manager. We have saved layer states meeting our standards, and a button on a toolbar which simply runs the layer command with the option to import a saved layer state from a file. If a drawing is fouled up, you push a button, ka-ching, you're done. The only programming involved was writing the button macro.

Again, I don't believe in spending time on creating a customization which duplicates a built-in capability. I'm not afraid of writing lisp when the situation requires it, but I don't do it for sport.

The answer to most common questions is to spend more time in the help docs and learn how close the software already comes to meeting your needs. Explore and understand every option of the command-line -LAYER command first. Then tweak it as necessary.

j.buzbee

unread,
Aug 6, 2004, 2:00:57 PM8/6/04
to
So what if your standard layer file has over 700 layers? When you import a
layer state you import all layers instead of only those needed. Sounds like
a sledge hammer when all was needed is a screw driver!

As for programming for sport - just because you lack the capacity to
understand that the true power of AutoCAD is it's open architecture doesn't
mean those who utilize that power are excercising mental masturbation.

just my humble E0.02 (which = about 0.017 USD)

jb


"Tom Smith" <nos...@address.withheld> wrote in message
news:15308601.109175658...@jiveforum1.autodesk.com...

Scott Davis

unread,
Aug 6, 2004, 11:21:21 AM8/6/04
to
Using the layer manager and saved layer states, this will create layers that
are not present? If you have a saved layer state with 100 layers, open a
new file with no layers, and restore the saved layer state, it will create
all 100 layers?


"Tom Smith" <nos...@address.withheld> wrote in message
news:15308601.109175658...@jiveforum1.autodesk.com...

Tom Smith

unread,
Aug 9, 2004, 8:26:35 AM8/9/04
to
> Using the layer manager and saved layer states, this will create layers
that are not present?

Yes, try it.


Tom Smith

unread,
Aug 9, 2004, 8:41:51 AM8/9/04
to
> So what if your standard layer file has over 700 layers?

Mine doesn't, and apparently neither does the OP's. We have several saved
layer states which contain the same list of standard layers, with different
visibility settings appropriate to different tasks. If we needed different
sets of layers for different types of drawings, then I would probably
maintain a standard "clean" version of each drawing type from which to
export its layer state. The OP refered to one standard list of layers, not
multiple possible standard lists.

> When you import a layer state you import all layers instead of only those
needed. Sounds like
> a sledge hammer when all was needed is a screw driver!

The OP wanted to create any layers on his standard list which were missing,
or fix the layer properties if they didn't match standards. If his standard
demanded 700 layers, then I would assume he would want all 700 of them
created. In fact he's asking about 100 layers. He said he wants them all
imported. Sounds like offering the tool that was requested!

> just because you lack the capacity to understand

Offensive and unnecessary.

You proposed that the OP go off on a programming expedition to do something
which, from your description, appears to duplicate the functionality of the
layer states manager, if it were applied to his case. I suggested that he
use the layer states manager as is. If that fails to meet his needs I'm sure
he'll continue looking for a solution. Relax.


j.buzbee

unread,
Aug 9, 2004, 1:23:30 PM8/9/04
to
>>it will create all 100 layers?

Dosn't sound like Scott is too happy with the built-in stuff does it? If
your not up to helping him with writing a customized routine maybe you
should gracefully bow out and let him get some help.

Tom Smith

unread,
Aug 9, 2004, 10:45:24 AM8/9/04
to
> Dosn't sound like Scott is too happy with the built-in stuff does it?

It sounded to me like he is seeking confirmation that importing a layer
state will do what he requested : "create layers that are not present."


Scott Davis

unread,
Aug 9, 2004, 11:36:42 AM8/9/04
to
Guys!

C'mon....eveyone has been helpful! I have found out things I didn't know,
and other ways of thinking about how to do this. There is no right or wrong
way to do this, but definately one way might be faster, cheaper, etc.

I still have one question that originally sparked this, and now I'd like to
know for future reference: Why does Excel add extra quote marks to cells
which contain quotes upon a SaveAs to TXT?

"Tom Smith" <nospam> wrote in message news:41178e04$1_1@newsprd01...

0 new messages