Skip to content

Commit e13c5b0

Browse files
committed
close to final
1 parent d7e00b6 commit e13c5b0

17 files changed

+236
-84
lines changed

plugin/FF_anchors.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! python3
2-
import rhinoscriptsyntax as rs # type: ignore # noqa: F401
2+
import rhinoscriptsyntax as rs # type: ignore
33

4-
from compas.scene import Scene
54
from compas_fofin.datastructures import CableMesh
65
from compas_fofin.rhino.scene import RhinoCableMeshObject
76
from compas_fofin.session import Session
@@ -15,9 +14,9 @@ def RunCommand(is_interactive):
1514
# Load stuff from session
1615
# =============================================================================
1716

18-
scene: Scene = session.get("scene")
17+
scene = session.scene()
1918

20-
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh") # replace by: find (cf. jQuery)
19+
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh")
2120

2221
if not meshobj:
2322
return
@@ -76,7 +75,7 @@ def RunCommand(is_interactive):
7675
# Session save
7776
# =============================================================================
7877

79-
if session.CONFIG["autosave"]:
78+
if session.CONFIG["autosave.events"]:
8079
session.record(eventname="Add/Remove Anchors")
8180

8281

plugin/FF_anchors_constraints.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#! python3
2-
import rhinoscriptsyntax as rs # type: ignore # noqa: F401
2+
import rhinoscriptsyntax as rs # type: ignore
33

44
import compas_rhino
55
import compas_rhino.conversions
66
import compas_rhino.objects
77
from compas.colors import Color
8-
from compas.scene import Scene
98
from compas_fd.constraints import Constraint
109
from compas_fofin.datastructures import CableMesh
1110
from compas_fofin.rhino.scene import RhinoCableMeshObject
@@ -20,7 +19,7 @@ def RunCommand(is_interactive):
2019
# Load stuff from session
2120
# =============================================================================
2221

23-
scene: Scene = session.get("scene")
22+
scene = session.scene()
2423
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh") # replace by: get_object_by_name (cf. jQuery)
2524

2625
if not meshobj:
@@ -114,7 +113,7 @@ def RunCommand(is_interactive):
114113
# Session save
115114
# =============================================================================
116115

117-
if session.CONFIG["autosave"]:
116+
if session.CONFIG["autosave.events"]:
118117
session.record(eventname=f"{option} Constraints")
119118

120119

plugin/FF_anchors_move.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! python3
22
import rhinoscriptsyntax as rs # type: ignore
33

4-
from compas.scene import Scene
54
from compas_fofin.rhino.scene import RhinoCableMeshObject
65
from compas_fofin.session import Session
76

@@ -14,8 +13,8 @@ def RunCommand(is_interactive):
1413
# Load stuff from session
1514
# =============================================================================
1615

17-
scene: Scene = session.get("scene")
18-
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh") # replace by: get_object_by_name (cf. jQuery)
16+
scene = session.scene()
17+
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh")
1918

2019
if not meshobj:
2120
return
@@ -31,7 +30,7 @@ def RunCommand(is_interactive):
3130
if not option:
3231
return
3332

34-
vertices = meshobj.select_vertices()
33+
vertices = meshobj.select_vertices(show_anchors=True, show_free=False)
3534
if vertices:
3635
if option == "Free":
3736
meshobj.move_vertices(vertices)
@@ -55,7 +54,7 @@ def RunCommand(is_interactive):
5554
# Session save
5655
# =============================================================================
5756

58-
if session.CONFIG["autosave"]:
57+
if session.CONFIG["autosave.events"]:
5958
session.record(eventname="Move Anchors")
6059

6160

plugin/FF_anchors_update.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
#! python3
2-
import rhinoscriptsyntax as rs # type: ignore # noqa: F401
3-
4-
import compas_rhino
5-
import compas_rhino.conversions
6-
import compas_rhino.objects
7-
from compas.scene import Scene
8-
from compas_fd.constraints import Constraint
92
from compas_fofin.datastructures import CableMesh
103
from compas_fofin.rhino.scene import RhinoCableMeshObject
114
from compas_fofin.rhino.scene import RhinoConstraintObject
@@ -20,7 +13,7 @@ def RunCommand(is_interactive):
2013
# Load stuff from session
2114
# =============================================================================
2215

23-
scene: Scene = session.get("scene")
16+
scene = session.scene()
2417

2518
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh")
2619

@@ -33,21 +26,11 @@ def RunCommand(is_interactive):
3326
# Update Constraints
3427
# =============================================================================
3528

36-
constraint: Constraint
37-
3829
for sceneobject in scene.objects:
3930
if isinstance(sceneobject, RhinoConstraintObject):
40-
robj = compas_rhino.objects.find_object(sceneobject.guids[0])
41-
curve = compas_rhino.conversions.curveobject_to_compas(robj)
42-
sceneobject.constraint.geometry = curve
43-
44-
for vertex in mesh.vertices():
45-
guid = mesh.vertex_attribute(vertex, "constraint")
46-
if guid:
47-
constraint = mesh.constraints[guid]
48-
constraint.location = mesh.vertex_point(vertex)
49-
constraint.project()
50-
mesh.vertex_attributes(vertex, "xyz", constraint.location)
31+
sceneobject.update_constraint_geometry()
32+
33+
mesh.update_constraints()
5134

5235
# =============================================================================
5336
# Update scene
@@ -60,7 +43,7 @@ def RunCommand(is_interactive):
6043
# Session save
6144
# =============================================================================
6245

63-
if session.CONFIG["autosave"]:
46+
if session.CONFIG["autosave.events"]:
6447
session.record(eventname="Update Anchors")
6548

6649

plugin/FF_clear.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#! python3
22
import rhinoscriptsyntax as rs # type: ignore
33

4-
from compas.scene import Scene
54
from compas_fofin.session import Session
65

76

87
def RunCommand(is_interactive):
98

109
session = Session(name="FormFinder")
11-
scene: Scene = session.setdefault("scene", factory=Scene)
10+
scene = session.scene()
1211

1312
result = rs.MessageBox(
1413
"Note that this will remove all FormFinder data and objects. Do you wish to proceed?",
@@ -19,7 +18,7 @@ def RunCommand(is_interactive):
1918
if result == 6:
2019
scene.clear()
2120

22-
if session.CONFIG["autosave"]:
21+
if session.CONFIG["autosave.events"]:
2322
session.record(eventname="Clear")
2423

2524

plugin/FF_edges_attrs.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,55 @@
11
#! python3
2-
from compas.scene import Scene
2+
import rhinoscriptsyntax as rs # type: ignore
3+
34
from compas_fofin.rhino.scene import RhinoCableMeshObject
45
from compas_fofin.session import Session
56

67

78
def RunCommand(is_interactive):
89

910
session = Session(name="FormFinder")
10-
scene: Scene = session.setdefault("scene", factory=Scene)
11+
12+
# =============================================================================
13+
# Load stuff from session
14+
# =============================================================================
15+
16+
scene = session.scene()
1117

1218
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh")
1319

1420
if not meshobj:
1521
return
1622

23+
# =============================================================================
24+
# Update attributes
25+
# =============================================================================
26+
27+
rs.UnselectAllObjects()
28+
1729
edges = meshobj.select_edges()
1830
if edges:
1931
meshobj.update_edge_attributes(edges=edges)
2032

33+
# =============================================================================
34+
# Update scene
35+
# =============================================================================
36+
37+
rs.UnselectAllObjects()
38+
39+
meshobj.show_anchors = True
40+
meshobj.show_free = False
41+
meshobj.show_edges = False
42+
43+
meshobj.clear()
44+
meshobj.draw()
45+
46+
# =============================================================================
47+
# Session save
48+
# =============================================================================
49+
50+
if session.CONFIG["autosave.events"]:
51+
session.record(eventname="Edges Attributes")
52+
2153

2254
# =============================================================================
2355
# Run as main

plugin/FF_edges_delete.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#! python3
2-
import rhinoscriptsyntax as rs # type: ignore # noqa: F401
2+
import rhinoscriptsyntax as rs # type: ignore
33

4-
from compas.scene import Scene
54
from compas_fofin.datastructures import CableMesh
65
from compas_fofin.rhino.scene import RhinoCableMeshObject
76
from compas_fofin.session import Session
@@ -15,7 +14,7 @@ def RunCommand(is_interactive):
1514
# Load stuff from session
1615
# =============================================================================
1716

18-
scene: Scene = session.get("scene")
17+
scene = session.scene()
1918

2019
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh") # replace by: get_object_by_name (cf. jQuery)
2120

@@ -28,17 +27,20 @@ def RunCommand(is_interactive):
2827
# Delete edges
2928
# =============================================================================
3029

30+
rs.UnselectAllObjects()
31+
3132
meshobj.show_edges = True
32-
edges = meshobj.select_edges(redraw=True)
33+
edges = meshobj.select_edges()
3334

3435
if edges:
35-
fkeys = set()
36+
faces = set()
3637
for edge in edges:
37-
fkeys.update(mesh.edge_faces(edge))
38+
faces.update(mesh.edge_faces(edge))
3839

39-
for fkey in fkeys:
40-
if fkey is not None:
41-
mesh.delete_face(fkey)
40+
for face in faces:
41+
if face is not None:
42+
if mesh.has_face(face):
43+
mesh.delete_face(face)
4244

4345
mesh.remove_unused_vertices()
4446

@@ -48,16 +50,18 @@ def RunCommand(is_interactive):
4850

4951
rs.UnselectAllObjects()
5052

53+
meshobj.show_anchors = True
54+
meshobj.show_free = False
5155
meshobj.show_edges = False
5256

53-
scene.clear()
54-
scene.draw()
57+
meshobj.clear()
58+
meshobj.draw()
5559

5660
# =============================================================================
5761
# Session save
5862
# =============================================================================
5963

60-
if session.CONFIG["autosave"]:
64+
if session.CONFIG["autosave.events"]:
6165
session.record(eventname="Delete Edges")
6266

6367

plugin/FF_edges_q.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,73 @@
11
#! python3
2+
import rhinoscriptsyntax as rs # type: ignore
3+
4+
from compas_fofin.datastructures import CableMesh
5+
from compas_fofin.rhino.scene import RhinoCableMeshObject
6+
from compas_fofin.session import Session
27

38

49
def RunCommand(is_interactive):
510

6-
print("Not implemented yet...")
11+
session = Session(name="FormFinder")
12+
13+
# =============================================================================
14+
# Load stuff from session
15+
# =============================================================================
16+
17+
scene = session.scene()
18+
19+
meshobj: RhinoCableMeshObject = scene.get_node_by_name(name="CableMesh")
20+
21+
if not meshobj:
22+
return
23+
24+
mesh: CableMesh = meshobj.mesh
25+
26+
# =============================================================================
27+
# Delete edges
28+
# =============================================================================
29+
30+
rs.UnselectAllObjects()
31+
32+
option = rs.GetString(message="Update ForceDensity", strings=["Value", "ScaleFactor"])
33+
if not option:
34+
return
35+
36+
meshobj.show_edges = True
37+
edges = meshobj.select_edges()
38+
39+
if edges:
40+
41+
if option == "Value":
42+
value = rs.GetReal(message="Value")
43+
mesh.edges_attribute("q", value, keys=edges)
44+
45+
elif option == "ScaleFactor":
46+
factor = rs.GetReal(message="ScaleFactor")
47+
48+
for edge in edges:
49+
q = mesh.edge_attribute(edge, "q")
50+
mesh.edge_attribute(edge, "q", q * factor)
51+
52+
# =============================================================================
53+
# Update scene
54+
# =============================================================================
55+
56+
rs.UnselectAllObjects()
57+
58+
meshobj.show_anchors = True
59+
meshobj.show_free = False
60+
meshobj.show_edges = False
61+
62+
meshobj.clear()
63+
meshobj.draw()
64+
65+
# =============================================================================
66+
# Session save
67+
# =============================================================================
68+
69+
if session.CONFIG["autosave.events"]:
70+
session.record(eventname="Delete Edges")
771

872

973
# =============================================================================

0 commit comments

Comments
 (0)