(defun C:ExplodeAll (/ AllBlocks SolOnly )
(setvar "qaflags" 1)
(setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
(while (/= AllBlocks nil)
(progn
(command "_.explode" AllBlocks "")
(setq AllBlocks (ssget "X" (list (cons 0 "INSERT"))))
);progn
);while
(if (= AllBlocks nil)(alert "All blocks were exploded"))
(setq SolOnly (ssget "X" '((0 . "3DSOLID"))))
(command "_.erase" "all" "R" SolOnly "")
(setvar "qaflags" 0)
(princ)
);end ACISPrep
;;; Quick create anonymous group
(defun c:GP (/ ss1)
(princ "\nSelect objects to create anonymous group:")
(setq ss1 (ssget ":L"))
(if ss1 (command "-group" "create" "*" "" ss1 ""))
(princ)
)
;==============================================================================
; Returns selection set of all entities after passed in entity name
; taken from CAD Cookbook utilities
;==============================================================================
(defun SDG_AFTER (ename / ss)
(setq ss (ssadd)) ;create selection set
(if ename
(while (setq ename (entnext ename))
(ssadd ename ss) ;add entities to set
)
;;; (setq ss (ssget "X")) ;if no last entity, get all
) ;end if
(if (> (sslength ss) 0) ss) ;return nil if no entities
)
;==============================================================================
; Returns last entity, even subentities on polylines
; used to ensure SDG_AFTER skips to the next full entity, not just a subentity
;
; by roy_043 from http://www.theswamp.org/index.php?topic=35626.msg408522#msg408522
;==============================================================================
(defun SDG_GetLast ( / ent newEnt)
(setq ent (entlast))
(while (and
ent
(setq newEnt (entnext ent))
)
(setq ent newEnt)
)
ent
)
;;; example of SDG_after in action (note this routine won't work without subroutines I didn't provide - code ref only
;;; Duplicates objects onto current layer
(defun c:CDL ()
(SDG-ERROR-INIT (list (list
"cmdecho" 0 ;do list of variables to be set/reset
) T) )
(princ "\nCopy-DUPLICATE to current layer\n")
(if (setq ss1 (ssget ":L")) ;if stuff selected
(progn
(setq elst (SDG_GetLast) ;remember last entity
count (sslength ss1)
ss2 (ssadd)
)
(while (> count 0) ;reverse selection set
(ssadd (ssname ss1 (setq count (1- count))) ss2)
) ;end while
(command ".copy" ss2 "" "@" "@") ;copy in same place
(command ".select" (SDG_AFTER elst) "") ;reset previous to new entities since last
) ;end progn
) ;end if
(command "chprop" "P" "" "la" (getvar "clayer") "color" "bylayer" "ltype" "bylayer" "")
(SDG-ERROR-RESTORE)
(princ)
)
...If you use Bricscad then I recommend this version see "ALE_Ss-After" (also for other conditions):Code: [Select](defun SDG_AFTER (ename / ss)
(setq ss (ssadd)) ;create selection set
(if ename
(while (setq ename (entnext ename))
(ssadd ename ss) ;add entities to set
)
;;; (setq ss (ssget "X")) ;if no last entity, get all
) ;end if
(if (> (sslength ss) 0) ss) ;return nil if no entities
)
...
; Marc'Antonio Alessi - original by Rune Wold and Michael Puckett
; Function: ALE_LastEnt
;
; Version 1.01 - 20/12/2004
; Version 1.02 - 06/05/2010 to support Bricscad
;
; Description:
; get the absolute last entity in the database,
; for problems in >=r15 in blocks with attrib, and polylines
;
; Arguments: none
;
; Return Values:
; An entity name;
; otherwise nil, if there are no entities in the current drawing
;
; Example: (setq marker (ALE_LASTENT))
;
(defun ALE_LastEnt ( / EntNam OutVal)
(and
(setq OutVal (entlast))
(while (setq EntNam (entnext OutVal))
(setq OutVal EntNam)
)
)
OutVal
)
; Marc'Antonio Alessi
; Function: ALE_Ss-After
;
; Version 1.01 - 20/12/2004
; Version 1.02 - 30/09/2005
; Version 1.03 - 06/05/2010 to support Bricscad
;
; Description:
; get a selection set of items after EntNam in the database
;
; Arguments: An entity name
;
; Return Values:
; A selection set;
; otherwise nil, if there are no entities after EntNam
;
; Examples:
; (setq marker (ALE_LASTENT)) ...create new entities...
; to include reference entity:
; (command "_.MOVE" (ALE_SS-AFTER marker) marker "" ...)
; Note: NOT valid if marker is a SEQEND of
; blocks with attrib or old polylines (PLINETYPE = 0)
;
; not include reference entity:
; (command "_.MOVE" (ALE_SS-AFTER marker) "" ...)
;
(defun ALE_Ss-After (EntNam / SelSet)
(cond
( (not EntNam) (ssget "_X" '((0 . "~VIEWPORT"))) ); dwg was empty
( (setq EntNam (entnext EntNam)) ;"~VIEWPORT" x Bricscad
(setq SelSet (ssadd EntNam))
(while (setq EntNam (entnext EntNam))
(if (entget EntNam) (ssadd EntNam SelSet))
)
SelSet
)
)
)
it's nothing but a nuisance.why 'nuisance'? it's behavior is easily controlled via PICKSTYLE variable or 'Ctrl+H' shortcut.
(defun vk_CreateGroup
(Name EntsList SelFlag / GroupDic EntName)
(if (and EntsList
(setq GroupDic (cdadr
(member (cons 3 "ACAD_GROUP") (entget (namedobjdict)))
)
)
(not
(and Name (vl-position (cons 3 Name) (entget GroupDic)))
)
(setq EntName (entmakex
(append (list (cons 0 "GROUP")
(cons 100 "AcDbGroup")
(cons 300 "")
(cons 70
(if Name
0
1
)
)
(cons 71 SelFlag)
)
(mapcar (function (lambda (e) (cons 340 e))) EntsList)
)
)
)
(entmod (append (entget GroupDic)
(list (cons 3
(if (null Name)
"*"
Name
)
)
(cons 350 EntName)
)
)
)
)
(if Name
Name
(cdadr
(member (cons 350 EntName) (reverse (entget GroupDic)))
)
)
)
)
I've always wondered this, and have never met someone that can give me an answer. What is the point of groups? I've never seen a point for their use, and when I have had drawings where objects are in a group, it's nothing but a nuisance.I use them a bit for my inhouse application. We do irrigation design and it's nice to have an adjustable "design arc" that moves with the sprinkler block. Also good for tying many small items together.
I've always wondered this, and have never met someone that can give me an answer. What is the point of groups? I've never seen a point for their use, and when I have had drawings where objects are in a group, it's nothing but a nuisance.