Jump to content

Recommended Posts

Posted

I have a few Lisps that insert blocks. The Lisp uses the full file path to locate the drawing and then insert. However if a block already exists in the drawing with the same name the Lisp will use the file in the drawing NOT the one defined by the path.

 

If I use the standard insert dialog box and navigate the file and then try to insert I will be promted if I want to redifine it.

 

How can I get this option to redfine in LISP?

Posted

I sometimes use vla-insertblock to insert a block and this always redefines the existing block.

 

PS> Redefine ~ sorry couldn't help it.

Posted

PS> Redefine ~ sorry couldn't help it.

 

You do not miss a trick.:P

Posted
I have a few Lisps that insert blocks. The Lisp uses the full file path to locate the drawing and then insert. However if a block already exists in the drawing with the same name the Lisp will use the file in the drawing NOT the one defined by the path.

 

If I use the standard insert dialog box and navigate the file and then try to insert I will be promted if I want to redifine it.

 

How can I get this option to redfine in LISP?

 

What's exactly what you want?

 

http://www.cadtutor.net/forum/showthread.php?t=40217

http://forums.augi.com/showthread.php?p=1035107

http://forums.augi.com/showthread.php?t=74579&highlight=blockredef

 

http://paracadd.com/lisp/lisp_lst.htm

;;;Redefine a block and update its attributes

;;; *******************************************************************

;;; ATTREDEF.LSP

Posted
I sometimes use vla-insertblock to insert a block and this always redefines the existing block.

 

PS> Redefine ~ sorry couldn't help it.

 

"Redefine" is for rookies :P . seriously thought I don't mind being corrected. That wasn't a type I just spelled it wrong lol

Posted

I tried this

 
(defun C:test ()
(vl-load-com)
(vla-insertblock (getpoint) "L:/DrawingUtilities/F-Part" 1 1 1 0)
)

but I get this error

error: bad argument type: VLA-OBJECT (-85.2136 19.2445 0.0)

Posted

Have you looked at the reference in the Visual LISP Help file?

 

InsertBlock method

 

Arguments:

 

Object: ModelSpace, PaperSpace, Block

The objects this method applies to.

 

InsertionPoint: Variant (three-element array of doubles); input-only

The 3D WCS coordinates specifying the location in the drawing to insert the block.

 

Name: String; input-only

The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include the .dwg extension and any path information necessary for AutoCAD to find the file.

 

Xscale: Double; input-only; optional

The default equals 1.0. Must be a positive number.

 

Yscale: Double; input-only; optional

The default equals 1.0. Must be a positive number.

 

Zscale: Double; input-only; optional

The default equals 1.0. Must be a positive number.

 

Rotation: Double; input-only; optional

The default equals 0.0 radians.

 

Password: Variant; input-only; optional

 

__________________________________________________

 

Return Value: BlockRef object

The placed block as a Block Reference object.

 

Posted

You will need to provide the Block VLA-Object into which you wish to insert the block (i.e. Model/Paper Space, Block definition).

 

And the Point will need to be a Variant.

 

As an example:

 

(defun InsertBlock (bNme Pt)
 (vl-load-com)
 ;; Lee Mac  ~  05.03.10

 (vla-InsertBlock
   (if (eq acPaperSpace
           (vla-get-ActiveSpace
             (setq doc (vla-get-ActiveDocument
                         (vlax-get-acad-object)))))
     
     (if (eq :vlax-true (vla-get-MSpace doc))
       (vla-get-ModelSpace doc)
       (vla-get-PaperSpace doc))

     (vla-get-ModelSpace doc))

   (vlax-3D-point Pt) bNme 1. 1. 1. 0.))



(defun c:test (/ iPt file)

 (if (and (setq iPt  (getpoint "\nPick point for Block: "))
          (setq file (findfile "L:\\DrawingUtilities\\F-Part.dwg")))
   
   (InsertBlock file iPt))

 (princ))

Posted

i did look at the help files and I thought I had done it right. i'm going to go through the afralisp VLisp tutorials. Seeing you guys use all the vl- stuff makes me jealous :lol:.

 

Ijust did the "Beginning" tutorial and I think it just blew my mind.

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