- changing compos including sketches and bodies

This commit is contained in:
bklronin 2024-12-31 17:21:56 +01:00
parent 6c8462a7f3
commit 601121dc15

24
main.py
View File

@ -177,10 +177,10 @@ class MainWindow(QMainWindow):
# Create and initialize a new Component
compo = Component()
compo.id = f"Component {len(self.project.timeline) + 1}"
compo.id = f"Component {len(self.project.timeline)}"
compo.descript = "Initial Component"
compo.sketches = {}
compo.body = {}
compo.bodies = {}
self.project.timeline.append(compo)
# Create a button for the new component
@ -201,7 +201,7 @@ class MainWindow(QMainWindow):
def get_activated_compo(self):
# Iterate through all items in the layout
total_elements = self.compo_layout.count()
print(total_elements)
#print(total_elements)
for i in range(total_elements):
widget = self.compo_layout.itemAt(i).widget() # Get the widget at the index
if widget: # Check if the widget is not None
@ -280,8 +280,10 @@ class MainWindow(QMainWindow):
def on_compo_change(self):
compo_id = self.get_activated_compo()
if compo_id:
if compo_id is not None:
self.ui.sketch_list.clear()
self.ui.body_list.clear()
print("id", compo_id)
print("sketch_registry", self.project.timeline[compo_id].sketches)
@ -289,6 +291,9 @@ class MainWindow(QMainWindow):
print(sketch)
self.ui.sketch_list.addItem(sketch)
for body in self.project.timeline[compo_id].bodies:
self.ui.body_list.addItem(body)
def edit_sketch(self):
name = self.ui.sketch_list.currentItem().text()
@ -398,7 +403,9 @@ class MainWindow(QMainWindow):
def draw_mesh(self):
name = self.ui.body_list.currentItem().text()
print("selected_for disp", name)
model = self.project.timeline[-1].body[name].sdf_body
compo_id = self.get_activated_compo()
model = self.project.timeline[compo_id].bodies[name].sdf_body
vesta = vesta_mesh
model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0)
@ -442,7 +449,6 @@ class MainWindow(QMainWindow):
selected = self.ui.sketch_list.currentItem()
name = selected.text()
# TODO: add selected element from timeline
sel_compo = self.project.timeline[self.get_activated_compo()]
#print(sel_compo)
sketch = sel_compo.sketches[name]
@ -480,7 +486,7 @@ class MainWindow(QMainWindow):
# Create body element and assign known stuff
name_op = f"extrd-{name}"
sel_compo.body
body = Body()
body.sketch = sketch #we add the sketches for reference here
body.id = name_op
@ -496,7 +502,7 @@ class MainWindow(QMainWindow):
edges = interactor_mesh.generate_mesh(interactor.lines, 0, -length)
body.interactor = interactor
sel_compo.body[name_op] = body
sel_compo.bodies[name_op] = body
offset_vector = interactor.vector_to_centroid(None, centroid, normal)
#print("off_ved", offset_vector)
@ -567,7 +573,7 @@ class Component:
"""
id = None
sketches: dict = None
body: dict = None
bodies: dict = None
connector = None
# Description