vla-add

Discussion in 'AutoCAD' started by Ursus Uziemblo, Jan 25, 2005.

  1. It was only about 15 minutes, but thank you for the
    acknowledgement.

    I'm not sure I understand "into existing container", do you
    mean into the active space (model or paper)?

    At quick glance it appears to me that it should, though you
    would then have to deal with the business of deleting the
    superfluous instance of the block (which can be compounded
    by the resident layer being locked). I felt it a little more
    elegant to go the route of a temporary block definition.

    The only thing I can think of regarding "works correctly and
    exit with error" is that you removed the code that creates
    the temporary block definition but left the code intact that
    deletes said block definition (assuming you modified the
    code I provided).

    It would be helpful if you would post the code you are using
    that does not work. If you post it I'll try to look at it
    this evening (assuming an solution isn't posted by then).

    Cheers.
     
    Michael Puckett, Jan 27, 2005
    #21
  2. In my own experience I found that "\\" won't work with ActiveX. You have to use "/" instead when specifying a file name...
     
    Nick_Merchant, Jan 27, 2005
    #22
  3. Mileages vary -- that's not my experience (tho thanks for
    sharing yours).
     
    Michael Puckett, Jan 27, 2005
    #23
  4. Thanks Michael again
    code is simple (no error check....)

    (setq Blocks (vla-get-blocks (vla-get-activeDocument
    (vlax-get-Acad-object))))

    (setq Block (vla-item Blocks "abc")) ;;it exist in dwg

    (vla-InsertBlock Block (vlax-3d-point 0 0) "D:\\work\\abc.dwg" 1 1 1 0)

    Duplicate definition of block _Open30 ignored.

    Duplicate definition of block GENAXEH ignored.

    ; error: Automation Error. Object was open for write



    2nd problem with Attribute - updated blok has attribute in old place

    can not find a way to find all inserts (in paper space - a lot of layouts)

    search in PaperSpace shows only elements in Active Layout

    how to reach "nonactive")

    Ursus Uziemblo
     
    Ursus Uziemblo, Jan 27, 2005
    #24
  5. Just looking quickly --

    (problem 1) It appears to me that you inserting block "ABC"
    into block "ABC". This creates a circular reference, an illegal
    operation.

    (problem 2) You need to cycle thru all your layouts to find all
    the block instances and then modify said found instances.
    Something like --

    Code:
    
    (defun foo ( document )
    
    (vlax-for block
    
    (vlax-get-property
    document
    'Blocks
    )
    
    (if
    
    (eq :vlax-true
    (vlax-get-property
    block
    'IsLayout
    )
    )
    
    (vlax-for object block
    
    (if
    
    (and
    (eq "AcDbBlockReference"
    (vlax-get-property
    object
    'ObjectName
    )
    )
    (eq "MYBLOCKNAME"
    (vlax-get-property
    object
    'Name
    )
    )
    )
    
    (PerformTaskOnBlockReference object)
    
    )
    )
    )
    )
    )
    
    <Untested>
    
    
     
    Michael Puckett, Jan 27, 2005
    #25
  6. Alternatively using vanilla LISP:

    Code:
    
    (defun foo ( blockName / i ss )
    (if (setq ssget "x" (list '(0 . "insert") (cons 2 blockName)))
    (repeat (setq i (sslength ss))
    (PerformTaskOnEname
    (ssname ss (setq i (1- i)))
    )
    )
    )
    )
    
    
     
    Michael Puckett, Jan 27, 2005
    #26
  7. And vanilla / visual mix --

    Code:
    
    (defun foo ( blockName / i ss )
    (if (setq ssget "x" (list '(0 . "insert") (cons 2 blockName)))
    (repeat (setq i (sslength ss))
    (PerformTaskOnBlockReference
    (vlax-ename->vla-object
    (ssname ss (setq i (1- i)))
    )
    )
    )
    )
    )
    
    
     
    Michael Puckett, Jan 27, 2005
    #27
  8. I should note that more and more of my own code is
    designed with the intent to work with objectdbx
    documents, and as a result, I generally avoid writing
    vanilla / visual hybrid functions like the last two
    posted -- they will not work with said docs. If this
    ng allowed post deletion I'd delete those two posts
    but ever since this ng was "improved" we cannot do that.
     
    Michael Puckett, Jan 27, 2005
    #28
  9. Thanks Michael
    (1) Understand (still work??)
    (2) I will try it - plain lisp I know, was looking for v-lisp
    Thanks - will play with it
    Ursus Uziemblo
     
    Ursus Uziemblo, Jan 27, 2005
    #29
  10. Michael,
    plain lisp searching for INSERT
    but v-lisp is searching for Blockrefereces inside Blocks
    what is collection of block definitions only - no inserts
    inserts for active layout are in PaperSpace
    inserts for nonActive layouts are in ?????
    Ursus Uziemblo
    ps is Sucka mean what I thing? (slovak lang)
    uu
     
    Ursus Uziemblo, Jan 27, 2005
    #30
  11. Sorry Michael for yesterday complains
    I was blind
    You search inside IsLayout=-1
    this is exactly what I'm looking for
    Thanks again

     
    Ursus Uziemblo, Jan 28, 2005
    #31
  12. No problem, glad you are on your way to a solution and
    pleased I was able to assist.
     
    Michael Puckett, Feb 1, 2005
    #32
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.