Okay I worked on this this weekend and I am ALMOST getting the output I want...
'VB.NET Code output
gp.AddLine(0.000,10.000,0.000,2.000)
gp.AddArc(0.000,8.000,4.000,4.000,0.000,90.000)
gp.AddLine(10.000,12.000,2.000,12.000)
gp.AddArc(8.000,8.000,4.000,4.000,0.000,90.000)
gp.AddLine(12.000,2.000,12.000,10.000)
gp.AddArc(8.000,-0.000,4.000,4.000,0.000,90.000)
gp.AddLine(2.000,0.000,10.000,-0.000)
gp.AddArc(0.000,0.000,4.000,4.000,0.000,90.000)
The start and end arc angles all appear to be 0 and 90.
The x,y center point is different for each so I know I am getting each arc in the loop.
How does this work?
My latest conversion code.
require 'sketchup'
# Task; Convert sketchup face outer loop to VB.NET graphicpath code
def ConvertToDotNetLine(edge)
# Convert to VB.NET code graphicpath line definition
startpt = edge.start.position
endpt = edge.end.position
s = "gp.AddLine("
s += "%.3f" % startpt.x.to_f + ","
s += "%.3f" % startpt.y.to_f + ","
s += "%.3f" % endpt.x.to_f + ","
s += "%.3f" % endpt.y.to_f + ")\n"
return s
end
def ConvertToDotNetArc(arc)
# Convert to VB.NET code graphicpath arc definition
x = arc.center[0]-arc.radius # Left of arc circle's bounding box.
y = arc.center[1]-arc.radius # Top of arc circle's bounding box.
wt = arc.radius * 2 # width of arc circle's bounding box.
ht = wt # height of arc circle's bounding box.
startang = arc.start_angle
endang = arc.end_angle
s = "gp.AddArc("
s += "%.3f" % x.to_f + ","
s += "%.3f" % y.to_f + ","
s += "%.3f" % wt.to_f + ","
s += "%.3f" % ht.to_f + ","
s += "%.3f" % startang.radians + ","
s += "%.3f" % endang.radians + ")\n"
return s
end
model = Sketchup.active_model
face = model.selection[0]
if (face)
sout = ""
used_edges = []
loop = face.outer_loop
edgeuses = loop.edgeuses
edgeuses.each do|edgeuse|
edge = edgeuse.edge
next if used_edges.index edge
curve = edge.curve
if (curve)
used_edges = used_edges | curve.edges
if curve.is_a? Sketchup;;ArcCurve
sout += ConvertToDotNetArc(curve)
# UI.messagebox "Edge is an Arc Curve"
else
UI.messagebox "Edge is a Curve"
end
else
sout += ConvertToDotNetLine(edge)
# UI.messagebox "Edge is a Line"
end
end # end edgeuses each
f = File.open("C;\\aaapath.txt", "w")
f.write(sout)
f.close
UI.messagebox(sout)
end