Output arcs to dxf format
-
I am writing a script that allows me to output simple 2D drawings to dxf format, but I am having some trouble with arcs. I can output lines and circles fine but my arcs do not have the correct starting and ending angles, the arc always opens down despite it's orientation in the model.
How can I correctly output arcs in dxf format?
[Edit:]I should specify I want to output the arcs as arcs, not a series of lines.
-
Hi Tmic, Here is a link to ruby that works for me. I export polylines only, and have not tested the other export extities. If you get yours to work with layers preserved, please post your solution.
-
To get the proper layer name for each entity you have to do something like this.
model = Sketchup.active_model entities = model.entities layername = entities[entity_index].layer.name
or in a for each loop
model = Sketchup.active_model entities = model.entities entities.each |entity| layername = entity.layer.name end
I have seen the script you mentioned, but it outputs arcs as a series of lines. I am trying to output arcs as arcs.
-
Thanks, I will see if I can use your examples. Sorry I wasn't able to help you.
-
I think it sounds like an autocad problem, no? Or do you think you are doing something wrong with the ruby coordinates for the arc that you are getting?
Chris
-
Chris,
The only problem I'm having is getting the correct start and end angle of the arc, the ArcCurve.start_angle, and ArcCurve.end_angle are not giving me the correct values.I'm currently trying to determine these angles myself using the start point and end point of the arc, but I'm having trouble getting it to work consistently.
-
What value is it returning? It is most likely a radian. So you would need to do a start_arc.radian to change it into degrees (or is it start_arc.degree?). Perhaps that is the issue?
Chris
-
I guess I should have said that I already convert it to degrees.
I think I am losing something in the transition from sketchup to dxf, but I'm not sure what. It seems like it should be a straight forward transition center point = center point, radius = radius, angles = angles, but it is turning into a real headache.
-
I'm getting closer. It turns out that ArcCurve.start_angle is always 0.0, so I made a function that finds the actual start anlge, I then add that to the end angle for output.
def get_new_angle(center, point) #center is the center point returned by AcrCurve.center #point is the start point of the arc returned by ArcCurve.vertices[0].position return Math;;atan(((center.y.to_f - point.y.to_f)/(center.x.to_f - point.x.to_f))).to_f.degrees.abs end
Now the problem is arcs on the y axis are not correct.
Advertisement