Removing database links
File: borra_atr.py · command BORRA_ATR, without parameters. Also runs from the Python script pane.
Iterates all drawing window geometries, including deleted geometries and reference file geometries, replacing them with clones whose codes are new and have no database link: no table, record or attributes.
Usage
Enter on the command line:
BORRA_ATR
Code
import digi3d
view = digi3d.current_view()
def creaClonSinAtributosBaseDatos(entidad):
"""Crea un clon de la entidad sustituyendo sus códigos por unos nuevos sin diccionario de BBDD.
Argumentos:
entidad: Entidad a clonar
Devuelve:
Entidad clonada sin enlace a base de datos
"""
clon = entidad.clone()
codes = []
for codigo in entidad.codes:
codes.append(digi3d.FeatureCode(codigo.code))
clon.codes = tuple(codes)
return clon
eliminar = []
anadir = []
for entidad in view:
anadir.append(creaClonSinAtributosBaseDatos(entidad))
eliminar.append(entidad)
view.add(anadir)
view.delete(eliminar)
view.redraw()
How it works
entidad.clone()creates an editable geometry copy; view geometries are read-only.- Codes are recreated from their strings: takes each code's string (
codigo.code) and constructs a new code withdigi3d.FeatureCode(codigo.code).FeatureCode(code)takes the string and creates a code without a table, identifier or database attributes.- To preserve table and record, also copy
.tableand.id, as in renomcod.
clon.codes = tuple(codes)assigns the clone's new code list.- Collects clones in
anadirand originals ineliminar, applying changes in bulk withview.add(...)andview.delete(...). - Iterates all view geometries, including deleted ones.
See also
- FeatureCode:
code,table,id,attributes - Geometry:
clone,codes