New code with some improvement.
But the problem is sprockets, fillets.
I have thought of making sections and enlarging them via makeOffset2D.
the code is active in the new file.
I correctly obtain the sections at different height, using some trick:
Code: Select all
def test_spr_sec():
"""Test sectioning."""
# make hub for cutting
#c_hub = mk_hub(fuse_play)
spkts = mk_sprockets(0.40, 0.75)
spkts_c = Part.makeCompound(spkts)
Part.show(spkts_c, "sprockets")
# try to define a "law" to make hub sprockets fillets
cen_rad_min = hu_rad
cen_rad_max = hu_lv_rad + hu_lv_ia
print("center radii, min: {0} max: {1}".format(cen_rad_min, cen_rad_max))
# hub side fillets
hu_fi_dim = (rim_nrad - cen_rad_max) / hu_fi_fac
# same as above for rim fillets
# rim_fi_dim = (rim_nrad - cen_rad_max) / hu_rim_fac
rec_fac = hu_fi_dim / 5
plays = (
fuse_play * 0.5,
rec_fac * -1,
rec_fac * -2,
rec_fac * -3,
rec_fac * -4,
rec_fac * -5,
)
print(plays)
enlarg = 10
enl_fact = enlarg / len(plays)
for s_idx, play in enumerate(plays):
sect_t = section_sprockets(play)
Part.show(sect_t, "section{}".format(s_idx))
shapes = []
for idx, spkt in enumerate(spkts_c.Solids):
result = sect_t.common(spkt)
wire = result.Faces[0].Wires[0]
#comp_wire = wire.makeOffset2D(enlarg - enl_fact * s_idx)
Part.show(wire, "section{}_{}".format(s_idx, idx))
shapes.append(result)
Not so elegant, I've hardcoded some distance from the "hub cut solids" and created enlarged extruded wires to obtain section at different heights.
We could not model a single sprocket as the hub is not circular, so many sprockets have different position for the fillet.
I have thought of making these sections, enlarging them using makeOffset2D and then loft the profiles to obtain a solid and fuse to each sprocket in the correct place.
We could determine a different law using maybe two diameter for enlarging and obtain properly spaced sections.
But "sections are not planar" and makeOffset2D raise an error.
EDIT:
Strange enough a little problem, see the image below
Image above is with the actual code
EDIT2: for a couple of minute I have posted here a wrong version, sorry for any inconvenience, and for my english too.
Section is not working perfectly when at the tangent point of the wire, probably there are some calculations that use some length like tangent that is infinite at this point, resulting in a distorted shape. Probably using a plane problem will not occur.
There is a way to obtain some data and make a plane to cut the sprocket and obtain a planar section?.
Problem is automating things, based on existing shapes I have though of using sprocket axis and determine a position and the orthogonal line to sprocket axis.
As usual some Vector math is involved.
TIA and Regards
Carlo D.