chore: import 3d-drawing history from local Code/3d-drawing (subfolder, history preserved)
This commit is contained in:
commit
7b754e810b
51 files changed
+20300
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import sys, time, pickle
|
||||
sys.path += ['/root/.local/lib/python3.13/site-packages','/usr/local/lib/python3.13/dist-packages','/usr/lib/python3/dist-packages']
|
||||
from build123d import import_step, Face
|
||||
import numpy as np
|
||||
shape = import_step("/mnt/user-data/uploads/97.과제/Code/3d-drawing/model/tunnel_solids.step")
|
||||
solids = shape.solids()
|
||||
pickle_out = {}
|
||||
import json
|
||||
meta=json.load(open('/mnt/user-data/uploads/97.과제/Code/3d-drawing/model/tunnel_solids_meta.json'))
|
||||
comps=[c for c in meta['components'] if c['group']!='시설한계(참조선)']
|
||||
print("non-clearance comps", len(comps))
|
||||
# match by volume greedily in meta order
|
||||
used=set(); mapping={}
|
||||
for c in comps:
|
||||
best=None;bd=1e9
|
||||
for j,s in enumerate(solids):
|
||||
if j in used: continue
|
||||
d=abs(s.volume-c['volume_m3'])
|
||||
if d<bd: bd=d;best=j
|
||||
if bd<0.02:
|
||||
used.add(best); mapping[c['id']]=best
|
||||
else:
|
||||
mapping[c['id']]=None
|
||||
print("matched", sum(v is not None for v in mapping.values()), "of", len(comps), "unused solids", len(solids)-len(used))
|
||||
print("first 10 mapping", list(mapping.items())[:10])
|
||||
pickle.dump({'mapping':mapping}, open('/tmp/verify_daesan2_run/mapping.pkl','wb'))
|
||||
# faces of solid 0 (LIN_01)
|
||||
for idx in [mapping['LIN_01_P-3']]:
|
||||
s=solids[idx]
|
||||
fs=s.faces()
|
||||
print("solid",idx,"nfaces",len(fs), "vol", round(s.volume,3))
|
||||
rows=[]
|
||||
for f in fs:
|
||||
gt=f.geom_type
|
||||
c=f.center(); a=f.area
|
||||
try:
|
||||
n=f.normal_at(c)
|
||||
except Exception as ex:
|
||||
n=None
|
||||
rows.append((gt, round(a,1), [round(x,3) for x in (c.X,c.Y,c.Z)], None if n is None else [round(x,4) for x in (n.X,n.Y,n.Z)]))
|
||||
rows.sort(key=lambda r: -r[1])
|
||||
for r in rows[:25]: print(r)
|
||||
Reference in new issue
Block a user