're-welding' known curve created in code

Using entities.add_curve(points_array) will return a continuous selectable curve…

If you add this curve to a surface it remains a continuous selectable curve…

if you add a ‘surface’ to the curve it becomes a series of disconnected edges, but each edge still reports as being a curve…

this occurs for surfaces formed from the curve to a centre point or between two curves…

the gif shows a demo from the script attached…

I have tried many ways of grouping, moving, exploding in different sequences, but they all result exactly the same as this one…

I looked at many welding scripts, but they either fail to work, are buggy or spend a lot of effort ‘looking’ for an edge array…

As already have original point arrays, is there a way to remedy this splitting of the curses highlighted in the gif…

the test script…

# script to aid in disscussion of welding surface edges...
model = Sketchup.active_model
sel   = model.selection
ents  =  model.active_entities
view  = model.active_view
mats  = model.materials

# cylindrical sine wave pair on a unit radius with 24 sides...
wave = [[1.0, 0.0, 0.0], [0.9659258262890683, 0.25881904510252074, 0.050799999999999984], [0.8660254037844387, 0.49999999999999994, 0.08798818102449896], [0.7071067811865476, 0.7071067811865475, 0.1016], [0.5000000000000001, 0.8660254037844386, 0.08798818102449898], [0.25881904510252096, 0.9659258262890682, 0.05080000000000003], [6.123233995736766e-17, 1.0, 1.2442411479337108e-17], [-0.25881904510252063, 0.9659258262890683, -0.05079999999999998], [-0.4999999999999998, 0.8660254037844388, -0.08798818102449893], [-0.7071067811865475, 0.7071067811865476, -0.1016], [-0.8660254037844385, 0.5000000000000003, -0.087988181024499], [-0.9659258262890682, 0.258819045102521, -0.050800000000000047], [-1.0, 1.2246467991473532e-16, -2.4884822958674216e-17], [-0.9659258262890684, -0.25881904510252035, 0.05079999999999989], [-0.8660254037844388, -0.4999999999999998, 0.08798818102449892], [-0.7071067811865479, -0.7071067811865471, 0.1016], [-0.5000000000000004, -0.8660254037844384, 0.08798818102449903], [-0.25881904510252146, -0.9659258262890681, 0.05080000000000014], [-1.8369701987210297e-16, -1.0, 3.267705224142925e-17], [0.2588190451025203, -0.9659258262890684, -0.050799999999999915], [0.4999999999999993, -0.866025403784439, -0.08798818102449889], [0.7071067811865475, -0.7071067811865477, -0.1016], [0.8660254037844384, -0.5000000000000004, -0.08798818102449901], [0.9659258262890681, -0.2588190451025215, -0.05080000000000014], [1.0, 0.0, -0.0]]
rev_wave = wave.reverse
#
outer_wave = []
rev_wave.each{|pt| outer_wave << [pt[0], pt[1], pt[2] + 0.1]}
#
inner_wave = []
outer_wave.each{|pt| inner_wave << [pt[0] * 0.5, pt[1] * 0.5, pt[2]]}

# single undo
model.start_operation('Wave', false, false, false)

# add colors to watch the order of construction...
mat_names = []
mats.each{|n| mat_names << n.name}
	mats.add('inner').color   = 'skyblue'    unless mat_names.include?('inner')
	mats.add('outer').color   = 'seashell' unless  mat_names.include?('outer')

# Make the empty 'wave' group.
wave_grp = ents.add_group()

# Make array to hold entities...
wave_ents = wave_grp.entities

# Add outer points to inner points for the radial pairs...
radial = outer_wave.zip(inner_wave)
radial_edges = radial.each {|pr|
  e = wave_ents.add_edges(pr)
  e[0].soft="true"
  e[0].smooth="true"
	# for watching only
  sel.add(e)
	view.refresh
}
sel.clear

# Add  outer points to offset inner points for the diagonal pairs...
diagonal = outer_wave.zip(inner_wave[0..-2].unshift(inner_wave[-1]))
diagonal_edges = diagonal.each {|pr|
  e = wave_ents.add_edges(pr)
  e[0].soft="true"
  e[0].smooth="true"
  e[0].casts_shadows = false
	# for watching only
  sel.add(e)
	view.refresh
}
sel.clear

# Add the inner 'curve' and face created between curve, radial and diagonal edges...
inner_edges = wave_ents.add_curve(inner_wave)
i = 0
inner_edges.each {|e|
	e.find_faces
	f = e.faces[0]
	i += 1
	# for watching only
	f.material = 'inner'
  sel.add(f)
	view.refresh
}
sel.clear
#
outer_edges = wave_ents.add_curve(outer_wave)
	i = 0
	outer_edges.each {|e|
	e.find_faces
	f = e.faces[0]
	i += 1
	# for watching only
	f.material = 'outer'
  sel.add(f)
	view.refresh
}
sel.clear

sel.add(inner_edges, outer_edges)

model.commit_operation

and here a gif of the curve to centre-point surface…

john

We have had separate PMs about this before…

The order of operations is critical.
Make the softened edges, make the facets, make a curve in a group and explode it over the facets.
If desired turn the smoothed edges back solid…

Try this code pasted into the Ruby Console, in an empty model, to make two 1" facets with a shared ‘curve’ edge-set which straddles an otherwise splitting cross-edge that is smoothed to stop the splitting…

out the smoothing code-line and/or the final un-smoothing code-line to see the differences.

### the vertices of two rectangles sharing edge b,e
a=[0,0,0]
b=[0,0,1]
c=[1,0,1]
d=[1,1,1]
e=[0,1,1]
f=[0,1,0]
###
model=Sketchup.active_model
aents=model.active_entities
###
group=aents.add_group()
gents=group.entities
### add softened edge - otherwise splitting at b.e
edge=gents.add_line(b,e); edge.smooth=true; edge.soft=true
###
gents.add_face(a,b,e,f)
gents.add_face(b,c,d,e)
###
subgp=aents.add_group()
sents=subgp.entities
sents.add_curve(a,b,c,d,e,f)
###
group.explode
subgp.explode
### reset edge b,e back solid, if desired
edge.smooth=false; edge.soft=false
###

that works, even when I close the perimeter by adding an additional point…

aside the groupings [ which I have in the final script from our PM’s ], the main difference I spot is the face creation not using the curve, i.e. each having an ordered points array…

I’ll go back rework that bit into yesterdays version…

I posted publicly so as not be only bothering you all the time…

john

Make the smoothed edges first - i.e. any ‘cross-edges’ which would otherwise split the curve.
Then make the facets - doing it that way keeps the smoothed edges intact.
Then make the overlaying curves inside a temporary group.
Then explode the welded curve-group over the facets.
The welded curve persists in the new geometry.
If you don’t want smoothed edges you can revert them to be solid AFTER merging the curve with the facets.

Cheers @TIG,

I have a working version of curve to centre point surface now…

it appears the most critical step is the surface outer edges are ‘soft’ and made separately…

it works with only 2 levels of groups and a single explode of the inner group…

curve to curve may need a third group unless I create a mesh…

john