What am i doing wrong?

Discussion in 'AutoCAD' started by ChrisW, Apr 14, 2004.

  1. ChrisW

    ChrisW Guest

    I am not sure what i am doing wrong here but in the function below "i" is
    always set to 2 no matter how many attributes the block has.

    (setq blockobj (vlax-ename->vla-object blockent)
    attriblist (vla-getattributes blockobj)
    attriblist (vlax-variant-value attriblist)
    i (vlax-safearray-get-dim attriblist)
    ret nil
    ) ;_ end of setq
     
    ChrisW, Apr 14, 2004
    #1
  2. ChrisW

    ChrisW Guest

    It was returning "1" but my loop ran twice. Thanks that fixed my problem.
     
    ChrisW, Apr 14, 2004
    #2
  3. ChrisW

    Jeff Mishler Guest

    I'm unsure of why you get 2, as it should be 1. The method
    "getattributes" returns a one dimensional array of attributes. If you
    want to know how many attributes there are, there are two ways to get
    that.

    Either:
    (1+ (- (vlax-safearray-get-u-bound attriblist
    1)(vlax-safearray-get-l-bound attriblist 1)))
    or
    (length (vlax-safearray->list attriblist))

    HTH,
    Jeff
     
    Jeff Mishler, Apr 14, 2004
    #3
  4. ChrisW

    Jeff Mishler Guest

    You're welcome, glad I could help.

    Jeff

     
    Jeff Mishler, Apr 14, 2004
    #4
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.