Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
haynesc87
Posts: 43
Registered: ‎02-05-2011
Message 1 of 4 (231 Views)

LISP Help please

231 Views, 3 Replies
08-09-2012 10:38 AM

Hi all

 

I would like a LISP to do the equivilent of the following :

 

qselect .... 

 

Object : Space
Properties: Layer
Operatior: Wildcard

Value: *Mega*

 

Send to Back

 

Could anyone help me with the LISp for this thanks

Chris

 

Distinguished Contributor
tom_brabant
Posts: 397
Registered: ‎12-08-2003
Message 2 of 4 (222 Views)

Re: LISP Help please

08-09-2012 01:29 PM in reply to: haynesc87

Here might be a start. This would send anything on a layer beginning with "Mega" to the back.

(defun c:MegaStarToBack ()
(setq ss (ssget "x"
(list; begin filter
(cons 8 "Mega*")
);end filter
)
)
(command "draworder" ss "" "Back")
)

 

Active Contributor
haynesc87
Posts: 43
Registered: ‎02-05-2011
Message 3 of 4 (176 Views)

Re: LISP Help please

08-13-2012 03:21 AM in reply to: tom_brabant

Hi thanks ...

 

what do the ")" ? mean? ...

 

if i open notepad what exactly do i need to type for the script to work ?

 

iv wrote a script before bujt iv never seen them look like this before ... normally mine look like :

 

VISRETAIN 0
-XREF R *

VISRETAIN 1

QSAVE

CLOSE

 

For example

Thanks

 

 

Distinguished Contributor
tom_brabant
Posts: 397
Registered: ‎12-08-2003
Message 4 of 4 (157 Views)

Re: LISP Help please

08-13-2012 07:47 AM in reply to: haynesc87

Everything from the "(defun" to the final ")" constitute an autolisp function definition. This particular function definition happens to add a new command to an autocad drawing session. I have reposted the contents at bottom, and shortened the new command's name to "tb" for convenience.
One of several ways to make it work is to:
1. Copy the contents and paste them into notepad and save the text file with a ".lsp" extension.
2. Then, in autocad, use the "appload" command to browse to the newly created file and load it into a drawing session.
3. Invoke the command by typing "tb" at the command line.

I might mention that appload also contains a "startup suite" so that frequently used files can be loaded into any drawing session automatically.

(defun c:tb ()
(setq ss (ssget "x"
(list; begin filter
(cons 8 "Mega*")
);end filter
)
)
(command "draworder" ss "" "Back")
)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community