Jump to content

Recommended Posts

Posted

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

Posted

(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.

Posted

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)

)

Posted

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
   )
 )
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...