app
SOLIDWORKS Bridge
Public Made by Adomby adom
Launch, model and quit SOLIDWORKS from any Adom container. Nothing is ever lost.
main
import math, sys, io, contextlib
sys.path.insert(0,'.')
with contextlib.redirect_stdout(io.StringIO()):
from tb2 import toolblock, area
from tb34 import clip_halfplane, clip_disc
A,B,C=86,58,44
prof,_,info,P=toolblock(A,B,C,top=B-33.0,redge=B-57.0)
Aprof=area(P); hole14=math.pi*49; hole11=math.pi*5.5**2
xstep=(A-52)-14.0
Astep=area(clip_halfplane(P,1,0,xstep))
Abelow=area(clip_halfplane(P,0,1,-14.0)) # region y<=-14 (below lobe-bottom line)
Abelow_right=area(clip_halfplane(clip_halfplane(P,0,1,-14.0),-1,0,-xstep)) # y<=-14 and x>=xstep (not already step-cut)
xR=A-14.0
F=(43+29*(22/34.0),-11.0); yc=-11+math.sqrt(41**2-(xR-F[0])**2); cx,cy=xR,yc
Aslot=area(clip_disc(P,cx,cy,41.0))
print("areas: profile %.2f step(x<=%.0f) %.2f below(y<=-14) %.2f below&right-of-step %.2f slot %.2f"%(Aprof,xstep,Astep,Abelow,Abelow_right,Aslot))
V=Aprof*C - Astep*19 - Abelow_right*19 - Aslot*24 - hole14*(C-19) - hole11*(C-24)
t3=628.18/0.0079
print("STEP3 with 19x19 under-notch: V=%.1f mass=%.2f (key 628.18, diff %+.3f%%)"%(V,V*0.0079,(V/t3-1)*100))
# sensitivity: R41 center variants
for name,(ccx,ccy) in [("corner (72,25)",(xR,25.0)),("(72,28.0)",(xR,28.0)),("(72,29.5)",(xR,29.5)),("pixel (72.4,28.6)",(72.4,28.6))]:
As=area(clip_disc(P,ccx,ccy,41.0)); Vv=Aprof*C - Astep*19 - Abelow_right*19 - As*24 - hole14*(C-19) - hole11*(C-24)
print(" R41 center %-18s slotA=%.1f mass=%.2f (%+.2f%%)"%(name,As,Vv*0.0079,(Vv/t3-1)*100))
import json; json.dump(dict(V3=V,Aprof=Aprof,Astep=Astep,Abelow_right=Abelow_right,Aslot=Aslot,cx=cx,cy=cy),open("step3.json","w"))