A Better way than Nentsel to Select an Attribute

Discussion in 'AutoCAD' started by bcbii, Oct 2, 2004.

  1. bcbii

    bcbii Guest

    Hi,

    I am writing a lisp routine that fills in a bunch of stuff on the border
    with user entered information. I am actually editing blocks containing
    attributes on the drawing. I have run into a problem using nentselpt;
    initially the value of this atribute is "-" (without quotes) centered in a
    box. Say the user runs my routine once and changes the attribute to
    "_____1" (where the _ represents a space and there are no quotes). They
    then realize this is wrong and re-run the routine. On the second time
    through with the routine, my routine will crash because I have used
    nentselpt to select the attribute to edit. Since there are spaces in the
    new attribute, right where the nentselpt point is, nothing will be selected,
    and my routine will crash. That is probably as clear as mud, but I was
    wondering if there is a better way to select an attribute within a block for
    editing in a lisp routine?

    Thank you
     
    bcbii, Oct 2, 2004
    #1
  2. bcbii

    fengk Guest

    I don't know why is nentselp necessary here. If you use nentsel to get the ename, then the object. the user should be able to update the string value anytime he wants.
     
    fengk, Oct 2, 2004
    #2
  3. bcbii

    James Allen Guest

    I think it would be better to pick them by their tag values than their
    locations. I would start with vla-getattributes and then filter for the tag
    values you want. The following should get you started.

    (setq enm (car (entsel "\nPick Block")); block ename
    obj (vlax-ename->vla-object enm); block vla-object
    var (vla-getattributes obj); vla-variant-array of block attributes
    ary (vlax-variant-value var); safearray of block attributes
    objlst (vlax-safearray->list ary); list of block attribute vla-objects
    enmlst (mapcar 'vlax-vla-object->ename objlst); list of block
    attribute enames
    )
     
    James Allen, Oct 2, 2004
    #3
  4. bcbii

    James Allen Guest

    Incidentally, what does your routine do that the built-in editing commands
    don't?

    James
     
    James Allen, Oct 2, 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.