Thursday
AutoLISP, Download, Programming2 Really Useful AutoLISP Utilities: COPYROT and PICKDEL
Today we added two new AutoLISP application examples to our download section. One of them is COPYROT.LSP. It simply copies the entities that you select and applies the rotate command at the location where they are copied.
;************************************************************ ;* COPYROT.LSP * ;************************************************************ ;* Copies selected objects and rotates them in their new * ;* position. This utility is prepared for instructive * ;* purposes. It's free for use. * ;************************************************************ ;* (c) Copyright 2007 Taliasoft.com * ;* www.dailyautocad.com --- www.taliasoft.com * ;************************************************************ ; Let's define our main function 'cr' and local vars (defun c:cr (/ sel pt) (setq ent 1) ; set ent var to 1 for loop ; Ask user for selection (while (= sel nil) ; wait for selection (princ "\nSelect objects to copyrot:") (setq sel (ssget)) ) ; Copy selected objects on their own position (command "_.COPY" sel "" "0,0" "@") ; Let's move selected opjects (princ "\Please select base point:") (setq pt (getpoint)) (princ "\Select second point:") ; pause waits user for pick second point (command "_.MOVE" "_P" "" pt pause) ; let's rotate copied objects on their new position ; first get LASTPOINT value as rotation base point (setq pt (getvar "LASTPOINT")) (princ "\nPlease enter rotation angle:") (command "_.ROTATE" "_P" "" pt pause) (princ) )
Code.1 Source code of COPYROT.LSP
The other one is PICKDEL.LSP, which deletes the entities that are clicked on.
;************************************************************ ;* PICKDEL.LSP * ;************************************************************ ;* Deletes picked object till user cancel the command * ;* This application is preapered for instructive * ;* purposes. It's free for use. * ;************************************************************ ;* (c) Copyright 2007 Taliasoft.com * ;* www.dailyautocad.com --- www.taliasoft.com * ;************************************************************ ; Let's define our main function 'pd' and local vars (defun c:pd (/ ent ename sel) (setq ent 1) ; set ent var to 1 for loop ; Start pick loop till ent is nil (while (/= ent nil) (setq ent (entsel) ; wait user for pick ename (car ent) ; get entity name sel (ssadd) ; create an empty ss sel (ssadd ename sel) ; pu picked ent into ) (command "._ERASE" sel "") ; Erase selected ent ) (princ) )
Code.2 Source code of PICKDEL.LSP
We are increasing the number of examples as a result of many requests from readers. And sooner you will be able to download them from here free. We are also looking forward to see some applications from our readers. Those who are willing to send us some example applications can send us the application files and their short resume together with a 90×120 portrait.
cr_pd.zip (1.2 KiB, 198 hits)
You need to be a registered user to download this file.
Post Tags: AutoLISP, Downloads
Related Posts
Popular
- Hip tip: Increasing view resolution with VIEWRES system variable
07/03/2009 04:39 am
7 Comments - Sirince – IZMIR
07/02/2009 11:02 am
1 Comment - Visual LISP: Programming user interfaces with OpenDCL
07/01/2009 10:15 pm
10 Comments - 3D Modeling 7: EXTRUDE
06/30/2009 02:14 pm
10 Comments - Ask DailyAutoCAD: Which Notebook to Buy?
06/30/2009 12:17 pm
1 Comment
Featured Articles
- AutoCAD 2009 Update 3 Released
- Speed Up As AutoCAD 2009 Ribbon Menu Helps You!
- MEP Analysis Extension for AutoCAD MEP extended to March 31, 2009
- Recap of AutoCAD-related technologies on Autodesk Labs
- Technology Preview of MEP Analysis Extension extended to 12/31/08
- Autodesk Labs: Forward and Backward utility for AutoCAD
|

Feb 2, 2009
Reply
Hello Orhan,
I have written a function just like your Pickdel function but white the difference that my function use ssget to select the objects to delete. For my opinion this works better because you can select more objects in one time. This is my version:
; Main function ‘pd’
(defun c:pd (/ oldError -cmdecho- $selectedobjects $impliedselection)
(setq -cmdecho- (getvar “CMDECHO”)) ; Save current value for cmdecho
(setvar “CMDECHO” 0) ; Set cmdecho to 0
(setq oldError *Error*) ; Define error handler
(defun *Error* (Melding)
(Prompt Melding)
(setvar “CMDECHO” -cmdecho-)
(setq *Error* oldError)
(princ)
)
(if (setq $impliedselection (ssget “_i”)) ; check if there is a current selection
(progn ; if true delecte selection
(setvar “PICKFIRST” 1)
(command “erase” $impliedselection “”)
)
(progn ; If false start a while function
(while (setq $selectedobjects (ssget “_:s”)) ; While select objects (”_:s” fore single selection)
(command “erase” $selectedobjects “”) ; Erase selected objects
)
)
)
(redraw)
(setvar “CMDECHO” -cmdecho-) ; Reset cmdecho value
(setq *Error* oldError) ; Reset error handler
(princ)
)