Author Topic: Find Min Y Coordinate on a Polyline and insert block  (Read 6000 times)

0 Members and 1 Guest are viewing this topic.

efernal

  • Bull Frog
  • Posts: 206
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #15 on: January 23, 2015, 02:13:52 PM »
your test.dwg contains two LWPOLYLINE, not POLYLINE...

e.fernal

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #16 on: January 23, 2015, 02:16:24 PM »
when in properties is polyline  !!! :-o

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #17 on: January 23, 2015, 02:18:03 PM »
Are you sure that you have the block name in the same directory of the current opened drawing ?

Code: [Select]
(defun c:Test (/ o x e l path)
  (princ "\n Select Polyline ")
  (if (and (setq o (ssget "_+.:S" '((0 . "POLYLINE"))))
           (setq x (ssname o 0))
           (while (and (setq x (entnext x))
                       (member '(0 . "VERTEX") (setq e (entget x)))
                  )
             (setq l (cons (cdr (assoc 10 e)) l))
           )
           (setq path (findfile (strcat (getvar 'DWGPREFIX) "pindiat.dwg")))
      )
    (progn
      (command
        "_.-insert"
        path
        nil
      )
      (if (tblsearch "BLOCK" "pindiat")
        (entmake
          (list
            '(0 . "INSERT")
            (cons 2 "pindiat")
            (cons
              10
              (list
                0.
                (- 14
                   (cadar (vl-sort l
                                   '(lambda (j k) (< (cadr j) (cadr k)))
                          )
                   )
                )
                0.
              )
            )
          )
        )
      )
    )
  )
  (if (not path)
    (alert "Block name is not found in Directory !!")
  )
  (princ)
)

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #18 on: January 23, 2015, 02:24:55 PM »
Gives me the message   (alert "Block name is not found in Directory !!") ,but the lisp is with the block in the same folder ... i can't  understand !

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #19 on: January 23, 2015, 02:29:21 PM »
You need to read what users advise you with every thread and not just copy and paste the codes to use .
Read what I have written above the last routine that I posted .

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #20 on: January 23, 2015, 02:31:19 PM »
I read it .Yes i am sure that i have the block name in the same directory of the current opened drawing

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #21 on: January 23, 2015, 02:36:46 PM »
You need to read what users advise you with every thread and not just copy and paste the codes to use .
Read what I have written above the last routine that I posted .
It's easier to just make the block rather than travel down the rabbit hole LOL.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ o)
  2.   (if (not (tblobjname "block" "pindiat"))
  3.     (progn (entmake '((0 . "BLOCK")
  4.                       (100 . "AcDbEntity")
  5.                       (67 . 0)
  6.                       (8 . "0")
  7.                       (100 . "AcDbBlockReference")
  8.                       (2 . "pindiat")
  9.                       (10 0.0 0.0 0.0)
  10.                       (70 . 0)
  11.                      )
  12.            )
  13.            (entmake '((0 . "LWPOLYLINE")
  14.                       (100 . "AcDbEntity")
  15.                       (67 . 0)
  16.                       (8 . "0")
  17.                       (100 . "AcDbPolyline")
  18.                       (90 . 2)
  19.                       (70 . 128)
  20.                       (43 . 0.0)
  21.                       (38 . 0.0)
  22.                       (39 . 0.0)
  23.                       (10 -8.660870552062988 0.0)
  24.                       (40 . 0.0)
  25.                       (41 . 0.0)
  26.                       (42 . 0.0)
  27.                       (91 . 0)
  28.                       (10 9.859517574310302 0.0)
  29.                       (40 . 0.0)
  30.                       (41 . 0.0)
  31.                       (42 . 0.0)
  32.                       (91 . 0)
  33.                      )
  34.            )
  35.            (entmake '((0 . "LWPOLYLINE")
  36.                       (100 . "AcDbEntity")
  37.                       (67 . 0)
  38.                       (8 . "0")
  39.                       (100 . "AcDbPolyline")
  40.                       (90 . 2)
  41.                       (70 . 128)
  42.                       (43 . 0.0)
  43.                       (38 . 0.0)
  44.                       (39 . 0.0)
  45.                       (10 -8.660870552062988 -2.40)
  46.                       (40 . 0.0)
  47.                       (41 . 0.0)
  48.                       (42 . 0.0)
  49.                       (91 . 0)
  50.                       (10 9.859517574310302 -2.40)
  51.                       (40 . 0.0)
  52.                       (41 . 0.0)
  53.                       (42 . 0.0)
  54.                       (91 . 0)
  55.                      )
  56.            )
  57.            (entmake '((0 . "LWPOLYLINE")
  58.                       (100 . "AcDbEntity")
  59.                       (67 . 0)
  60.                       (8 . "0")
  61.                       (100 . "AcDbPolyline")
  62.                       (90 . 2)
  63.                       (70 . 128)
  64.                       (43 . 0.0)
  65.                       (38 . 0.0)
  66.                       (39 . 0.0)
  67.                       (10 -8.660870552062988 -4.80)
  68.                       (40 . 0.0)
  69.                       (41 . 0.0)
  70.                       (42 . 0.0)
  71.                       (91 . 0)
  72.                       (10 9.859517574310302 -4.80)
  73.                       (40 . 0.0)
  74.                       (41 . 0.0)
  75.                       (42 . 0.0)
  76.                       (91 . 0)
  77.                      )
  78.            )
  79.            (entmake '((0 . "LWPOLYLINE")
  80.                       (100 . "AcDbEntity")
  81.                       (67 . 0)
  82.                       (8 . "0")
  83.                       (100 . "AcDbPolyline")
  84.                       (90 . 2)
  85.                       (70 . 128)
  86.                       (43 . 0.0)
  87.                       (38 . 0.0)
  88.                       (39 . 0.0)
  89.                       (10 -8.660870552062988 -7.20)
  90.                       (40 . 0.0)
  91.                       (41 . 0.0)
  92.                       (42 . 0.0)
  93.                       (91 . 0)
  94.                       (10 9.859517574310302 -7.20)
  95.                       (40 . 0.0)
  96.                       (41 . 0.0)
  97.                       (42 . 0.0)
  98.                       (91 . 0)
  99.                      )
  100.            )
  101.            (entmake '((0 . "LWPOLYLINE")
  102.                       (100 . "AcDbEntity")
  103.                       (67 . 0)
  104.                       (8 . "0")
  105.                       (100 . "AcDbPolyline")
  106.                       (90 . 2)
  107.                       (70 . 128)
  108.                       (43 . 0.0)
  109.                       (38 . 0.0)
  110.                       (39 . 0.0)
  111.                       (10 -8.660870552062988 -9.60)
  112.                       (40 . 0.0)
  113.                       (41 . 0.0)
  114.                       (42 . 0.0)
  115.                       (91 . 0)
  116.                       (10 9.859517574310302 -9.60)
  117.                       (40 . 0.0)
  118.                       (41 . 0.0)
  119.                       (42 . 0.0)
  120.                       (91 . 0)
  121.                      )
  122.            )
  123.            (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
  124.     )
  125.   )
  126.   (princ "\n Select LWPolyline ")
  127.   (if (setq o (ssget "_+.:S" '((0 . "LWPOLYLINE"))))
  128.     (entmake
  129.       (list
  130.         '(0 . "INSERT")
  131.         (cons 2 "pindiat")
  132.         (cons
  133.           10
  134.           (car (vl-sort
  135.                  (mapcar 'cdr (vl-remove-if-not '(lambda (p) (eq (car p) 10)) (entget (ssname o 0))))
  136.                  '(lambda (j k) (< (cadr j) (cadr k)))
  137.                )
  138.           )
  139.         )
  140.       )
  141.     )
  142.   )
  143.   (princ)
  144. )
« Last Edit: January 23, 2015, 03:00:57 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #22 on: January 23, 2015, 02:43:12 PM »
You need to read what users advise you with every thread and not just copy and paste the codes to use .
Read what I have written above the last routine that I posted .
It's easier to just make the block rather than travel down the rabbit hole LOL.

 :-D

Although that I did not open the attached drawings , I think you are using the wrong entity name as I have did in my first post LOL

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #23 on: January 23, 2015, 02:45:21 PM »
You need to read what users advise you with every thread and not just copy and paste the codes to use .
Read what I have written above the last routine that I posted .
It's easier to just make the block rather than travel down the rabbit hole LOL.

 ;D

Although that I did not open the attached drawings , I think you are using the wrong entity name as I have did in my first post LOL

The objects are LWPOLYLINE so your code should work.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #24 on: January 23, 2015, 02:55:45 PM »
Nothing is working and i don't know how. The lisp and the block is in tha same folder but nothing insert in the drawing .. i don't  know  :-o :-o :-o :-o :-o

i use autocad 2010

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #25 on: January 23, 2015, 02:58:30 PM »
Nothing is working and i don't know how. The lisp and the block is in tha same folder but nothing insert in the drawing .. i don't  know  :o :o :o :o :o

i use autocad 2010
Works here  :whistling:
« Last Edit: January 23, 2015, 03:02:23 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #26 on: January 23, 2015, 03:11:17 PM »
ronjonp i ask to insert the block in the point (0,y) y= 14-Min Poly y

pedroantonio

  • Guest
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #27 on: January 23, 2015, 03:17:31 PM »
with this command the block is insert with the other lisp in not working i can not  understand why

Code: [Select]
(Defun c:PINDIAT ()
 (setq dt1 (getpoint "\n insert point :"))
 (command "insert" "*PINDIAT" dt1 "" "0")
)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Find Min Y Coordinate on a Polyline and insert block
« Reply #28 on: January 23, 2015, 03:18:00 PM »
I know what you asked for and Tharwat's code does that. Mine was just an example.

You have all the code to fix this yourself.

Take THIS and replace the same section in the code HERE.

I know I've already said this but you really have to start applying yourself....
« Last Edit: January 23, 2015, 03:28:36 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC