AttipEdit command with C sharp, VB.net or lisp?

AttipEdit command with C sharp, VB.net or lisp?

muckmailer
Collaborator Collaborator
541 Views
2 Replies
Message 1 of 3

AttipEdit command with C sharp, VB.net or lisp?

muckmailer
Collaborator
Collaborator

Is there an C sharp, VB.net or lisp routine that is equivlent
 to the Attipedit command?

 The AttipEdit command allows a user to select an attribute
 in a block reference and directly edit it.

 Most C sharp vb.net or lisp routines has the user to
 select the block and then the program extracts the attribute
 for a block defination.

 Thank you,

0 Likes
542 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

To edit attribute value, if you can use LISP in your workflow, you can just call the command "ATTIPEDIT" in list statement like:

 

(command "ATTIPEDIT",....).

 

If you want a .NET API routine that can be used in your .NET addins, you look at Editor.GetNestedEntity() to allow user to select an attribute in a block reference. Once an attribute is selected (the code then knows its ObjectId), you are free to do whatever you want to the attribute selected. the code (in C#) would look like:

 

private void EditAtt(Editor ed)

{

  var opt=new PromptNestedEntityOptions("\nPick an attribute:");

  var res=ed.GetNestedEntity(opt);

  if (res.Status==PromptStatus.OK)

  {

    ChangeAttValue(res.ObjectId, ed);

  }

}

 

private void ChangeAttValue(ObjectId attId, Editor ed)

  using (var tran=attId.Database.TransactionManager.StartTransaction())

  {

    var att=tran.GteObject(attId, OpenMode.ForRead) As AttributeReference;

    if (att!=null)

    {

      ed.WriteMessage("\nCurrent Attribute Value: {0}", att.TextString);

      var attValueRes=ed.GetString("\nEnter new attribute value:");

      if (attValueRes.Status==PromptStatus.OK)

      {

        att.UpgradeOpen();

        att.TextString=attValueres.StringValue;

      }

    }

    tran.Commit();

  }

}

 

Of course, after user picks an attribute, you can show a data input form as dialog box (but in this case, I'd ask user to pick block, and display all attributes on the form for user to edit).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

muckmailer
Collaborator
Collaborator

Is there a way I could use that code in a loop (or Attipedit command) into a loop?

 

I would like to select many blocks in a window or crossing at once and filter out the attributes

from the selection set to edit them in a short dalog box. I would like to edit the attributes in

a loop starting from the upper right attribute to lower left attribute in a rolling loop that was

selected in the selection set. Is it possable to do that using Net, Lisp or whatever?

 

It would be select, edit attribute in dialog box, hit return for the next attribute untill all attributes are edited.

 

Thank you,. 

0 Likes