View Full Version : sorting selection sets
chuck
11-09-2004, 10:18 PM
Why would this not work?
It appears that I can only create three of the four selection sets, the
parent set "ss1" and two out of the three "child" sets. Anyone know what I'm
doing wrong here?
Thanks
____________________________________________________________________________
_____________
(defun c:dimsort ()
(setvar "cmdecho" 0)
(setq ss1 (ssget "X" '((0 . "DIMENSION"))))
; This grabs all dims in drawing.
(setq ssr (ssadd)) ;This creates a new empty selection set.
(setq ssa (ssadd)) ;This creates a new empty selection set.
(setq ssd (ssadd)) ;This creates a new empty selection set.
(setq R (cons 100 "AcDbRadialDimension"))
(setq A (cons 100 "AcDb2LineAngularDimension"))
(setq D (cons 100 "AcDbDiametricDimension"))
;Establish what you are looking for in the selection sets.
(setq index 0)
(repeat (sslength ss1)
(setq dimobj (ssname ss1 index)) ; This grabs one dim object from the
selection set.
(setq dimguts (entget dimobj)) ; This shows the guts of the dim object.
(if (member R dimguts)
(progn (setq ssr (ssadd dimobj ssr))
(setq ss1 (ssdel dimobj ss1))
)
) ;if radial add to ssr remove from ss1
(if (member A dimguts)
(progn (setq ssa (ssadd dimobj ssa))
(setq ss1 (ssdel dimobj ss1))
)
) ;if angularl add to ssa remove from ss1
(if (member D dimguts)
(progn (setq ssd (ssadd dimobj ssd))
(setq ss1 (ssdel dimobj ss1))
)
) ;if diametric add to ssd remove from ss1
(setq index (1+ index))
)
)
;should have four selection sets of dimensions
;one radial "ssr" one angular "ssa"one diametric "ssd"
; and one with all the others "ss1"
Michael Bulatovich
11-10-2004, 05:31 AM
I think you're running into trouble because you are deleting items from the
original selection set
as you go. When you get to a certain point, your counter incrementally grows
to beyond
the number of items left in the selection set and then your call for that
entity data returns nil.
Better to just always use the first item in SS1 as SS1 shrinks, or don't
remove the items from
SS1 until you are finished.
--
MichaelB
www.michaelbulatovich.com
"chuck" <chuck@nospam.wo> wrote in message
news:Anikd.6128$hp3.683394@read2.cgocable.net... Why would this not work? It appears that I can only create three of the four selection sets, the parent set "ss1" and two out of the three "child" sets. Anyone know what
I'm doing wrong here? Thanks
____________________________________________________________________________ _____________ (defun c:dimsort () (setvar "cmdecho" 0) (setq ss1 (ssget "X" '((0 . "DIMENSION")))) ; This grabs all dims in drawing. (setq ssr (ssadd)) ;This creates a new empty selection set. (setq ssa (ssadd)) ;This creates a new empty selection set. (setq ssd (ssadd)) ;This creates a new empty selection set. (setq R (cons 100 "AcDbRadialDimension")) (setq A (cons 100 "AcDb2LineAngularDimension")) (setq D (cons 100 "AcDbDiametricDimension")) ;Establish what you are looking for in the selection sets. (setq index 0) (repeat (sslength ss1) (setq dimobj (ssname ss1 index)) ; This grabs one dim object from the selection set. (setq dimguts (entget dimobj)) ; This shows the guts of the dim object. (if (member R dimguts) (progn (setq ssr (ssadd dimobj ssr)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if radial add to ssr remove from ss1 (if (member A dimguts) (progn (setq ssa (ssadd dimobj ssa)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if angularl add to ssa remove from ss1 (if (member D dimguts) (progn (setq ssd (ssadd dimobj ssd)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if diametric add to ssd remove from ss1 (setq index (1+ index)) ) ) ;should have four selection sets of dimensions ;one radial "ssr" one angular "ssa"one diametric "ssd" ; and one with all the others "ss1"
Compare this code to yours and find the errors of your ways ;-)
(defun c:dimsort (/ A D DIMGUTS DIMOBJ INDEX R); SS1 SSA SSD SSR)
(setvar "cmdecho" 0)
(setq ss1 (ssget "X" '((0 . "DIMENSION"))))
; This grabs all dims in drawing.
(setq ssr (ssadd)) ;This creates a new empty selection set.
(setq ssa (ssadd)) ;This creates a new empty selection set.
(setq ssd (ssadd)) ;This creates a new empty selection set.
(setq R (cons 100 "AcDbRadialDimension"))
(setq A (cons 100 "AcDb2LineAngularDimension"))
(setq D (cons 100 "AcDbDiametricDimension"))
;Establish what you are looking for in the selection sets.
(setq index 0)
(repeat (sslength ss1)
(setq dimobj (ssname ss1 index)) ; This grabs one dim object from
theselection set.
(setq dimguts (entget dimobj)) ; This shows the guts of the dim object.
(if (member R dimguts)
(progn (ssadd dimobj ssr)
(ssdel dimobj ss1)
(setq index (1- index))
)
) ;if radial add to ssr remove from ss1
(if (member A dimguts)
(progn (ssadd dimobj ssa)
(ssdel dimobj ss1)
(setq index (1- index))
)
) ;if angularl add to ssa remove from ss1
(if (member D dimguts)
(progn (ssadd dimobj ssd)
(ssdel dimobj ss1)
(setq index (1- index))
)
) ;if diametric add to ssd remove from ss1
(setq index (1+ index))
)
)
;should have four selection sets of dimensions
;one radial "ssr" one angular "ssa"one diametric "ssd"
; and one with all the others "ss1"
--
Jeff
check out www.cadvault.com
"chuck" <chuck@nospam.wo> wrote in message
news:Anikd.6128$hp3.683394@read2.cgocable.net... Why would this not work? It appears that I can only create three of the four selection sets, the parent set "ss1" and two out of the three "child" sets. Anyone know what I'm doing wrong here? Thanks ____________________________________________________________________________ _____________ (defun c:dimsort () (setvar "cmdecho" 0) (setq ss1 (ssget "X" '((0 . "DIMENSION")))) ; This grabs all dims in drawing. (setq ssr (ssadd)) ;This creates a new empty selection set. (setq ssa (ssadd)) ;This creates a new empty selection set. (setq ssd (ssadd)) ;This creates a new empty selection set. (setq R (cons 100 "AcDbRadialDimension")) (setq A (cons 100 "AcDb2LineAngularDimension")) (setq D (cons 100 "AcDbDiametricDimension")) ;Establish what you are looking for in the selection sets. (setq index 0) (repeat (sslength ss1) (setq dimobj (ssname ss1 index)) ; This grabs one dim object from the selection set. (setq dimguts (entget dimobj)) ; This shows the guts of the dim object. (if (member R dimguts) (progn (setq ssr (ssadd dimobj ssr)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if radial add to ssr remove from ss1 (if (member A dimguts) (progn (setq ssa (ssadd dimobj ssa)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if angularl add to ssa remove from ss1 (if (member D dimguts) (progn (setq ssd (ssadd dimobj ssd)) (setq ss1 (ssdel dimobj ss1)) ) ) ;if diametric add to ssd remove from ss1 (setq index (1+ index)) ) ) ;should have four selection sets of dimensions ;one radial "ssr" one angular "ssa"one diametric "ssd" ; and one with all the others "ss1"
MyLounge.com Site Map
Forum:
Cars,
Cell Phone,
Database,
Games,
Home Improvement,
IT,
Music,
School,
Sports,
Web Design,
Web Server,
Weight Loss
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.