Kenter Posted July 23, 2010 Posted July 23, 2010 I am wondering if there is a way to insert a block from file into an autocad drawing using a LISP script. I already have a script that does a bunch of stuff, but want to add a generic note in at a certian point (lets call it b1). It would idealy be set up in this way: (command "_insert" block from a standard spot in c: click ok insert at point b1 ) Kenter Quote
CADkitt Posted July 23, 2010 Posted July 23, 2010 (defun c:inslogo (/) (command "_.-insert" "logo=logo_new" "y" nil) (princ) ) For this way the file must be in search paths. Logo_new is the file name. Quote
Kenter Posted July 23, 2010 Author Posted July 23, 2010 This is what I used. Just not sure how to have the incertion point at b1... (defun C:bn () (command "INSERT" "c:\\Users\\Kenter\\Desktop\\Arc" "0,0" "" "" "") (princ) ) Quote
Lee Mac Posted July 23, 2010 Posted July 23, 2010 Another example: (defun c:test ( / block point ) (setq block "test.dwg") (setq point '(0.0 0.0 0.0)) (if (setq block (LM:ForceBlockDefinition block)) (entmake (list (cons 0 "INSERT") (cons 2 block) (cons 10 point) ) ) (princ "\n** Block not Found **") ) (princ) ) ;;---------------=={ Force Block Definition }==---------------;; ;; ;; ;; Ensures, if possible, that a block definition is present ;; ;; in a drawing. ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, June 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; block - block name or filename ;; ;;------------------------------------------------------------;; ;; Returns: Block name, else nil ;; ;;------------------------------------------------------------;; (defun LM:ForceBlockDefinition ( block / path ext base ) (vl-load-com) ;; © Lee Mac 2010 (setq path (vl-filename-directory block) ext (vl-filename-extension block) base (vl-filename-base block)) (and (eq "" ext) (setq ext ".dwg")) (or (eq "" path) (setq path (strcat path "\\"))) (cond ( (tblsearch "BLOCK" base) base ) ( (setq block (findfile (strcat path base ext))) (command "_.-insert" block) (command) base ) ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.