Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

LISP Help please

242 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: 404
Registered: ‎12-08-2003
Message 2 of 4 (233 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 (187 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: 404
Registered: ‎12-08-2003
Message 4 of 4 (168 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")
)

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.