kaefer,
It's prompt attribute, wanted him to appear at the prompt cad not to have to choose how I hj as attributes that are invisible can not be selected.
The block attachment is thus a visible and two invisible, I tried it but did not notice a difference in the invisible.
Modified with the tips you gave me but still could not, I apologize in advance to everyone I'm still crawling in C # programming and cad.
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using acad = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.EditorInput;
namespace ClassLibrary5
{
public class Class1
{
[CommandMethod("TESTE")]
public static void UpdateSingleAttribute()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
try
{
Entity ent;
PromptNestedEntityResult nres;
ObjectId id;
do
{
PromptNestedEntityOptions pno = new PromptNestedEntityOptions("\nSelecione o Bloco Atributado >>");
nres = ed.GetNestedEntity(pno);
if (nres.Status != PromptStatus.OK)
{
break;
}
id = nres.ObjectId;
ent = id.GetObject(OpenMode.ForRead) as Entity;
ed.WriteMessage("\nObjeto Selecionado\t{0}", ent.GetRXClass().DxfName);
Point3d pnt = nres.PickedPoint;
AttributeReference attref = tr.GetObject(id, OpenMode.ForRead) as AttributeReference;
AttributeDefinition msg = ent as AttributeDefinition;
BlockReference blref = tr.GetObject(ent.OwnerId, OpenMode.ForRead) as BlockReference;
foreach (ObjectId attId in blref.AttributeCollection)
{
if (attref.Tag == "MyInvisibleAttributeTag")
{
PromptStringOptions pso = new PromptStringOptions("\nDigite novo valor : ");
pso.AllowSpaces = true;
PromptResult res;
res = ed.GetString(pso);
break;
}
}
PromptStringOptions psso = new PromptStringOptions("\nDigite novo valor : ");
psso.AllowSpaces = true;
PromptResult rres;
rres = ed.GetString(psso);
if (rres.Status != PromptStatus.OK) break;
string strvalue = rres.StringResult;
attref.UpgradeOpen();
attref.TextString = strvalue;
}
while (nres.Status == PromptStatus.OK);
tr.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
ed.WriteMessage("\n" + ex.StackTrace + "\n" + ex.Message);
}
}
}
}
}
Thanks,
Josano