hi Tharwat . I try your code but i use polyline not LWPOLYLINE !!!Remove the LW before the object name Polyline and try again , otherwise upload a sample drawing showing before and after with the block that to be inserted .
(defun C:test ()
(princ "\n Select Polyline ")
(if (setq o (ssget "_+.:S" '((0 . "POLYLINE"))))
(entmake
(list
'(0 . "INSERT")
(cons 2 "*pindiat")
(cons
10
(list 0.
(- 14
(cadar (vl-sort (mapcar 'cdr
(vl-remove-if-not
'(lambda (p) (eq (car p) 10))
(entget (ssname o 0))
)
)
'(lambda (j k) (< (cadr j) (cadr k)))
)
)
)
0.
)
)
)
)
)
)
i put the lisp in the same folder with the block but the block didn't insert :-o
(defun C:test ()
(princ "\n Select Polyline ")
(if (setq o (ssget "_+.:S" '((0 . "POLYLINE"))))
(entmake
(list
'(0 . "INSERT")
(cons 2 "pindiat")
(cons
10
(list 0.
(- 14
(cadar (vl-sort (mapcar 'cdr
(vl-remove-if-not
'(lambda (p) (eq (car p) 10))
(entget (ssname o 0))
)
)
'(lambda (j k) (< (cadr j) (cadr k)))
)
)
)
0.
(command "insert" "*pindiat" dt1 "" "0")
)
)
)
)
)
)
(defun c:Test (/ o path)
(princ "\n Select LWPolyline ")
(if (and (setq o (ssget "_+.:S" '((0 . "LWPOLYLINE"))))
(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 (mapcar 'cdr
(vl-remove-if-not
'(lambda (p) (eq (car p) 10))
(entget (ssname o 0))
)
)
'(lambda (j k) (< (cadr j) (cadr k)))
)
)
)
0.
)
)
)
)
)
)
)
(if (not path)
(alert "Block name is not found in Directory !!")
)
(princ)
)
hi Tharwat . I try your code but i use polyline not LWPOLYLINE !!!
no give me this
-> Select POLYLINE entity :
-> Not a valid POLYLINE...
(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)
)
You need to read what users advise you with every thread and not just copy and paste the codes to use .It's easier to just make the block rather than travel down the rabbit hole LOL.
Read what I have written above the last routine that I posted .
You need to read what users advise you with every thread and not just copy and paste the codes to use .It's easier to just make the block rather than travel down the rabbit hole LOL.
Read what I have written above the last routine that I posted .
You need to read what users advise you with every thread and not just copy and paste the codes to use .It's easier to just make the block rather than travel down the rabbit hole LOL.
Read what I have written above the last routine that I posted .
;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
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 :oWorks here (http://www.theswamp.org/index.php?topic=48717.msg538140#msg538140) :whistling:
i use autocad 2010
(Defun c:PINDIAT ()
(setq dt1 (getpoint "\n insert point :"))
(command "insert" "*PINDIAT" dt1 "" "0")
)