Results 1 to 4 of 4

Thread: Help with using wblock command in AutoLisp format.

  1. #1
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Help with using wblock command in AutoLisp format.

    When I ceate a block using WBLOCK in LISP format my original objects that make-up a block get erased.

    I am trying to create a block using (command "-wblock").
    First I am prompted - Enter name of output file: I enter C:/AcadTemp/Spool/TEST.dwg
    Second I am prompted - [= (block=output file) * (whole drawing)] <define new drawing>: I select "" to enter define new drawing
    Specify insertion basse point - I specify insertion point
    Then I get a selection box and select items.
    Finally the block is created...however all of the objects in my modelspace that made-up a block are deleted.
    How can I avoid that, how can I tell LISP to retain information inside the modespace.

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Help with using wblock command in AutoLisp format.

    Found one from my very oldies, not tested
    Try to use on your own, select objects one by another
    Code:
    (vl-load-com)
    (defun C:wblock-test  (/ adoc en ent pfss ss)
    
      (setq	adoc (vla-get-activedocument
    	       (vlax-get-acad-object)
    	       )
    	)
      (sssetfirst)
      (setq ss (ssadd))
      (while
        (setq ent (entsel))
         (ssadd (car ent) ss)
         )
      (princ (strcat "\nВыбрано: " (itoa (sslength ss))))
      (setq pfss (vla-get-pickfirstselectionset adoc))
      
      (while (setq en (ssname ss 0))
        (vlax-invoke
          pfss
          'AddItems
          (list (vlax-ename->vla-object en)))
        (ssdel en ss))
      (vlax-invoke
        adoc
        'Wblock
        (strcat (getvar "dwgprefix") "WBLOCK-TEST.dwg")
        pfss)
      (vla-delete pfss)
      (vlax-release-object pfss)
      (princ)
      )
    (defun C:wbt ()(C:wblock-test)(princ))
    ;;Call:
    (prompt "\nКоманда для выполнения WBT")
    (princ)

  3. #3
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    0

    Default Re: Help with using wblock command in AutoLisp format.

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    ...however all of the objects in my modelspace that made-up a block are deleted.
    How can I avoid that, how can I tell LISP to retain information inside the modespace.
    All you really need to do is have your function undo itself once the wblock operation is complete. The following example illustrates this (note that no error handling and only minimal testing is included):

    Code:
    (defun c:wbtest ( / ACADDOC SELSETS SS SSVL)
      (vl-load-com)
      (setq acaddoc (vla-get-activedocument (vlax-get-acad-object))
    	selsets (vla-get-selectionsets acaddoc)
    	); setq
      (vla-startundomark acaddoc)
      (setq ss (ssget)
    	ssvl (cond ((vl-catch-all-error-p
    		      (setq ssvl (vl-catch-all-apply
    				   'vla-item
    				   (list selectionsets "vlass")
    				   ); vl-catch-all-apply
    			    ); setq
    		      ); vl-catch-all-error-p
    		    (vlax-invoke selsets 'add "vlass")
    		    ); no existing selectionset named "vlass"
    		   (t (progn
    			(vla-delete ssvl)
    			(vlax-invoke selsets 'add "vlass")
    			); progn
    		    ); default
    		   ); cond
    	); setq
      (vlax-invoke ssvl 'select acselectionsetprevious)
      (vlax-invoke acaddoc 'wblock (strcat (getvar "dwgprefix") "wblock-test.dwg") ssvl)
      (vla-delete ssvl)
      (vlax-release-object ssvl)
      (vla-endundomark acaddoc)
      (vl-cmdf "undo" "1")
      (princ)
      ); defun

  4. #4
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Help with using wblock command in AutoLisp format.

    There is an old command for it


    OOPS from the command line , or

    Enter name of existing block or
    [= (block=output file)/* (whole drawing)] <define new drawing>: ""
    Specify insertion base point:
    Select objects: 1 found

    Select objects: 1 found, 2 total

    Select objects:

    Command: (command "oops")
    Last edited by devitg.89838; 2012-07-24 at 10:49 PM. Reason: add an option

Similar Threads

  1. command Circle>Tan Tan Radius Autolisp
    By TUD_DUT in forum AutoLISP
    Replies: 1
    Last Post: 2012-10-23, 09:23 PM
  2. Block command in an AutoLISP script.
    By identity4 in forum AutoLISP
    Replies: 3
    Last Post: 2012-05-22, 04:48 AM
  3. Replies: 10
    Last Post: 2009-10-07, 05:55 PM
  4. WBLOCK command inverts objects
    By jason.cyr13 in forum AutoCAD General
    Replies: 3
    Last Post: 2009-06-29, 09:24 PM
  5. AutoLISP command causes script to stop...
    By FWSchreck in forum AutoLISP
    Replies: 4
    Last Post: 2007-01-20, 12:06 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •