Does any know of a lisp that will insert one block multiple times at the mid point of every line in a drawing. (for example)
|
|
|
Does any know of a lisp that will insert one block multiple times at the mid point of every line in a drawing. (for example)
I have a lisp that insert blocks at the end point of every line in a drawing.
Maybe it can help you.
Thank you Lee Mac.
File Attached
PtManagerV2-4.lsp
Could it be changed to midpoint? I would like to check it out. Thanks Billy
Here an alternative code.
I tried to to keep it simple and not combine to many commands to make it easy to follow along.
You can also modify the program to add multiple lines to a selection set and then do the insert instead of one at a time.
HTHCode:;;; BLI.lsp ;;; ;;; Purpose: To insert a block on a midpoint of a line. (defun C:BLI () (setq ENT NIL) (setq PIC_ENT NIL) (setq BLOCK_TO_INSERT "C:\Users\Owner\Desktop\CROQUI\ST.dwg"); insert the path where your block is (setq BSCALEFACTOR 0.5) (while (null ENT) (setq PIC_ENT (entsel "\n Select Line To Insert Block To: ")) (if (= PIC_ENT NIL) (progn (princ) (exit) ) ) (setq ENT (entget (car PIC_ENT))) (if (= "LINE" (cdr (assoc 0 ENT))) (progn (setq PT1 (cdr (assoc 10 ENT))) ; get start point of line (setq PT2 (cdr (assoc 11 ENT))) ; get endpoint of line (setq RANGLE (angle PT1 PT2)) ; get angle of line (setq DANGLE (RTD RANGLE)) ; convert angle radians to deg (setq LLINE (distance PT1 PT2)) ; gets length of line (setq HOFLINE (/ LLINE 2)) ; lengh of line divided by 2 (setq INSERTPT (polar PT1 RANGLE HOFLINE)) ; set block insertion point (command "-insert" "ST" INSERTPT BSCALEFACTOR BSCALEFACTOR DANGLE ); the name of your block (setq ENT NIL) (setq PIC_ENT NIL) ) (progn (princ "\n *** You need to select a line! ") (setq ENT NIL) ) ) ) ) ;;; RTD ;;; --- ;;; Convert radians to degrees (defun RTD (A) (* A (/ 180 pi))) (princ "\n BLI.slp loaded! Type BLI to start!") (princ)
Last edited by BILLYJOW; 2012-12-05 at 07:28 PM.
lol,,,,Im still trying to understand how to make the first lisp work correctly.
Ive got the block inserting to all points in the drawing but still looking for a way to get it to go to end points of lines. Ill check out this other lisp in a min. thanks for all your help billy.
Try this ...
Code:(defun c:Mins (/ 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 . "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.))) (cdr (assoc 10 e)) (cdr (assoc 11 e)) ) ) (cons 2 name) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) ) ) ) (princ) ) (princ) )
lol,,,,that is cool tharwat!!! The only thing that could make that lisp better is if the block would align with the line. thank you
Like this .... ?
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) )
That is bad a**. lol Very cool. I wish I could write lisps like that. I will have to watch how I draw my lines so the block will rotate the correct direction. Again very cool lisp. thank you