Author Topic: intersect line draw  (Read 1483 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
intersect line draw
« on: May 05, 2012, 08:19:55 PM »
sorry sorry for many ask   
really sorry

i am making  patter line
if you see my attached file . you can understand my work
in my work , that pattern is used often
it is difficult  to make that pattern withmy poor lisp skill

pls  can you make me that lisp

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: intersect line draw
« Reply #1 on: May 06, 2012, 07:43:34 AM »
Try this one:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:PatternLine  (/ p1 p2 ss en par baseline dir wid ptlst n pt)
  3.   (if (and (setq p1 (getpoint "Pick 1st point of crossing line: "))
  4.            (setq p2 (getpoint p1 "Pick 2nd point of crossing line: "))
  5.            (setq ss (ssget "_F" (list p1 p2) '((0 . "LWPOLYLINE")))))
  6.     (progn (setq ss       (ssnamex ss)
  7.                  en       (cadar ss)
  8.                  par      (vlax-curve-getParamAtPoint en (cadr (cadddr (car ss))))
  9.                  wid      (/ (- (vlax-curve-getDistAtParam en (1+ (fix par))) (vlax-curve-getDistAtParam en (fix par))) 2.)
  10.                  dir      (apply 'angle
  11.                                  (list (vlax-curve-getPointAtParam en par)
  12.                                        (vlax-curve-getPointAtParam
  13.                                          en
  14.                                          (if (< (- par (fix par)) 0.5)
  15.                                            (fix par)
  16.                                            (1+ (fix par))))))
  17.                  baseline (list (polar p1 dir wid) (polar p2 dir wid))
  18.                  n        0
  19.                  ptlst    (list (car baseline)))
  20.            (foreach lst  ss
  21.              (setq en    (cadr lst)
  22.                    pt    (vlax-curve-getClosestPointTo en (cadr (cadddr lst)) t)
  23.                    p1    (apply 'inters (append baseline (list pt (polar pt dir wid))))
  24.                    p2    (polar p1 dir wid)
  25.                    ptlst (if (= (rem n 2) 0)
  26.                            (cons p2 (cons p1 ptlst))
  27.                            (cons p1 (cons p2 ptlst)))
  28.                    n     (1+ n)))
  29.            (setq ptlst (cons (if (= (rem n 2) 0)
  30.                                (cadr baseline)
  31.                                (polar (cadr baseline) dir wid))
  32.                              ptlst))
  33.            (entmake
  34.              (append '((0 . "LWPOLYLINE") (100 . "AcDbEntity"))
  35.                      (list (cons 67
  36.                                  (if (> (getvar 'CVport) 1)
  37.                                    0
  38.                                    1))
  39.                            (cons 8 (getvar 'CLayer)))
  40.                      '((100 . "AcDbPolyline"))
  41.                      (list (cons 90 (length ptlst)))
  42.                      '((70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0))
  43.                      (apply 'append
  44.                             (mapcar '(lambda (pt) (cons (cons 10 pt) '((40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0))))
  45.                                     (reverse ptlst)))
  46.                      '((210 0.0 0.0 1.0))))))
  47.   (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.