TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: tjuzkj on December 14, 2011, 01:11:08 AM
-
Hello.
I often need to erase the dimensions except the outermost dimensions. The example is as follows.It wastes me a lot of time.
So I want to have a lisp routine to help me to do so efficinently.
I mean if I choose the dimensions ,the inner dimensions will be erased automatically and the two outmost dimensions will be retained。
Who can help me?Thank you!
-
Have you tried using the Filter / QSelect commands. I'd use them on a Window/WPolygon selection over the middle of the drawing, then filter for only Dimensions.
-
I use this little routine
(defun c:cco ()
(setq ocmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(initget "Line Ellipse Arc Circle LWpolyline Text Mtext Hatch Spline Solid 3dsolid Dimension Image Point")
(setq var (getkword "\nLine/Ellipse/Arc/Circle/LWpolyline/Text/Mtext/Hatch/Spline/Solid/3dsolid/Dimension/Image/Point:")
gro (cons 0 var)
ss (ssget (list gro))
)
(setvar "cmdecho" ocmdecho)
(princ "\nThe name of the selection is ss:")
(princ)
)
you can then delete it by using the command erase and calling the selection set "!ss"
at least this is how I do it.. I'm sure there are better ways
-
http://www.theswamp.org/index.php?topic=35028.0
-
LOL as I said there are better ways to do it ^^
-
LOL as I said there are other ways to do it ^^
-
I search out a lisp routine.It do it well.However,I find if the two outmost dimensions contain aligned dimensions,it can not do what
I want to do.Who can modify it?Running this routine needs to load libsub.fas.
(defun c:gps_deldm
(/ entlst i lst n pt1 pt2 ptlst ptx pty ss x xlst y ylst z)
;;;subfunction begins
(defun getapt (lst / i x y)
(setq x (nth 0 lst))
(setq i 1
y (nth i lst)
)
(while (and y (<= (fix (/ (- y x) 280.0)) 0))
(setq i (+ i 1)
y (nth i lst)
)
)
(setq x (last lst))
(setq i (- (length lst) 2)
z (nth i lst)
)
(while (and z (>= (fix (/ (- z x) 280.0)) 0))
(setq i (- i 1)
z (nth i lst)
)
)
(list y z)
)
;;;subfunction ends ---------------------------------
(princ "\n erase dimensions(retain the two outermost dimensions):")
(setq ss (ssget ":L" '((0 . "DIMENSION"))))
(if ss
(progn
(setq entlst (gps->ss-2lst ss))
(foreach n entlst
(setq ptlst (trans (dxf 10 (entget n)) 0 1))
(setq ptx (car ptlst))
(setq pty (cadr ptlst))
(setq xlst (append xlst (list ptx)))
(setq ylst (append ylst (list pty)))
)
(setq xlst (vl-sort xlst '<))
(setq ylst (vl-sort ylst '<))
(setq xlst (getapt xlst))
(setq ylst (getapt ylst))
(setq pt1 (list (+ (car xlst) 100) (+ (car ylst) 100)))
(setq pt2 (list (- (cadr xlst) 100) (- (cadr ylst) 100)))
(setq ss
(ssget
"w"
pt1
pt2
'((-4 . "<OR")
(-4 . "<AND")
(0 . "LEADER")
(-4 . "AND>")
(-4 . "<AND")
(0 . "*DIMENSION*")
(-4 . "AND>")
(-4 . "<AND")
(0 . "INSERT")
(-4 . "<OR")
(2 . "_SECTION")
(2 . "_AXISO")
(2 . "_AXISO#")
(-4 . "OR>")
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(if ss
(command ".erase" ss "")
)
)
)
(gps->error-restore)
)
-
Hi
Just wonder if your outer most dimension is generally longer then most, if it is then i would try filter out the dxf code 42
(42 . dimensionlength) and if anything small then a given dimension unit then erase.
Just a suggestion.
-
Have you tried using the Filter / QSelect commands. I'd use them on a Window/WPolygon selection over the middle of the drawing, then filter for only Dimensions.
X2
-
Hi
Just wonder if your outer most dimension is generally longer then most, if it is then i would try filter out the dxf code 42
(42 . dimensionlength) and if anything small then a given dimension unit then erase.
Just a suggestion.
Good idea, it just might work :-)
<limited testing>
(defun c:DimGone (/ ss dm_lst ent ang compare)
(defun _dxf (dx en)
(cdr (assoc dx (entget en)))
)
(setq ss (ssget "_X" '((0 . "DIMENSION"))))
(repeat (sslength ss)
(setq ent (ssname ss 0))
(if (not (setq compare (assoc (setq ang
(rtos (angle (_dxf 10 ent) (_dxf 14 ent)) 2 2)
)
dm_lst
)
)
)
(setq dm_lst (cons (list
ang
(_dxf 42 ent)
ent
)
dm_lst
)
)
(if (> (_dxf 42 ent) (cadr compare))
(progn
(entdel (last compare))
(setq dm_lst (subst (list ang (_dxf 42 ent) ent) compare dm_lst))
)
(entdel ent)
)
)
(ssdel ent ss)
)
(princ)
)
EDIT:(setq dm_lst (subst (list ang (_dxf 42 ent) ent) compare dm_lst)) <---rookie mistake :-D
-
If you're using Acad 2011 (or 2010 with the subsciption advantage pack) you can run select similar on a dimension then isolate the selected dimensions. Then erasing the inner dimensions will likely be nothing more than erasing a crossing selection.
-
POST UPDATED: