'Obtaining points from the dxf using dxfgrabber module python
In the below i got the circles and the lines that are in the given dxf. I want the points. I tried something that i didn't understand from the documentation of the dxfGrabber module. Can anyone help please.
import dxfgrabber
import matplotlib.pyplot as p
dxf=dxfgrabber.readfile("3.dxf")
#version=dxf.header["$ACADVER"]
output=[entity for entity in dxf.entities if entity.layer =='0']
q=[]
for line in output:
q.append(line)
w=[]
i=0
l=[]
c=[]
lines = [entity for entity in output if entity.dxftype == 'LWPOLYLINE']
circles= [entity for entity in output if entity.dxftype == 'CIRCLE']
for line in lines:
l.append(line)
for part in circles:
c.append(part)
references = [entity for entity in dxf.entities if entity.dxftype == '
test= dxf.blocks
points=[]
points=
Solution 1:[1]
I added round numbers
import dxfgrabber
def round_vertices(vertices_list: list, ndigits: int):
rounded_vertices = []
for vertex in vertices_list:
rounded_vertex = []
for coordinate in vertex:
rounded_vertex.append(round(coordinate, ndigits))
rounded_vertices.append(tuple(rounded_vertex))
return rounded_vertices
dxf=dxfgrabber.readfile("3.dxf")
output=[entity for entity in dxf.entities if entity.layer =='0']
list_of_vertices = [round_vertices(entity.points, 7) for entity in output if entity.dxftype == 'LWPOLYLINE']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
