Jump to content


deleting overlapped objects

overlapped objects

2 replies to this topic

#1 Arun Talukdar

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationIndia

Posted 05 April 2012 - 06:26 AM

is there any option for deleting overlapped objects?
Regards,
Arun

#2 SevaM

    Admin

  • Administrators
  • 231 posts

Posted 05 April 2012 - 09:11 AM

Hello Arun,

you can select required object then press Delete. When you click on overlapped objects - you will see list of all objects to select what you need to delete.

#3 RasterTechNZ

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationNew Zealand

Posted 26 April 2012 - 08:12 PM

Hi.

This is a very old LISP that I used to use to delete overlapped lines. Maybe someone can re-write in VB or Java to work in nanoCAD.

Kevin

;#: 77359 S2/AutoLISP
; 31-Mar-90 20:15:25
;Sb: #77244-#CSTRIP.LSP Program
;Fm: Richard Halle 73417,340
;To: Kevin Krebs 76114,1264 (X)
;
;Written by Richard Halle 73417,340.
;
;CUT.LSP Program deletes mulitple lines lying on the same vector. The longer
;line is left, and the shorter one(s) are deleted. Multiple Coincident Lines
;are deleted on the layers selected regardless of whether they are the same
;layer or not. If <M>ultiple or <A>ll Layers are selected, unpredictable
;results as to which layer line remains, may result. To avoid this, select
;<S>ingle layer one at a time.
;
;Minor modifications made to original code. K.Krebs
;
;Main Function
(defun C:CUT (/ pick s1 c1 c2 s data ld1 ld2 r flag t1 lr)
(defun lr ()
(setq s (1+ s))
(prompt (strcat "\r" (itoa s) " Line(s) removed."))
)
(initget 1 "All Single Multiple")
(setq pick
(getkword "\nProcess Lines on <A>ll, <S>ingle, or <M>ultiple Layers? ")
)
(cond
( (= pick "All") (setq s1 (ssget "x" (list (cons 0 "LINE")))))
( (= pick "Single") (setq s1 (layss "LINE")))
( (= pick "Multiple") (setq s1 (mlayss "LINE")))
)
(if s1
(progn
(prompt
(strcat "\n====== " (itoa (sslength s1))
" Line(s) Selected ======\n"
)
)
(setq c1 0 s 0 t1 0)
(while (ssname s1 c1)
(grtext -1 (strcat "Pass: " (itoa (1+ c1)))) ;status in mode area
(setq c2 (1+ c1))
(while (ssname s1 c2)
(setq data (entget (ssname s1 c1)) ;get data for 1st line
ld1 (list (dxf 10 data) (dxf 11 data)) ;start/end points
data (entget (ssname s1 c2)) ;get data for 2nd line
ld2 (list (dxf 10 data) (dxf 11 data)) ;start/end points
r (inline ld1 ld2) ;check 'em
t1 (1+ t1)
)
(grtext -2 (strcat "Test: " (itoa t1))) ;totals in coord. area

(cond
( (= r 1)
(entdel (ssname s1 c1)) ;delete 1st line
(ssdel (ssname s1 c1) s1) ;remove it from selection set
(setq c2 (sslength s1) ;reset c2 to exit from inner loop
flag t ;set "don't increment c1" flag
)
(lr)
)
( (= r 2)
(entdel (ssname s1 c2)) ;delete 2nd line
(ssdel (ssname s1 c2) s1) ;remove it from selection set
(lr)
)
( (null r)
(setq c2 (1+ c2)) ;increment c2
)
)
)
(if (null flag) (setq c1 (1+ c1)))
(setq flag nil)
)
(prompt ".....All done!")
)
)
(grtext)
(redraw)
(princ)
) ;end of c:CUT function

;Function checks which, if either, line is within the other
;L1 and L2 parameters are lists that contain the start and end
;points of a line.
;Returns either nil if lines are not colinear or either 1 or 2
;indicating that the lines are colinear and that the numbered one
;can be deleted.
(defun inline (l1 l2 / a1 flip long short ret pfix)
(defun pfix (p)
(if (> (caar p) (caadr p)) (setq p (list (cadr p) (car p))))
(if (> (cadar p) (cadadr p)) (setq p (list (cadr p) (car p))))
p
)
(setq l1 (pfix l1) l2 (pfix l2))
(if
(equal (setq a1 (angle (car l1) (cadr l1)))
(angle (car l2) (cadr l2))
0.0001
)
(progn
(if (> (distance (car l1) (cadr l1)) (distance (car l2) (cadr l2)))
(setq long l1 short l2)
(setq long l2 short l1 flip t)
)
(if
(and
(or (equal (car long) (car short))
(equal a1 (angle (car long) (car short)) 0.0001)
)
(>= (distance (car long) (cadr long))
(distance (car long) (cadr short))
)
)
(if flip (setq ret 1) (setq ret 2))
)
)
(setq ret nil)
)
ret
)

;Function to get entities on various layers by letting user
;pick sample entities on the desired layers.
;Type parameter is for entity type ("LINE" in this case).
;It returns a selection set.
(defun mlayss (type / ss lyr c st x ll)
(prompt "\nPick Sample Entities on the Layers You Want to Process.")
(setq ss (ssget))
(if ss
(progn
(setq c 0 ll '())
(repeat (sslength ss)
(setq lyr (dxf 8 (entget (ssname ss c))))
(if (not (member lyr ll)) (setq ll (cons lyr ll)))
(setq c (1+ c))
)
(setq ss nil ss (ssadd))
(foreach x ll
(setq st (ssget "x" (list (cons 0 type) (cons 8 x)))
c 0
)
(if st
(repeat (sslength st)
(ssadd (ssname st c) ss)
(setq c (1+ c))
)
)
(setq st nil)
)
)
)
ss
)

;Function to get entities on a single layer.
;Type parameter is for entity type ("LINE" in this case).
;Return a selection set.
(defun layss (type / lyr e)
(setq lyr (getstring "\nEntity Layer (Press <ENTER> to point)? "))
(if (= lyr "")
(progn
(while (not e) (setq e (entsel "\nPick Entity on Desired Layer: ")))
(setq lyr (dxf 8 (entget (car e))))
)
)
(ssget "x" (list (cons 0 type) (cons 8 lyr)))
)

(defun dxf (key data) (cdr (assoc key data)))

(prompt "CUT.LSP loaded.... Enter CUT to run!")
(princ)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users