[plugin]Export arcs, circles and vertex to dxf ?
-
I think you have an error in collecting the circles and arcs.
if es != 2 ### it's an arc arc = true circ = false break end
later
circles << c if circ && ! circles.include?(c) ### only add it to list once arcs << c if arc && ! arcs.include?(c) ### only add it to list once -
OK, right.
-
Hello TIG,
When arc=false and circle=false, I wanted to store the entity in an array, could y help me? So at the end, I will use the edges of these entities for writing the polylines.
-
You now have two arrays - for circles and arcs.
Process each collected 'curve' in turn.
e.g.circles.each{|c| c.edges.each{|e| # the curve's edges # process each edge 'e' } }Do the same for the 'arcs' array...
As it stands, you have arrays of curves which define circles of edges.
Those 'collections' are pointing to their 'edges' - i.e. defining their 'segments', which can be used as you want later...
-
I misspoke, sorry. I'm OK for the arc and circle. They will be writen in the DXF file as ARC entity and CIRCLE entity.
What I don't see is how to collect the edges of the vertices of other entities of the selection/loop to write polylines (it's better than just lines for selection in the CAD softwares), when it's not an arc or a circle, in the "else" section of the previous code :else ### it's not a curve, or if it is it's not a circle or an arc circ = false arc = false ... next endTo write as polylines the dxf entities which are not circle or arc, I will use the following functions(*). The function dxf_write_polyline must be modified, because it's based on the loops of the faces, and the loop will be broken - or ignored - by the arcs and circles.
tform=Geom;;Transformation.new() layername=model.active_layer.name def dxf_transform_vertex(vertex, tform) point = Geom;;Point3d.new(vertex.position.x, vertex.position.y, vertex.position.z) point.transform! tform point end def dxf_write_polyline(face, tform, layername) face.loops.each do |aloop| $dxf_file.puts(" 0\nPOLYLINE\n 8\n"+layername+"\n 66\n 1") $dxf_file.puts("70\n 8\n 10\n0.0\n 20\n 0.0\n 30\n0.0") for j in 0..aloop.vertices.length do if (j==aloop.vertices.length) count = 0 else count = j end point = dxf_transform_vertex(aloop.vertices[count],tform) $dxf_file.puts( " 0\nVERTEX\n 8\nMY3DLAYER") $dxf_file.puts("10\n"+(point.x.to_f * $unit_conv).to_s) $dxf_file.puts("20\n"+(point.y.to_f * $unit_conv).to_s) $dxf_file.puts("30\n"+(point.z.to_f * $unit_conv).to_s) $dxf_file.puts( " 70\n 32") end if (aloop.vertices.length > 0) $dxf_file.puts( " 0\nSEQEND") end end endThank you very much.
(*)existing plugin from http://www.guitar-list.com, original authors: Nathan Bromham, Konrad Shroeder
-
Hi,
In fact, there is the problem of the order of the vertices to make the polylines. I think I must follow the loops, like in the initial code of guitar-list, but I must test the ".curve" of each vertex and extract the arcs, circles, and the polylines with vertices in the order. A little tricky for me, I will take a paper and a pencil!
-
Look at my 'Weld' tool.
That takes selected edges, and then welds them into a curve.
It has to sort the edges out in order and also get the start/end points correctly ordered.However, a non-arc curve has a list of ordered vertices method, so you can get their positions as points using:
points = curve.vertices.collect{|v| v.position }
then use
points.each_with_index{|p, i| model.active_entities.add_text(i.to_s, p) }
to label the points to demonstrate to yourself that they are indeed ordered... -
Thanks TIG, I will work on it.
-
Hello TIG,
Like other people, I have the following problem : with the(Sketchup::ArcCurve)entities, the arcs are always rotated, with the.start_anglevalue equal to 0.0 (and not equal to the angle with the X axe, the API documentation is wrong on this point in my situation - working with the entities of the loops).
Do you have a clean (and 3D) workaround?
Best regards,
Renaud. -
I just saw that the .xaxis propery of the arcs are rotated => start_angle=0 is right, because the reference is wrong. OK, knowing that, I can see how to do this.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement