Last active
December 23, 2015 00:39
-
-
Save brunosaboia/6554650 to your computer and use it in GitHub Desktop.
Ler nome para XData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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