I draw some cad hilbert-based one-loop drawing like this:
this is dxf format data.
and I wrote Python program that extract coordinates from svg that is made by InkScape.
But, this did not work fine.
all coordinates my python program extracted to csv file and draw x-y graph by excel, connect points of line-to-line are different that I expect like this:
This seems that connecting points are different, counter-side is connected.
My python program is extract x,y from svg in turn.
Please tell me how to determine connecting point, or any other problems?
for subpath_index in range(len(csp)): for node_index in range(len(csp[subpath_index])): x, y = csp[int(subpath_index)][int(node_index)][1] # inkex.errormsg(f'{x},{y}') draw_circle(self, x, y) csv_list.append([x, y])
return csv_list
The returned list can then be written directly to csv:
def create_csv(self, csv_list):
try: with open('/home/name/Pictures/points.csv', 'w') as csv_file:
write = csv.writer(csv_file) write.writerows(csv_list) except: inkex.errormsg('Could not write to csv file !')
(Some of the code above was with help previously from user Kaalleen)
I draw some cad hilbert-based one-loop drawing like this:
this is dxf format data.
and I wrote Python program that extract coordinates from svg that is made by InkScape.
But, this did not work fine.
all coordinates my python program extracted to csv file and draw x-y graph by excel, connect points of line-to-line are different that I expect like this:
This seems that connecting points are different, counter-side is connected.
My python program is extract x,y from svg in turn.
Please tell me how to determine connecting point, or any other problems?
If you have just extracted the coordinates, what has happened to the other svg path commands.
For example. L C A H V ?
C and A give bezier curves and arcs.
If you have just extracted the node coordinates and drawn lines, that will give you a polygon only.
My svg data is modified, 'Insert new nodes into selected nodes' by 8 times to increase simple coordinates
and eliminate bezier, spline curves.
So, this is enough to extract simple x,y coordinates M, L, V, H, not need to sample C, A.
In Inkscape, select all nodes, and click the highlighted button ( node toolbar ) to check first.
dear inklinea,
I tried you suggested, but the result was same.
The saved svg I edit by Inkscape consists no C, A, only exist M, L, V, H.
And the important thing I want is the order of coordinates are all arranged to be drawn unicursally.
The target device is 6-axis robot to trace dxf data.
This robot only recognize simple x,y,z,rx,ry,rz coordinates, so I must convert curves to a set of fine points.
Do you have a copy of the one loop .dxf ? that you can attach ?
plz confirm.
Very unfortunately, it works fine in Illustrator.
All I want is extract simple fine coordinates without curves.
I was able to create this.
Using the node tool, I press ctrl + a to select all nodes in the imported dxf.
Then press Shift + J to join all nodes.
Then increase the nodes a couple of times.
In the extension convert to an absolute path, then export nodes at .csv
( I have attached the csv )
I confirmed, thanks!!! My problem has gone by your assist. I am very happy.
I did not know Shift + J command by now. Where is this command? Which icon related?
A problem of InkScape is, I think, that keyboard shortcuts, tool icons and menu bar functions are disjointed and not integrated
Yes, it's part of the Node Tool Toolbar.
Image attached.
Yes, I have found it.
And I have one more question.
> In the extension convert to an absolute path, then export nodes at .csv
Where is this command?
I cannot find this.
You can use Extensions > Modify Path > To Absolute
However I wrote a small extension to test your curve.
def make_abs_node_list(self, element):
csv_list = []
path_d_abs = element.path.to_absolute().transform(element.composed_transform())
csp = path_d_abs.to_superpath()
for subpath_index in range(len(csp)):
for node_index in range(len(csp[subpath_index])):
x, y = csp[int(subpath_index)][int(node_index)][1]
# inkex.errormsg(f'{x},{y}')
draw_circle(self, x, y)
csv_list.append([x, y])
return csv_list
The returned list can then be written directly to csv:
def create_csv(self, csv_list):
try:
with open('/home/name/Pictures/points.csv', 'w') as csv_file:
write = csv.writer(csv_file)
write.writerows(csv_list)
except:
inkex.errormsg('Could not write to csv file !')
(Some of the code above was with help previously from user Kaalleen)
Thanks inklinea, I successfully extract coordinates from svg to csv by my python program.
My problem is that I did not know the command of join all nodes at all.
And I'd like to contribute for enhancing InkScape.
The most important thing I concern is to enhance the speed of 'Insert new node' command.
How do I contribute for this?
https://chat.inkscape.org/channel/team_devel