-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
105ec0b
commit 0859d6b
Showing
8 changed files
with
152 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#! python3 | ||
# venv: brg-csd | ||
# r: compas_session>=0.4.5, compas_ags>=1.3.1 | ||
|
||
import rhinoscriptsyntax as rs # type: ignore | ||
|
||
from compas_igs.forms import Attribute | ||
from compas_igs.forms import EdgeAttributesForm | ||
from compas_igs.forms import VertexAttributesForm | ||
from compas_igs.session import IGSSession | ||
|
||
# ============================================================================= | ||
# Command | ||
# ============================================================================= | ||
|
||
|
||
def RunCommand(): | ||
session = IGSSession() | ||
|
||
form = session.find_formdiagram(warn=True) | ||
if not form: | ||
return | ||
|
||
# ============================================================================= | ||
# Attributes | ||
# ============================================================================= | ||
|
||
option = rs.GetString("Form Attributes", strings=["VertexAttributes", "EdgeAttributes"]) | ||
if not option: | ||
return | ||
|
||
if option == "VertexAttributes": | ||
attributes = [ | ||
Attribute(name="x", text="X", value=float, width=48, editable=False), | ||
Attribute(name="y", text="Y", value=float, width=48, editable=False), | ||
Attribute(name="z", text="Z", value=float, width=48, editable=False), | ||
Attribute(name="is_fixed", text="FIXED", value=bool, width=48, editable=False), | ||
Attribute(name="cx", text="CX", value=float, width=48, editable=False), | ||
Attribute(name="cy", text="CY", value=float, width=48, editable=False), | ||
] | ||
|
||
vertices = {} | ||
for vertex in form.diagram.vertices(): | ||
vertices[vertex] = {} | ||
for attr in attributes: | ||
vertices[vertex][attr.name] = form.diagram.vertex_attribute(vertex, name=attr.name) | ||
|
||
form = VertexAttributesForm(attributes, vertices) | ||
if form.show(): | ||
pass | ||
|
||
elif option == "EdgeAttributes": | ||
attributes = [ | ||
Attribute(name="l", text="L", value=float, width=48, editable=False), | ||
Attribute(name="q", text="Q", value=float, width=48, editable=False), | ||
Attribute(name="f", text="F", value=float, width=48, editable=False), | ||
Attribute(name="is_ind", text="IND", value=bool, width=48, editable=False), | ||
] | ||
|
||
edges = {} | ||
for edge in form.diagram.edges(): | ||
edges[edge] = {} | ||
for attr in attributes: | ||
edges[edge][attr.name] = form.diagram.edge_attribute(edge, name=attr.name) | ||
|
||
form = EdgeAttributesForm(attributes, edges) | ||
if form.show(): | ||
pass | ||
|
||
# ============================================================================= | ||
# Update scene | ||
# ============================================================================= | ||
|
||
# if session.settings.autosave: | ||
# session.record(name="Form Attributes") | ||
|
||
|
||
# ============================================================================= | ||
# Main | ||
# ============================================================================= | ||
|
||
if __name__ == "__main__": | ||
RunCommand() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
from .attribute import Attribute | ||
from .edgeforces import EdgeForcesForm | ||
from .edgeattributes import EdgeAttributesForm | ||
from .vertexattributes import VertexAttributesForm | ||
|
||
__all__ = [ | ||
"Attribute", | ||
"EdgeForcesForm", | ||
"EdgeAttributesForm", | ||
"VertexAttributesForm", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from typing import Type | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class Attribute(BaseModel): | ||
name: str | ||
value: Type | ||
text: str | ||
editable: bool = False | ||
expand: bool = False | ||
width: int = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# import ast | ||
# from typing import Any | ||
# from typing import Type | ||
|
||
import Eto.Drawing # type: ignore | ||
import Eto.Forms # type: ignore | ||
import Rhino # type: ignore | ||
import Rhino.UI # type: ignore | ||
from pydantic import BaseModel | ||
|
||
|
||
class SettingsForm(Eto.Forms.Dialog[bool]): | ||
def __init__(self, model: BaseModel): | ||
super().__init__() | ||
self.model = model | ||
|
||
def show(self): | ||
return self.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters