vlax-release-object

Discussion in 'AutoCAD' started by Mark Ingram, Apr 21, 2004.

  1. Mark Ingram

    Mark Ingram Guest

    In the function below, shouldn't there be anything released?

    Thanks,
    Mark

    ;;;Insert a block into all PaperSpace Layout Tabs,
    ;;;all at 0,0,0 & 0 deg. rotation
    ;;;by Jeff Mishler, January 2004

    (defun c:ins2tabs ( / lays bname blk newblk)
    (setq lays (vla-get-layouts
    (vla-get-activedocument
    (vlax-get-acad-object)))
    bname (getstring "\nBlock to insert in all Layouts?: ")
    )
    (if (not (tblsearch "block" bname))
    (progn
    (princ "\nBlock not found, please select block: ")
    (setq bname
    (getfiled "Block Selection for Tab Insert" bname "dwg" 0))
    )
    )
    (vlax-for x lays
    (if (not (= "Model" (vla-get-name x)))
    (progn
    (setq blk (vla-get-block x)
    newblk (vlax-invoke-method
    blk
    'insertblock
    (vlax-3d-point
    '(0.0 0.0 0.0))
    bname 1.0 1.0 1.0 0.0))
    ;;; (vla-add (vla-get-layouts
    ;;; (vla-get-activedocument
    ;;; (vlax-get-acad-object))) "Title")
    ;;; (vla-put-layer newblk "Title")
    ;;; uncomment above to place on layer other than the current one
    )
    )
    )
    (princ)
    )
     
    Mark Ingram, Apr 21, 2004
    #1
  2. Mark Ingram

    Jeff Mishler Guest

    Nope.

    After doing a search and reading MANY posts, which you might want to do,
    too, I've found that it all boils down to this simple post made by Luis
    Esquivel on Nov. 6, 2002:

    "All the loadings I do with the following I use vlax-release-object
    vlax-create-object
    vlax-get-or-create-object
    vla-getinterfaceobject

    For the other instances AutoCAD takes care.

    and in short yes.

    Luis Esquivel"

    HTH,
    Jeff
     
    Jeff Mishler, Apr 21, 2004
    #2
  3. Mark Ingram

    Mark Ingram Guest

    Hi Jeff - First, thanks for the reply *and* the code.

    Now that I have you, may I ask a few questions?

    1. I want to force the redefining of the block on insert...
    (vlax-invoke-method LAYOUTNAME 'insertblock
    (vlax-3d-point '(0.0 0.0 0.0)) "stamp-save" 1.0 1.0 1.0 0.0)
    works great, but...
    (vlax-invoke-method LAYOUTNAME 'insertblock
    (vlax-3d-point '(0.0 0.0 0.0))
    (strcat "stamp-save=r:\\cadd\\proto\\stamp-save") 1.0 1.0 1.0
    0.0)
    causes an error. Any suggestions? This redefine works fine with a
    standard insert.

    2. The block I'm trying to insert contains an attribute. Is there an
    additional argument or something I can easily do here? I tried putting a
    simple string after the rotation angle above. Nothing happened, not even an
    error or a returned string at the prompt.

    Thanks,
    Mark
     
    Mark Ingram, Apr 21, 2004
    #3
  4. Mark Ingram

    Jeff Mishler Guest

    see inline comments

    You're welcome!
    Just use the fully qualified path name, it will redefine it:
    (vlax-3d-point '(0.0 0.0 0.0)) "r:\\cadd\\prot\\stamp-save.dwg" 1.0 1.0 1.0
    0.0)
    Nope, you must get the attributes of the insert, if the block has
    attributes, AFTER inserting the block. Then you must cycle through the
    attributes and add the text to the attribute.

    (if (= (vla-get-hasattributes newblk) :vlax-true)
    (progn
    (setq atts (vlax-safearray->list
    (vlax-variant-value
    (vla-getattributes newblk))))
    (if (= (length atts) 1)
    (progn
    (setq att (car atts))
    (vla-put-textstring att textval)
    )
    (progn
    (foreach att atts
    ;;;cycle through and set the textstring for each
    ;;; attribute based on the tagstring value
    )
    )
    )
    )
    )

    Jeff
     
    Jeff Mishler, Apr 21, 2004
    #4
  5. Mark Ingram

    Mark Ingram Guest

    Jeff,

    Thank you very much,
    Mark

     
    Mark Ingram, Apr 21, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.