sorting selection sets
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
sorting selection sets

 
Post new topic   Reply to topic    CADForums.net Forum Index -> AutoCAD
Author Message
chuck
Guest





Posted: Wed Nov 10, 2004 11:18 am    Post subject: sorting selection sets Reply with quote

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"

Back to top
Michael Bulatovich
Guest





Posted: Wed Nov 10, 2004 6:31 pm    Post subject: Re: sorting selection sets Reply with quote

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...
Quote:
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"

Back to top
Jeff
Guest





Posted: Thu Nov 11, 2004 2:45 am    Post subject: Re: sorting selection sets Reply with quote

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...
Quote:
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"



Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> AutoCAD All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB