guitarguy1685 Posted March 5, 2010 Posted March 5, 2010 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? Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 I sometimes use vla-insertblock to insert a block and this always redefines the existing block. PS> Redefine ~ sorry couldn't help it. Quote
The Buzzard Posted March 5, 2010 Posted March 5, 2010 PS> Redefine ~ sorry couldn't help it. You do not miss a trick. Quote
gilsoto13 Posted March 5, 2010 Posted March 5, 2010 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 Quote
guitarguy1685 Posted March 5, 2010 Author Posted March 5, 2010 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 . seriously thought I don't mind being corrected. That wasn't a type I just spelled it wrong lol Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 http://forums.augi.com/showthread.php?p=1035107 Wow, my code does get around... Quote
guitarguy1685 Posted March 5, 2010 Author Posted March 5, 2010 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) Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 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. Quote
Lee Mac Posted March 5, 2010 Posted March 5, 2010 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)) Quote
guitarguy1685 Posted March 10, 2010 Author Posted March 10, 2010 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 . Ijust did the "Beginning" tutorial and I think it just blew my mind. 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.