AutoCAD Script - Automatically Select All Entities on Specific Layer

AutoCAD Script - Automatically Select All Entities on Specific Layer

joe.balaneski
Enthusiast Enthusiast
2,066 Views
6 Replies
Message 1 of 7

AutoCAD Script - Automatically Select All Entities on Specific Layer

joe.balaneski
Enthusiast
Enthusiast

I have a script for archiving drawings.  Part of the archiving is it converts all C3D entities to basic AutoCAD entities.  And for whatever reason it brings our existing ground surface contours to the front of everything when the script is run.  It doesn't do that to anything else, just the contours and labels...lol.  It's quite annoying having clients say the drawings look messy.

 

I'm trying to add a line to the script that would grab all the contours and labels after they are lines/text and push them to the back using draw order.

 

If possible is it also able to select all text or mleaders and bring them to the front?

 

I would think this is possible. I was wondering if anyone knew how to code this into a script?

 

Thanks for any help!

0 Likes
2,067 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

Are you asking about a Script per se, by AutoCAD's definition of the word?  That is, a file with .SCR filetype ending, invoked via the SCRIPT command?  Or something else, such as an AutoLisp routine?  What you ask can easily be done in the latter -- I'm not sure about the former, because it would probably involve some AutoLisp function(s), and there are limits to which of those work in Scripts. 

Kent Cooper, AIA
0 Likes
Message 3 of 7

Sea-Haven
Mentor
Mentor

Using ssget you can get at say c-tinn-view layer and all objects on it and the use draw order to send to back.

 

(setq ss (ssget "x" (list (cons 8 "C-tinn-view")))
(command "draworder" ss "" "B")

You can do multi layers if you know them (cons 8 "C-tinn-view,labels1,label2")

0 Likes
Message 4 of 7

joe.balaneski
Enthusiast
Enthusiast

Sorry...I'm completely illiterate when it comes to lisp creation.

 

Do I just put what sea.haven posted into a text file, save it as a .lsp and then tell my AutoCAD script to read that new lisp routine?  Or is there more that is needed for it to function properly as a lisp?

0 Likes
Message 5 of 7

dlanorh
Advisor
Advisor

Are you running an LT version of AutoCAD? If not, then it would be easier to run a lisp than trying to call some lisp code in a script file.

By the way, the reason they come to the front is that in converting entities, you create new entities which automatically come to the front. It's just the way AutoCAD works.

 

And No, just putting @Sea-Haven code into a file won't work as it is missing bits and unless everything you want to move to the back is on layer "C-tinn-view" on your system.

 

How are you "converting" C3D entities. Exploding, Bursting? Posting your script may help someone to provide what you need, be that a lisp or enhanced script.

 

I am not one of the robots you're looking for

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

Civ3D has the export surfaces built in it depends on what is turned on like triangles or contours or both as the export command recognises the current surface style. Out of the box the triangles will go on c-tinn-view.

 

Have a look at the screen shot this is the surfaces settings, yes you can change layer.

0 Likes
Message 7 of 7

joe.balaneski
Enthusiast
Enthusiast

I'm using AECOBJEXPLODE to convert the C3D entities to basic entities.  Below is my script code.  

 

I found turning off FILEDIA makes it run smoother than having to have windows popping up.

 

What I would like to do is right before it switches back to Paper Space is push all my contours and labels to the background and/or bring all our text objects to the front.  

 

Thanks to another post I put on here, I was helped with the loading of lisp routines to remove fields in text objects during the archive process.  We had clients complain our SSM values were all ####.

 

 

 

FILEDIA 0
TILEMODE 1
-AECOBJEXPLODE
Y
C
Y
B
N
N
Y
N
Y
(load"S:/WaterCADstds/NA/CW_EDM/Lisp/FLD2TXT.lsp")
FLD2TXT
ALL

(load"S:/WaterCADstds/NA/CW_EDM/Lisp/R-FIELDS-ALL.lsp")
R-FIELDS-ALL

TILEMODE 0
(load"S:/WaterCADstds/NA/CW_EDM/Lisp/FLD2TXT.lsp")
FLD2TXT
ALL

(load"S:/WaterCADstds/NA/CW_EDM/Lisp/R-FIELDS-ALL.lsp")
R-FIELDS-ALL

EXPORTTOAUTOCAD2013 
FILEDIA 1
CLOSE
Y 
0 Likes