Hello, thanks, and question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Hello, thanks, and question

Jozef
Hello,
I appreciate LibreCad and all the work that has gone into it.  I have mainly used it as a tool to verify the dxf output from another drawing package.  So in a way it is my reference and very important to avoid mistakes when sending my files to the shop.
I am working now on an idea for converting a 2d drawing into Gcode for engraving.  I know there are packages that claim to do this but I'm yet to find a good one that can output efficient codes.  I would like to explore taking the coordinates for the various entities to use.  I know that I can get entity coordinates for one thing at a time using the plugin.  Is there a way I can get all the entities at once and send them to a file?  I know I'm asking a lot, but thought that since LibreCAD already reads the dxf file and must parse all the data, maybe it is available somehow?  My apologies if it seems a stupid question.
thanks,
Jozef
Reply | Threaded
Open this post in threaded view
|

Re: Hello, thanks, and question

sand1024
well, different entities are described by set of different coordinates... i.e. - point - just one coordinate. line - 2 of them. Circle - coordinate of center and radius... and so on.

So I'm not sure I understand how coordinates of "all entities" may be collected in some uniform way and sent to the file. Do you have some specific format in mind?
Reply | Threaded
Open this post in threaded view
|

Re: Hello, thanks, and question

perepujal
In reply to this post by Jozef
Hi, with the "List entities" plugin you could see some of the info you ask for:

Click on Plugins->List entities, select the entities you want the info, then hit Enter

alternatively, first select anything you want info, then click on Plugins->List entities, then hit Enter

Then copy/paste the output to a file, this is not automated, and maybe there are info you don't need, see for example the ouput of a circle:

n 4: CIRCLE
  Layer: 0
  Color: BYLAYER
  Line type: BYLAYER
  Line thickness: BYLAYER
  ID: 1002
    center point: X=20.0000 Y=110.2500
    radius: 23.9505
    circumference: 150.4852
    area: 1802.0961

HTH
Pere
Reply | Threaded
Open this post in threaded view
|

Re: Hello, thanks, and question

sand1024
well, for sure technically it's possible - after all, we have something similar in 2.2.2-alpha (https://github.com/LibreCAD/LibreCAD/releases/tag/2.2.2_alpha-latest) in Entity Info widget.

As for mass selection and export - no, so far there is no such a functionality at the moment - mainly because it's not clear which exact format is needed and, basically, how that output will be handled further (usually such exports are useful for further automated processing).

Actually, it's not a technically complex things to implement as we have good basis internally, and so it might be that I'll add this feature in the future if this will be really needed - at least, I've noted this.



Reply | Threaded
Open this post in threaded view
|

Re: Hello, thanks, and question

Jozef
Thanks.  I really only need each entitie's coordinates for what I thought I wanted to do.  I would want to put them into a csv file.  I know the dxf format has other things like color and line thickness and so on.  I could parse around all that.
Reply | Threaded
Open this post in threaded view
|

Re: Hello, thanks, and question

dxli
Jozef,

for special purposes, you can also ask AI to create code.

I tried Google AI mode:

generate a python program to list all geometry parameters of all entities in a DXF file, and output them in a CSV file

This is the python program it generated:

pip install ezdxf


import ezdxf
import csv

def export_dxf_to_csv(dxf_path, csv_path):
    try:
        # Load the DXF file
        doc = ezdxf.readfile(dxf_path)
    except IOError:
        print(f"Error: Cannot open file {dxf_path}")
        return
    except ezdxf.DXFStructureError:
        print(f"Error: Invalid or corrupted DXF file: {dxf_path}")
        return

    # Access the modelspace where geometry entities are stored
    msp = doc.modelspace()
    
    # Prepare CSV file for writing
    with open(csv_path, mode='w', newline='', encoding='utf-8') as f:
        writer = csv.writer(f)
        # Define header: Handle (unique ID), Type (LINE, CIRCLE, etc.), Layer, Parameter, Value
        writer.writerow(['Handle', 'Entity_Type', 'Layer', 'Parameter', 'Value'])
        
        for entity in msp:
            handle = entity.dxf.handle
            etype = entity.dxftype()
            layer = entity.dxf.layer
            
            # Extract all available DXF attributes for the current entity
            # This includes geometry (start, end, center, radius) and metadata
            attribs = entity.dxfattribs()
            
            for param_name, value in attribs.items():
                writer.writerow([handle, etype, layer, param_name, str(value)])

    print(f"Data successfully exported to: {csv_path}")

# Example Usage
if __name__ == "__main__":
    # Replace with your actual file names
    input_file = "drawing.dxf"
    output_file = "geometry_parameters.csv"
    export_dxf_to_csv(input_file, output_file)

Jozef wrote
Thanks.  I really only need each entitie's coordinates for what I thought I wanted to do.  I would want to put them into a csv file.  I know the dxf format has other things like color and line thickness and so on.  I could parse around all that.