Skip to content

Python script for extracting information from Autocad block attributes in multiple documents.

Notifications You must be signed in to change notification settings

pfrap/Multiple-file-Autocad-data-extraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multiple file Autocad data extraction

Python script for extracting information from Autocad block attributes in multiple documents.

"Python ETL"

  • Uses package EZDXF Sequence of operations
  1. FOR loop for checking unreadable files.
  2. Define the function for extracting information from cad files.
    • Select Autocad block types and defines user-customised parameter for filtering between selected blocks.
    • For each attribute extracts tag information and value in a Python dictionary.
  3. FOR loop to run the function on each file in the dxf file folder and return a Python dictionary.
  4. Checks number of files read and number of files saved for discrepancy.
  5. Pandas dataframe creation and excel export.

Reach me out for any help!

Script extract

def extract_attr_dxf(cartella, nomefile):
    doc = ezdxf.readfile("{}/{}".format(cartella, nomefile))
    modelspace = doc.modelspace()
    for n in modelspace:
        if n.dxftype()=="INSERT":
            articolo={}
            if n.has_attrib("NUMEROARTICOLO")==True:
                for attrib in n.attribs:
                    articolo[attrib.dxf.tag]=attrib.dxf.text
                user_defined_dictionary[articolo["NUMEROARTICOLO"]]=articolo

for nomefile in os.listdir(cartella):
  if nomefile.endswith(".dxf"):
    extract_attr_dxf(cartella,nomefile)

About

Python script for extracting information from Autocad block attributes in multiple documents.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages