# execute_rhino_code (IronPython 2.7) - 형식 VII (C8/C10) 생성 예: 단면 오프셋 120 교점 + 고정길이 + KDS 필렛 # 단면(대호지교 P1, s>0 쪽): 끝면 s=12100 (z9238~10738), 끝헌치 (12100,9238)->(8100,7738), # 바닥 z=7738, 내측헌치 (4900,7738)->(3400,8238) import scriptcontext as sc, Rhino, math, System from Rhino.Geometry import Point3d, Vector3d, Polyline, Curve, Brep, PipeCapMode d = sc.doc tol = d.ModelAbsoluteTolerance; atol = d.ModelAngleToleranceRadians COV = 120.0; r = 12.7; Rc = 76.2 + 12.7 # H25: 3db + db/2 A_LEG = 630.0; D_LEN = 2331.0 # 재료표 a, d # --- 2D 오프셋선 교점 --- sE = 12100.0 - COV # 끝면 오프셋 dx = -4000.0; dz = -1500.0; Ln = math.sqrt(dx*dx + dz*dz) nx = -1500.0/Ln; nz = 4000.0/Ln # 안쪽 법선 p0s = 12100.0 + COV*nx; p0z = 9238.0 + COV*nz t = (sE - p0s)/dx; Pab = (sE, p0z + t*dz) zf = 7738.0 + COV t = (zf - p0z)/dz; Pbc = (p0s + t*dx, zf) dx2 = -1500.0; dz2 = 500.0; L2 = math.sqrt(dx2*dx2 + dz2*dz2) q0s = 4900.0 + COV*500.0/L2; q0z = 7738.0 + COV*1500.0/L2 t = (zf - q0z)/dz2; Pcd = (q0s + t*dx2, zf) D = (Pcd[0] + D_LEN*dx2/L2, zf + D_LEN*dz2/L2) A = (sE, Pab[1] + A_LEG) pts2 = [A, Pab, Pbc, Pcd, D] # 결과: b=4167.1, c=3158.8 (도면과 일치) # --- 3D 생성 / 블록 교체 --- ang = math.radians(19.105) u = Vector3d(math.cos(ang), math.sin(ang), 0); wv = Vector3d(-math.sin(ang), math.cos(ang), 0) c = Point3d(480714926, 153833329.5, 9331) W_LIST = [-1630, -1375, -1125, -875, -625, -375, -125, 125, 375, 625, 875, 1125, 1375, 1630] # 1CYCLE (도면) out = [] for nm, sg in [("C8", 1.0), ("C10", -1.0)]: idf = d.InstanceDefinitions.Find(nm) inst = None for o in d.Objects.FindByLayer(d.Layers[d.Layers.FindByFullPath("P1_두부_주철근_1CYCLE::" + nm + "_H25", -1)]): if o.ObjectType == Rhino.DocObjects.ObjectType.InstanceReference: inst = o ok, inv = inst.Geometry.Xform.TryGetInverse() olds = list(idf.GetObjects()) # 백업 bg = []; ba = [] for o in olds: bg.append(o.Geometry.Duplicate()); ba.append(o.Attributes.Duplicate()) if d.InstanceDefinitions.Find(nm + "_backup") is None: d.InstanceDefinitions.Add(nm + "_backup", "backup", Point3d.Origin, bg, ba) newg = []; newa = [] i = 0 for w in W_LIST: wpts = [] for p in pts2: wpts.append(c + u*(sg*p[0]) + wv*w + Vector3d(0, 0, p[1] - c.Z)) fc = Curve.CreateFilletCornersCurve(Polyline(wpts).ToPolylineCurve(), Rc, tol, atol) bp = Brep.CreatePipe(fc, r, False, PipeCapMode.NONE, False, tol, atol)[0] bp.Transform(inv) newg.append(bp); newa.append(olds[min(i, len(olds)-1)].Attributes.Duplicate()) i += 1 out.append(nm + " modify=" + str(d.InstanceDefinitions.ModifyGeometry(idf.Index, newg, newa))) d.Views.Redraw() result = "\n".join(out) print(result)