# -*- coding: utf-8 -*- import rhinoscriptsyntax as rs import Rhino import scriptcontext as sc def clear_document(): """Löscht alle Objekte in der aktuellen Rhino-Szene.""" objs = rs.AllObjects() if objs: rs.DeleteObjects(objs) print("Alle Objekte wurden gelöscht.") else: print("Keine Objekte zum Löschen gefunden.") def create_facade_box(): """ Erstellt eine Fassadenhülle als geschlossene Box, basierend auf dem Rechteck: (2,-44,0), (75,-44,0), (75,1,0), (2,1,0) Das Rechteck wird von z=0 bis z=262 extrudiert. """ # Definiere die vier Ecken des Rechtecks (unten) bottom_pts = [ (2, -44, 0), (75, -44, 0), (75, 1, 0), (2, 1, 0) ] # Erstelle die obere Fläche (alle z-Werte auf 262 setzen) top_pts = [(x, y, 262) for (x, y, z) in bottom_pts] # rs.AddBox erwartet eine Liste von 8 Punkten in folgender Reihenfolge: # [A, B, C, D, E, F, G, H] mit: # A, B, C, D = untere Eckpunkte in korrekter Reihenfolge, # E, F, G, H = die entsprechenden oberen Eckpunkte. box_points = bottom_pts + top_pts facade_box = rs.AddBox(box_points) if facade_box: print("Fassadenvolumen erstellt:", facade_box) else: print("Fehler beim Erstellen des Fassadenvolumens.") return facade_box def create_hilfskurven(): """ Erzeugt 9 Hilfskurven aus den kopierten Daten. Die Daten sind als Dictionary organisiert, Schlüssel 1 bis 9, wobei jeder Wert eine Liste von (x, y, z)-Tupeln darstellt. """ hilfskurven_daten = { 1: [ (0.13546825530111165, -49.70697256277337, 0), (-1.0956372344606826, -43.15235937562431, 0), (0.7076913638182487, -37.69579332122987, 0), (-2.337492295261604, -29.81020408860733, 0), (-3.767241598941723, -24.945942316987296, 0), (-3.5561462867138243, -19.839398703998246, 0), (1.113734903634595, -6.988138430502113, 0), (-0.1501883532427746, -2.780088836845648, 0), (-2.0305998063401876, 1.0394968883376374, 0), (0.31486005237727116, 3.7499568600308293, 0), (3.367118486707468, 3.225069182581622, 0), (9.200700562722522, 1.8524616352839645, 0), (18.036861648451204, 1.7666736635778488, 0), (22.884209910202028, 2.9393853533114704, 0), (28.419957137458024, 7.698789972117997, 0), (35.794971791614664, 2.9677052674632955, 0), (40.59909820715648, 3.482433097699925, 0), (51.311268255301115, 3.929202437226652, 0), (57.6741395322646, 9.495814922132693, 0), (66.13901162214344, 3.231733937884444, 0), (77.63728075530113, 3.1910899372266703, 0), (78.87695996467174, 0.515468949084268, 0), (78.8674682553011, -5.912297562773364, 0), (82.91988537482203, -11.44161482149715, 0), (78.71544997948168, -20.345429711294607, 0), (76.11373490363458, -30.15160813944149, 0), (80.34369325530112, -46.01641006277336, 0), (68.28785575530112, -49.95301006277337, 0), (53.771643255301115, -45.27829756277335, 0), (36.54901825530111, -45.52433506277335, 0), (32.44839325530112, -51.839297562773375, 0), (21.786768255301112, -49.953010062773366, 0), (11.453193255301112, -45.27829756277335, 0), (0.13546825530111165, -49.70697256277337, 0), (-1.0956372344606826, -43.15235937562431, 0), (0.7076913638182487, -37.69579332122987, 0) ], 2: [ (0.13546825528865156, -49.706972562948366, 32.75), (-0.4580120403160254, -43.32731268393068, 32.75), (1.499008440707794, -37.64746603743846, 32.75), (-2.068253236028304, -30.31375866544108, 32.75), (-3.7672415989541834, -24.94594231716228, 32.75), (-1.5404079240564443, -17.666117713525388, 32.75), (-0.7778190014871962, -11.884550932432886, 32.75), (0.15940231756229878, -4.229848503487832, 32.75), (-2.3284047593656854, -0.6116147779037908, 32.75), (-1.1464095064018147, 3.7223678162970533, 32.75), (2.681003693671664, 4.510364651606328, 32.75), (8.590979958491026, 3.3846548868788093, 32.75), (14.163243293892128, 0.25743283865591365, 32.75), (18.722367841038505, 3.7786533045334454, 32.75), (28.419957137445564, 7.698789971943008, 32.75), (33.41288027073233, 2.6529435398059285, 32.75), (40.59170756176198, 5.104057815523227, 32.75), (48.91144136260658, 0.25743283865591365, 32.75), (54.80475924286991, 6.74131037036281, 32.75), (64.20487196789904, 2.5564947398024764, 32.75), (75.92751576800329, 2.7519271059792207, 32.75), (78.25845013823071, 0.14551256746600302, 32.75), (78.86746825528864, -5.912297562948352, 32.75), (82.91988537480958, -7.506895324048891, 32.75), (78.71544997946923, -20.345429711469592, 32.75), (79.95924386967218, -30.519672370648973, 32.75), (80.34369325528866, -46.01641006294835, 32.75), (69.10662742155965, -48.56378164582403, 32.75), (56.5542035779596, -43.261085679862575, 32.75), (41.65297730585315, -46.0905890242291, 32.75), (33.729036340865754, -49.67488455500736, 32.75), (21.29280219102925, -48.403038933705595, 32.75), (14.71317563503626, -43.261085679862575, 32.75), (0.13546825528865156, -49.706972562948366, 32.75), (-0.4580120403160254, -43.32731268393068, 32.75), (1.499008440707794, -37.64746603743846, 32.75) ], 3: [ (0.44845955803263676, -50.89211159244399, 65.5), (-4.954947312659356, -40.87329468636925, 65.5), (-2.330957328960212, -35.97221799223689, 65.5), (-2.068253236028304, -30.31375866544108, 65.5), (-6.081327963321114, -25.832413260169517, 65.5), (-1.5404079240564443, -17.666117713525388, 65.5), (-3.2503248970196728, -8.331667032124276, 65.5), (-4.193992585786819, -1.7259932107542602, 65.5), (-3.593476783844085, 2.0486775443142915, 65.5), (5.156896330178524, 1.9628895726081987, 65.5), (9.188931000365429, 0.25743283865591365, 65.5), (11.590994208136344, 0.25743283865591365, 65.5), (16.65248453879648, 0.25743283865591365, 65.5), (23.687098218697002, 2.649193346257039, 65.5), (31.836955530776894, 6.509652073031705, 65.5), (35.86899020096379, 2.220253487726502, 65.5), (43.63066076459596, 6.23169196385461, 65.5), (54.09859370249953, -1.2227565614914113, 65.5), (63.435409519615185, 2.382450575930052, 65.5), (73.65143742413018, 2.3496295066718336, 65.5), (76.6989350805355, 1.047379414304037, 65.5), (78.21325751079334, -1.257999389142957, 65.5), (79.88859645052166, -9.847308241367553, 65.5), (78.302034946237, -18.44938730172971, 65.5), (76.11373490363458, -28.442097147699243, 65.5), (76.47039677104841, -38.530017552059455, 65.5), (79.76123927502792, -47.98027439490843, 65.5), (68.91641933641993, -45.747360132767646, 65.5), (56.5542035779596, -43.261085679862575, 65.5), (52.7692916760293, -47.340880762553226, 65.5), (36.87055040179361, -48.752873515014365, 65.5), (23.373672482166075, -45.90366745878552, 65.5), (14.71317563503626, -43.261085679862575, 65.5), (0.44845955803263676, -50.89211159244399, 65.5), (-4.954947312659356, -40.87329468636925, 65.5), (-2.330957328960212, -35.97221799223689, 65.5) ], 4: [ (9.290112907831999, -47.35541994740775, 98.25), (-2.3279105549011683, -46.10954282863603, 98.25), (1.1137349036345858, -35.97221799223689, 98.25), (-2.068253236028304, -30.31375866544108, 98.25), (1.1137349036345858, -19.25689799926626, 98.25), (-0.20590467158946013, -11.057283663596788, 98.25), (1.6702782696230498, -5.150781811631524, 98.25), (-1.194191659797716, 0.4635458172047811, 98.25), (2.7805576535224645, 3.7360897524988834, 98.25), (9.730916091128593, 2.353949953218473, 98.25), (13.405297202967086, 1.1521921158783084, 98.25), (17.918830504642003, 0.25743283865591365, 98.25), (23.435371206689098, 1.608104570592932, 98.25), (31.094700445895015, 2.6111119709651347, 98.25), (42.362144894649504, 6.23169196385461, 98.25), (48.203148485952774, 2.817672714289197, 98.25), (53.944913203056714, 1.7854246543174668, 98.25), (60.54054151967921, 1.5250027521305447, 98.25), (69.07882900602634, 2.3073824050787564, 98.25), (76.05004771641272, 4.415100559084874, 98.25), (77.96444235025768, 1.5135961921636294, 98.25), (76.1137349036346, -2.4946675724492526, 98.25), (79.85014104008386, -11.337463629225232, 98.25), (76.11373490363458, -21.50182642060334, 98.25), (79.06214420477458, -27.435113264828523, 98.25), (77.84297212098402, -35.18591740086652, 98.25), (81.82013312835696, -43.92676131808643, 98.25), (68.91641933641993, -45.747360132767646, 98.25), (60.7674218535664, -43.261085679862575, 98.25), (52.75573270156698, -46.12136970348891, 98.25), (39.96555949620828, -46.538482687166564, 98.25), (29.41363897635745, -45.165875139868895, 98.25), (22.636389211575196, -43.261085679862575, 98.25), (9.290112907831999, -47.35541994740775, 98.25), (-2.3279105549011683, -46.10954282863603, 98.25), (1.1137349036345858, -35.97221799223689, 98.25) ], 5: [ (7.808695026270962, -43.261085679862575, 131), (2.660783333198842, -44.97155733414326, 131), (-0.46535996821193293, -42.56508087661638, 131), (-1.2204060447222855, -34.04969920351105, 131), (1.1137349036345858, -28.572147448053745, 131), (-2.1297960644539673, -23.052475863994527, 131), (0.47233394556497843, -17.730579564637075, 131), (-2.792421572682447, -8.569927603448033, 131), (-2.2876941780707787, -2.9309805848161443, 131), (2.368019046419513, 4.087333380460266, 131), (13.405297202967086, 1.1521921158783084, 131), (19.755037960862346, 2.749782399378298, 131), (29.392945893276558, 0.25743283865591365, 131), (38.613734903634594, 2.3056840389901367, 131), (47.271816250265275, 5.886227502672689, 131), (55.72003273891174, 4.814560742122755, 131), (64.27076013748172, 0.25743283865591365, 131), (69.699291136907, 4.9246334606721005, 131), (78.93476093129908, 1.4778670768711824, 131), (78.3695592708985, -9.01901953765543, 131), (80.25503781585603, -14.573920309058066, 131), (78.89326518691237, -23.20216818286877, 131), (76.78062496175875, -30.278266409577554, 131), (78.05898667628006, -35.636923642349245, 131), (82.25230556028102, -44.93103195518632, 131), (74.4549556179747, -44.72860410044892, 131), (66.89625862488829, -48.79149068196102, 131), (55.78594334831503, -44.94720777736936, 131), (49.567088340255175, -48.61991473854881, 131), (42.722540597832904, -44.89756047356277, 131), (36.96457793271329, -44.22173700512024, 131), (27.002046514874884, -43.261085679862575, 131), (14.61454447378913, -45.59074970327496, 131), (7.808695026270962, -43.261085679862575, 131), (2.660783333198842, -44.97155733414326, 131), (-0.46535996821193293, -42.56508087661638, 131) ], 6: [ (12.274812090896113, -43.261085679862575, 163.75), (8.834884233205958, -46.718669967811806, 163.75), (-1.6942862529413287, -43.48812902319843, 163.75), (1.1137349036345858, -37.326171295509965, 163.75), (-1.2755124267877365, -30.236928667052837, 163.75), (0.14266414645063377, -22.957558013810548, 163.75), (-1.3714211156566853, -17.0858615095407, 163.75), (-1.262914403410914, -10.548298388142124, 163.75), (-0.7805585743465144, -4.530032506699516, 163.75), (1.210969939399074, 5.0343118381016625, 163.75), (12.181488425645412, 0.9354460004195789, 163.75), (17.01917548262245, 5.182270516086451, 163.75), (28.521206612603773, 4.815089205720439, 163.75), (38.997779614842784, 2.7137899661957388, 163.75), (48.30674800440065, 0.25743283865591365, 163.75), (54.844468756275745, 7.242982859065797, 163.75), (64.8927051972742, -0.14485389289972544, 163.75), (69.11651530401507, 2.789781147523486, 163.75), (78.70241884708118, 1.0223580674646973, 163.75), (77.83618518312333, -9.053307181728872, 163.75), (76.73567996342706, -16.393497702634562, 163.75), (77.83618518312333, -25.420564305984445, 163.75), (76.73567996342706, -31.210652480860364, 163.75), (76.73567996342706, -38.037509026956826, 163.75), (78.81938704051423, -44.514427043234946, 163.75), (72.98224992911614, -43.66337241141822, 163.75), (70.63347462031861, -50.2163411424873, 163.75), (56.55503623942776, -44.472451388818776, 163.75), (51.30497689814674, -47.155095392794756, 163.75), (43.89080138624331, -44.697593341764275, 163.75), (37.53054121553291, -45.14787724765529, 163.75), (31.37572307688527, -45.31166801842314, 163.75), (25.151856942324013, -46.06367640944868, 163.75), (12.274812090896113, -43.261085679862575, 163.75), (8.834884233205958, -46.718669967811806, 163.75), (-1.6942862529413287, -43.48812902319843, 163.75) ], 7: [ (14.892957156978547, -44.30750934922131, 196.5), (-0.22977907750758278, -49.92223495595759, 196.5), (-3.234140570633376, -41.23429006667865, 196.5), (0.06783469669265287, -35.723487034790246, 196.5), (1.1137349036345858, -29.266338458296122, 196.5), (-2.175029808829613, -23.441229268375437, 196.5), (1.1137349036345858, -18.569319764078124, 196.5), (-1.2762023259882518, -13.282907255779262, 196.5), (-2.704585189731483, -6.601368155695592, 196.5), (-0.38953722403685787, 0.25743283865591365, 196.5), (4.6202804173443655, 7.070505072218643, 196.5), (15.635032340103498, 0.25743283865591365, 196.5), (24.00200735835321, 4.846372472430742, 196.5), (36.78895756535484, 1.4003686630135213, 196.5), (43.609941151597944, 6.093480919064894, 196.5), (50.396585556868686, 4.196424432626584, 196.5), (59.17531073795359, 0.25743283865591365, 196.5), (66.95799553113142, 3.8003684353607423, 196.5), (75.92198069470231, 2.4800915508037678, 196.5), (77.9637801629756, -0.8280728162476464, 196.5), (76.1137349036346, -5.997475813193496, 196.5), (79.1879287775537, -16.003784832993574, 196.5), (76.11373490363458, -25.037258253646414, 196.5), (79.67434657712731, -33.58431387472564, 196.5), (77.52021060758702, -45.95322363531182, 196.5), (71.96115004103142, -43.26108567986259, 196.5), (65.98515993198419, -46.509129691967374, 196.5), (56.5542035779596, -48.11920139952248, 196.5), (50.68304432924866, -45.37398630492713, 196.5), (41.5252934391396, -43.261085679862575, 196.5), (36.591627186321524, -46.509129691967395, 196.5), (31.37572307688527, -45.31166801842314, 196.5), (24.93265949695724, -45.13317431355475, 196.5), (14.892957156978547, -44.30750934922131, 196.5), (-0.22977907750758278, -49.92223495595759, 196.5), (-3.234140570633376, -41.23429006667865, 196.5) ], 8: [ (15.208645373351146, -49.15998403890563, 229.25), (5.278714281060356, -47.40091906089154, 229.25), (-0.6384129763144302, -43.261085679862575, 229.25), (-2.268384438730418, -35.48983780977266, 229.25), (0.5428100540087689, -31.030511241560852, 229.25), (-1.0783562336193517, -23.66069321143206, 229.25), (-2.0110205236121055, -18.84697129878829, 229.25), (-1.837616689763454, -10.223093560188936, 229.25), (1.113734903634595, -6.236139457990845, 229.25), (-2.954688212379256, 0.11217044826092433, 229.25), (4.314723422265051, 4.605058576978047, 229.25), (21.32330778044846, 0.25743283865591365, 229.25), (30.472061580750605, 4.633319438531118, 229.25), (44.06394327045002, 5.074768842516983, 229.25), (48.065408659580775, 0.25743283865591365, 229.25), (58.834031483815565, 2.3851984095886998, 229.25), (67.12940237204856, 0.25743283865591365, 229.25), (76.02593277120017, 6.176605255332081, 229.25), (82.16877518966201, -0.17805931549051593, 229.25), (76.93935759399365, -6.862877477577074, 229.25), (81.321486580219, -13.416943838037584, 229.25), (82.48650841820312, -21.572096703926572, 229.25), (79.3827017920522, -32.9134165754885, 229.25), (80.86388427271008, -41.15313620483364, 229.25), (76.09004375497612, -47.90057698164196, 229.25), (68.30488255831855, -43.26108567986259, 229.25), (63.52061605822659, -45.53922064720297, 229.25), (59.38808380346107, -47.542599332030335, 229.25), (52.15094743447873, -47.565498223712474, 229.25), (45.66963931792389, -43.75442149698932, 229.25), (38.61373490363459, -43.261085679862575, 229.25), (32.54320382186068, -44.54827222606225, 229.25), (23.87490474515588, -48.34401878180796, 229.25), (15.208645373351146, -49.15998403890563, 229.25), (5.278714281060356, -47.40091906089154, 229.25), (-0.6384129763144302, -43.261085679862575, 229.25) ], 9: [ (9.685087995840167, -43.261085679862575, 262), (0.0602695074199437, -46.83615593758805, 262), (-2.3037209985078335, -39.85675539627749, 262), (-3.5420017397080894, -30.963648254930167, 262), (1.1137349036345858, -23.815391248910448, 262), (-1.5769608672060622, -18.10951284501195, 262), (-3.6545727161808372, -13.290004948708239, 262), (1.113734903634595, -7.774027101543425, 262), (-2.0222935573259475, 2.807644686895169, 262), (10.19165738996754, 4.721351286931913, 262), (18.87875672336667, 1.7396871442610087, 262), (25.09944773440484, 3.849225867630128, 262), (35.03115269000863, 2.967866561946398, 262), (40.80407729010647, 1.5594661713214963, 262), (48.065408659580775, 0.25743283865591365, 262), (68.29065667549003, 1.8864090576772492, 262), (72.33083640292611, 5.62191909871395, 262), (80.43594670896418, 2.7513591986587973, 262), (77.60378053205396, -4.476651198719407, 262), (80.73872947963311, -15.773576709979197, 262), (74.62568455777453, -19.910827839985842, 262), (79.49852332087973, -27.4708913488061, 262), (74.94066229987435, -32.652212902021446, 262), (78.5222401089274, -39.462756978622856, 262), (77.81812591404591, -44.78207184405715, 262), (72.54068834931748, -45.55885245227646, 262), (67.51887003950769, -44.30815804094575, 262), (65.01372293219727, -47.3990108199518, 262), (61.10496864585142, -51.39832547353512, 262), (47.37013435770188, -44.979804786418285, 262), (38.46835092552178, -44.65491777071312, 262), (26.70438853181204, -46.9625473907146, 262), (15.707635237132326, -44.64102189636942, 262), (9.685087995840167, -43.261085679862575, 262), (0.0602695074199437, -46.83615593758805, 262), (-2.3037209985078335, -39.85675539627749, 262) ] } hilfskurven_ids = [] # Erzeuge die Kurven in der Reihenfolge 1 bis 9 for key in sorted(hilfskurven_daten.keys()): punkte = hilfskurven_daten[key] curve_id = rs.AddInterpCurve(punkte, 3) if curve_id: hilfskurven_ids.append(curve_id) else: print("Fehler beim Erstellen der Kurve", key) return hilfskurven_ids def loft_with_command(hilfskurven_ids): """ Selektiert die Hilfskurven und führt den Loft-Befehl automatisch aus. """ rs.UnselectAllObjects() for cid in hilfskurven_ids: rs.SelectObject(cid) rs.Command("_Loft _Enter _Enter", True) def create_floorplates(loft_id, z_min=0.0, z_max=262.0, count=82, extrude_height=0.75): """ Erzeugt Floor Plates (Stockwerke) aus dem Loft: 1. Es werden 82 horizontale Contour-Kurven von z=0 bis z=262 erzeugt. 2. Anschließend werden aus den geschlossenen Contour-Kurven planare Flächen erstellt. 3. Diese Flächen werden um 'extrude_height' (0.75 m) extrudiert. 4. Danach werden die Contour-Kurven gelöscht. """ loft_brep = rs.coercebrep(loft_id) if not loft_brep: print("Fehler: Loft konnte nicht in ein Brep konvertiert werden.") return [] step = (z_max - z_min) / (count - 1) rs.UnselectAllObjects() rs.SelectObject(loft_id) rs.Command("_-Contour _Enter 0,0,0 0,0,262 " + str(step) + " _Enter", True) contour_curves = rs.LastCreatedObjects() if contour_curves is None: contour_curves = [] print("Contours erzeugt: " + str(len(contour_curves)) + " Kurven") rs.DeleteObject(loft_id) floor_surfaces = [] for cid in contour_curves: srf_ids = rs.AddPlanarSrf(cid) if srf_ids: floor_surfaces.extend(srf_ids) print("Floor Plate Surfaces erzeugt: " + str(len(floor_surfaces))) # Lösche die Contour-Kurven (dies sind reine Kurven, keine Flächen) rs.DeleteObjects(contour_curves) extruded_plates = [] for srf_id in floor_surfaces: centroid_data = rs.SurfaceAreaCentroid(srf_id) if not centroid_data: continue center_pt = centroid_data[0] top_pt = (center_pt[0], center_pt[1], center_pt[2] + extrude_height) path_line = rs.AddLine(center_pt, top_pt) extr = rs.ExtrudeSurface(srf_id, path_line) if extr: extruded_plates.append(extr) rs.DeleteObject(path_line) print("Extruded Floor Plates: " + str(len(extruded_plates))) return extruded_plates def main(): # Optional: clear_document() hier entfernen, falls du die bestehende Szene behalten möchtest. # clear_document() # 1. Erstelle zuerst die Fassadenhülle als komplettes Volumen. facade_id = create_facade_box() # 2. Erzeuge anschließend die 9 Hilfskurven und erstelle daraus ein Loft. hilfskurven_ids = create_hilfskurven() loft_with_command(hilfskurven_ids) rs.DeleteObjects(hilfskurven_ids) loft_objs = rs.LastCreatedObjects() if not loft_objs: print("Fehler: Kein Loft gefunden!") return loft_id = loft_objs[0] # 3. Erzeuge die Floor Plates (Stockwerke) aus dem Loft. create_floorplates(loft_id, 0.0, 262.0, 82, 0.75) print("Fertig!") def create_facade_box(): """ Erstellt ein Fassadenvolumen als Box. Die Basis des Rechtecks ist definiert durch: (2,-44,0), (75,-44,0), (75,1,0), (2,1,0) und wird in Z-Richtung bis 262 extrudiert. """ # Definiere die vier Ecken des Rechtecks (unten) bottom_pts = [ (2, -44, 0), (75, -44, 0), (75, 1, 0), (2, 1, 0) ] # Erstelle die oberen Eckpunkte (z = 262) top_pts = [(x, y, 262) for (x, y, z) in bottom_pts] # Für rs.AddBox benötigen wir eine Liste von 8 Punkten (unten gefolgt von oben) box_points = bottom_pts + top_pts facade_box = rs.AddBox(box_points) if facade_box: print("Fassadenvolumen erstellt:", facade_box) else: print("Fehler beim Erstellen des Fassadenvolumens.") return facade_box if __name__ == "__main__": main()