Error in a code

Discussion in 'AutoCAD' started by hmsilva, Mar 30, 2005.

  1. hmsilva

    hmsilva Guest

    Hello everyone...

    I'm trying to use this routine

    (defun C:ZOOMALL ( / $acad docs dnum this)
    (vl-load-com)
    (setq $acad (vlax-get-acad-object)
    docs (vla-get-documents $acad)
    this (vla-get-activedocument $acad)
    dnum (vla-get-count docs)
    )
    (vlax-for each docs
    (vla-put-activedocument each)
    (vla-ZoomExtends $acad)
    (vla-save each)
    )
    (vla-put-activedocument this)
    (vlax-release-object docs)
    (vlax-release-object this)
    (vlax-release-object $acad)
    (princ (strcat "\nProcessed " (itoa dnum) " drawings."))
    (princ)
    )


    And I always get this message

    ; error: ActiveX Server returned the error: unknown name: ActiveDocument

    This is an example code...

    Why do I keep on receiving this message?

    Any ideas?

    Thanks to all future responses.

    Regards

    Henrique
     
    hmsilva, Mar 30, 2005
    #1
  2. hmsilva

    Vxc Guest

    At a first glance one of the erros I believe is this line
    (vla-ZoomExtends $acad) ; <--- vla-ZoomExtents is the code because
    "vla-ZoomExtends" does not exist.

    Other thing "vlax-for each docs", each is not defined nor is a command,
    I believe that this is a second error.
    Someone better with VLisp will anwser you Henrique.
     
    Vxc, Mar 30, 2005
    #2
  3. hmsilva

    Shane-W Guest

    I believe that once you switch drawings (activedocument)
    you will need to redifine ...
    $acad
    docs ;incase count changes
    ... as the variable is not carried
    from drawing to drawing.

    also try this
    (vlax-put-property each 'activedocument $acad)
    sometimes "rewording" aline of code works for me
    and stops the error:
    ; error: ActiveX Server returned the error: unknown name: ActiveDocument

    since it is saying it doesnt recognize vla-put-ACTIVEDOCUMENT

    havent tested any of this and good luck
     
    Shane-W, Mar 30, 2005
    #3
  4. hmsilva

    Shane-W Guest

    look in your apropos window
    "vla-ZoomExtends"
    does exist (in acad2000i)
    no documentation for it and i didnt try googling it either, but it is there
     
    Shane-W, Mar 30, 2005
    #4
  5. hmsilva

    hmsilva Guest

    Thanks to you all

    Still receiving errors...

    But still trying...

    Henrique
     
    hmsilva, Mar 31, 2005
    #5
  6. hmsilva

    Shane-W Guest

    (defun C:ZOOMALL ()
    (vl-load-com)
    (setq $acad (vlax-get-acad-object)
    docs (vla-get-documents $acad)
    this (vla-get-activedocument $acad)
    dnum (vla-get-count docs)
    )
    (vlax-for each docs
    (vla-put-activedocument (vlax-get-acad-object) each)
    (vla-ZoomExtents (vlax-get-acad-object))
    (vla-save (vla-get-activedocument (vlax-get-acad-object)))
    )
    (vla-put-activedocument (vlax-get-acad-object) this);******
    (vlax-release-object docs)
    (vlax-release-object this)
    (vlax-release-object $acad)
    (princ (strcat "\nProcessed " (itoa dnum) " drawings."))
    (princ)
    )

    this will make the code work 1 time, fails at the line marked ;******

    you can try (vl-propagate this) that will pu t the var 'this in all dwgs

    good luck
     
    Shane-W, Mar 31, 2005
    #6
  7. hmsilva

    hmsilva Guest

    Thanks Shane-W

    I keep on trying

    Henrique
     
    hmsilva, Mar 31, 2005
    #7
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.