Author Topic: How many spline end to end welded into a spline  (Read 1649 times)

0 Members and 1 Guest are viewing this topic.

Q1241274614

  • Guest
How many spline end to end welded into a spline
« on: January 25, 2013, 11:14:17 PM »
How many spline end to end welded into a spline。
 

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How many spline end to end welded into a spline
« Reply #1 on: January 26, 2013, 05:27:22 AM »
Hi ,

Can you please explain more about your aim of the lisp ? and it would be good to support that with a drawing .  :wink:

Tharwat

Q1241274614

  • Guest
Re: How many spline end to end welded into a spline
« Reply #2 on: January 26, 2013, 06:43:37 AM »
thank!

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How many spline end to end welded into a spline
« Reply #3 on: January 26, 2013, 09:54:19 AM »
Again .

Hi ,

Can you please explain more about your aim of the lisp ?


kruuger

  • Swamp Rat
  • Posts: 637
Re: How many spline end to end welded into a spline
« Reply #4 on: January 26, 2013, 01:42:15 PM »
How many spline end to end welded into a spline。
_JOIN
k.

Q1241274614

  • Guest
Re: How many spline end to end welded into a spline
« Reply #5 on: January 26, 2013, 08:28:03 PM »
(defun c:tt(/ dxf tang chg_ent on_ent undup os 2pi sline sarc scircle n ss ent pmt)
  (defun dxf(ent i)
    (cdr (assoc i (entget ent)))
  )
  (defun tang(ang sty)
    (rem (+ 2pi ang) sty)
  )
  (defun chg_ent(ent i pt / en)
    (setq en (entget ent) en (subst (cons i pt) (assoc i en) en))
    (entmod en)
  )
  (defun on_ent(a a1 a2 sty)
    (if (= sty "直线")
      (equal (+ (distance a1 a) (distance a a2)) (distance a1 a2) 0.01)
      (if (> a2 a1) (>= a2 a a1) (or (<= a a2) (>= a a1)))
    )
  )
  (defun undup(s sty / nm m ss ent1 spt1 ept1 cpt1 r1 ent2 spt2 ept2 cpt2 r2)
    (setq n -1 nm 0)
    (if (= sty "圆")
      (repeat (sslength s)
        (setq ent1 (ssname s (setq n (1+ n))))
        (if (entget ent1)
          (progn
            (setq cpt1 (dxf ent1 10) r1 (dxf ent1 40))
            (if (setq ss (ssget "x" (list (cons 0 "circle") (cons 10 cpt1) (cons 40 r1))))
              (progn
                (ssdel ent1 ss)
                (setq m -1)
                (repeat (sslength ss)
                  (setq ent (ssname ss (setq m (1+ m))))
                  (if (not (ssmemb ent s))
                    (progn
                      (ssdel ent ss)
                      (setq m (1- m))
                    )
                  )
                )
                (command "_.erase" ss "")
                (setq nm (+ nm (sslength ss)))
              )
            )
          )
        )
      )
      (repeat (sslength s)
        (setq ent1 (ssname s (setq n (1+ n))))
        (if (entget ent1)
          (progn
            (if (= sty "直线")
              (setq spt1 (dxf ent1 10) ept1 (dxf ent1 11))
              (setq spt1 (tang (dxf ent1 50) 2pi)
                    ept1 (tang (dxf ent1 51) 2pi)
                    cpt1 (dxf ent1 10)
                    r1 (dxf ent1 40)
              )
            )
            (if (setq ss (if (= sty "直线")
                           (ssget "cp" (list (polar spt1 (angle ept1 spt1) 0.1)
                                             (polar ept1 (- (angle spt1 ept1) (/ pi 4)) 0.15)
                                             (polar ept1 (+ (angle spt1 ept1) (/ pi 4)) 0.15)
                                       ) '((0 . "line"))
                           )
                           (ssget "x" (list (cons 0 "arc") (cons 10 cpt1) (cons 40 r1)))
                         )
                )
              (progn
                (ssdel ent1 ss)
                (setq m -1)
                (repeat (sslength ss)
                  (setq ent (ssname ss (setq m (1+ m))))
                  (if (not (ssmemb ent s))
                    (progn
                      (ssdel ent ss)
                      (setq m (1- m))
                    )
                  )
                )
                (setq m -1)
                (repeat (sslength ss)
                  (setq ent2 (ssname ss (setq m (1+ m))))
                  (if (= sty "直线")
                    (setq spt2 (dxf ent2 10)
                          ept2 (dxf ent2 11)
                    )
                    (setq spt2 (tang (dxf ent2 50) 2pi)
                          ept2 (tang (dxf ent2 51) 2pi)
                          cpt2 (dxf ent2 10)
                          r2 (dxf ent2 40)
                    )
                  )
                  (cond
                    ((and (on_ent spt2 spt1 ept1 sty) (on_ent ept2 spt1 ept1 sty))
                      (entdel ent2)
                    )
                    ((and (on_ent spt1 spt2 ept2 sty) (on_ent ept1 spt2 ept2 sty))
                      (entdel ent1)
                      (setq ent1 ent2 spt1 spt2 ept1 ept2)
                      (if (= sty "圆弧")
                        (setq cpt1 cpt2 r1 r2)
                      )
                    )
                    ((and (if (= sty "直线")
                            (equal (tang (angle spt1 ept1) pi) (tang (angle spt2 ept2) pi) 0.001)
                            T
                          )
                          (or (on_ent spt2 spt1 ept1 sty) (on_ent ept2 spt1 ept1 sty))
                     )
                      (entdel ent2)
                      (if (= sty "直线")
                        (progn
                          (if (on_ent spt2 spt1 ept1 sty)
                            (setq spt2 ept2)
                          )
                          (if (> (distance spt1 spt2) (distance ept1 spt2))
                            (progn (chg_ent ent1 11 spt2) (setq ept1 spt2))
                            (progn (chg_ent ent1 10 spt2) (setq spt1 spt2))
                          )
                        )
                        (if (on_ent spt2 spt1 ept1 sty)
                          (progn (chg_ent ent1 51 ept2) (setq ept1 ept2))
                          (progn (chg_ent ent1 50 spt2) (setq spt1 spt2))
                        )
                      )
                    )
                    (T (setq nm (1- nm)))
                  )
                  (setq nm (1+ nm))
                )
              )
            )
          )
        )
      )
    )
    (prompt (strcat "选到" (itoa (sslength s)) "个" sty "消去" (itoa nm) "个!"))
  )
  (command "_.undo" "_be")
  (command "_.ucs" "")
  (setq os (getvar "osmode")
        2pi (* 2 pi)
        sline (ssadd)
        sarc (ssadd)
        scircle (ssadd)
        n -1
  )
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)
  (prompt "\n请选择直线、圆弧或圆:")
  (if (setq ss (ssget '((0 . "line,arc,circle"))))
    (progn
      (prompt "\n正在消除合并重复线条,请稍候...")
      (prompt "\n")
      (repeat (sslength ss)
        (setq ent (ssname ss (setq n (1+ n))))
        (cond
          ((= (dxf ent 0) "LINE") (ssadd ent sline))
          ((= (dxf ent 0) "ARC") (ssadd ent sarc))
          ((= (dxf ent 0) "CIRCLE") (ssadd ent scircle))
        )
      )
    )
  )
  (if (> (sslength sline) 1) (progn (undup sline "直线") (setq pmt T)))
  (if (> (sslength sarc) 1) (progn (undup sarc "圆弧") (setq pmt T)))
  (if (> (sslength scircle) 1) (progn (undup scircle "圆") (setq pmt T)))
  (if (and ss (not pmt)) (prompt "\n没有重复实体!"))
  (setvar "osmode" os)
  (command "_.undo" "_e")
  (princ)
)



he above only on line, arc, circle, I think you can spline, LWPOLYLINE, ELLIPSE.

xiaxiang

  • Guest
Re: How many spline end to end welded into a spline
« Reply #6 on: January 27, 2013, 09:26:57 PM »
The OP is: How to eliminate or merge duplicate lines including  line, arc, circle and spline, LWPOLYLINE, ELLIPSE

Q1241274614

  • Guest
Re: How many spline end to end welded into a spline
« Reply #7 on: January 28, 2013, 01:02:37 AM »
1 the same type and connected end to end
2 same types of endpoints in another.

1.相同类型首尾相连接
2.相同类型端点在另一个的上面