Skip to content

Instantly share code, notes, and snippets.

@brunosaboia
Last active December 23, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosaboia/6554650 to your computer and use it in GitHub Desktop.
Save brunosaboia/6554650 to your computer and use it in GitHub Desktop.
Ler nome para XData
[CommandMethod("LerNome")]
public static void LerNome()
{
var documento = Application.DocumentManager.MdiActiveDocument;
var editor = documento.Editor;
var opcoes = new PromptEntityOptions("\nSelecione a entidade: ");
opcoes.SetRejectMessage("\nPor favor, selecione uma reta (Line).");
opcoes.AddAllowedClass(typeof(Line), false);
opcoes.AllowNone = false;
var resultado = editor.GetEntity(opcoes);
if (resultado.Status != PromptStatus.OK)
{
editor.WriteMessage("\nComando abortado.");
return;
}
using (var transacao = documento.TransactionManager.StartTransaction())
{
var reta = transacao.GetObject(resultado.ObjectId, OpenMode.ForRead);
var dados = reta.XData;
if (dados == null)
{
editor.WriteMessage("\nNão há dados anexados à reta.");
}
else
{
foreach (var valor in dados)
{
editor.WriteMessage("\nTipo: {0}, Valor: {1}", valor.TypeCode, valor.Value.ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment