You're very welcome John .
|
Tharwat,,,Could I bother you one more time?
I have been trying to change your first lisp to insert blocks at points (or nodes). no rotation needed. I have failed over and over.
If you have time could you try it out?
Last edited by Tharwat; 2012-12-07 at 07:39 PM.
Alright thank you... I was making it to complicated.
I am sorry , I forgot to change a few lines of code because I forgot that the first routine insert a block on the center of the selected lines and with points the first insertion point is enough like this ...
Code:(defun c:Test (/ name ss i e) (if (and (or (/= (setq name (getstring t "\n Specify Block name :")) "") (/= name nil) ) (if (not (tblsearch "BLOCK" name)) (progn (alert " name of Block is not found !!") nil ) t ) (progn (prompt "\n Select lines ...") (setq ss (ssget '((0 . "POINT")))) ) ) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (entmakex (list '(0 . "INSERT") (assoc 10 e) (cons 2 name) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) ) ) ) (princ) ) (princ) )
I was so excited to start my new project yesterday because I knew I was going to get the chance to use this cool code you gave me. All I had to do was make sure I drew my lines correctly to get the block to insert and be rotated in the correct direction.
I drew my grid and had all my framing drawn and now its time to insert my block and........What a messssss. Some of my lines where drawn from right to left and that caused my block to be upside down. Some of my vertical lines were drawn from top to bottom and my block inserted to right side of the line. See, I always want my block to either insert ABOVE the mid point of a horizontal line or to the LEFT side of a vertical line.
So I think what I need to do is write some "if-then" into your code. (Sorry, I have no ideal what Im doing, I have this pamphlet called "AutoLisp Quick Start" a guide for lisp rookies)
If the line is 180 degrees then rotate block 180 degrees
if the line is 270 degrees then rotate block 180 degrees
I dont know. I couldnt find my lisp a** with two hands. Tharwat if you have time could you help me right this.
[/QUOTE]Code:(defun c:Mins (/ name ss i e p1 p2) (if (and (or (/= (setq name (getstring t "\n Specify Block name :")) "") (/= name nil) ) (if (not (tblsearch "BLOCK" name)) (progn (alert " name of Block is not found !!") nil ) t ) (progn (prompt "\n Select lines ...") (setq ss (ssget '((0 . "LINE")))) ) ) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (entmakex (list '(0 . "INSERT") (cons 10 (mapcar (function (lambda (q p) (/ (+ q p) 2.))) (setq p1 (cdr (assoc 10 e))) (setq p2 (cdr (assoc 11 e))) ) ) (cons 2 name) (cons 50 (angle p1 p2)) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) ) ) ) (princ) ) (princ) )
Just replace the DXF 50 in the code as the following to match if the angle is equal either 180. or 270. put the angle 180. otherwise leave the angle value as it is .
Hope this helps with your request .Code:(cons 50 (if (or (eq (angle p1 p2) pi) (eq (angle p1 p2) (* pi 1.5)) ) pi (angle p1 p2) ) )