UtilidadesDigiNG
Namespace: Digi21.Utilities
Assembly: Digi21.Utilities
Methods for entities loaded in Digi3D.AI's active drawing window.
public static class UtilidadesDigiNG
Both methods use DigiNG.DrawingFile and DigiNG.ReferenceFiles from the DigiNG class in Digi21.DigiNG.Plugin. They therefore only work in an extension running inside Digi3D.AI with a drawing window open. Without a drawing window, DigiNG.DrawingFile throws NullReferenceException.
Static methods
EnumeraTodasLasEntidades
public static IEnumerable<Entity> EnumeraTodasLasEntidades()
Returns entities from the active drawing file (DigiNG.DrawingFile), followed by those from each reference file (DigiNG.ReferenceFiles), in that order. The sequence is evaluated when iterated. Includes deleted entities: filter them through NoEliminadas from UtilidadesSecuenciaEntity.
ArchivoPropietarioDeEntidad
public static int ArchivoPropietarioDeEntidad(Entity entidad)
Returns 0 if entidad belongs to the active drawing file, and 1 + i if it belongs to the reference file at index i in DigiNG.ReferenceFiles. Membership is checked in this order:
- If
entidad.OwnerisDigiNG.DrawingFile(IReadOnlyDrawingFileExtension.Contains), returns0. - If
entidad.Owneris notnull, returns1 + ifor the first reference file whosePathequalsentidad.Owner.Path, case-insensitively. - If
entidad.Ownerisnull, iterates each reference file's entities and then the active file's entities, returning the position of the first file containing the sameentidadinstance.
Throws Exception with the message "The entity does not belong to any file" if none of the checks succeeds.
Example
This extension command counts non-deleted entities in the active drawing file and reference files, and writes the result to the results window:
using Digi21.Digi3D;
using Digi21.DigiNG.Plugin.Command;
using Digi21.Utilities;
namespace Ejemplos;
[Command(Name = "CUENTA_TODAS_LAS_ENTIDADES")]
public class CuentaTodasLasEntidades : Command
{
public CuentaTodasLasEntidades()
{
Initialize += (sender, e) =>
{
var total = UtilidadesDigiNG.EnumeraTodasLasEntidades().NoEliminadas().Count();
var activo = Digi21.DigiNG.DigiNG.DrawingFile.NoEliminadas().Count();
Digi3D.OutputWindow.Show();
Digi3D.OutputWindow.WriteLine($"Archivo activo: {activo} entidades.");
Digi3D.OutputWindow.WriteLine($"Archivos de referencia: {total - activo} entidades.");
Dispose();
};
}
}