Skip to content

Commit 005bdc8

Browse files
latest
1 parent e8040c6 commit 005bdc8

File tree

3 files changed

+58
-52
lines changed

3 files changed

+58
-52
lines changed

examples/basic_usage.ipynb

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"id": "d59622c6",
77
"metadata": {},
88
"outputs": [],
@@ -27,7 +27,7 @@
2727
},
2828
{
2929
"cell_type": "code",
30-
"execution_count": 3,
30+
"execution_count": 2,
3131
"id": "f6cb8c80",
3232
"metadata": {},
3333
"outputs": [
@@ -37,7 +37,7 @@
3737
"'tcs00001'"
3838
]
3939
},
40-
"execution_count": 3,
40+
"execution_count": 2,
4141
"metadata": {},
4242
"output_type": "execute_result"
4343
}
@@ -78,7 +78,7 @@
7878
},
7979
{
8080
"cell_type": "code",
81-
"execution_count": 4,
81+
"execution_count": 3,
8282
"id": "56285449",
8383
"metadata": {},
8484
"outputs": [],
@@ -88,7 +88,7 @@
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 5,
91+
"execution_count": 4,
9292
"id": "d00b88d6",
9393
"metadata": {},
9494
"outputs": [
@@ -98,6 +98,14 @@
9898
"text": [
9999
"package MyStructure {\n",
100100
"\n",
101+
"\n",
102+
" part def Onshape_Component {\n",
103+
" attribute onshape_url;\n",
104+
" }\n",
105+
" part def Omniverse_Component {\n",
106+
" attribute ov_filepath;\n",
107+
" }\n",
108+
"\n",
101109
" part def Component{\n",
102110
" attribute tx;\n",
103111
" attribute ty;\n",
@@ -114,15 +122,15 @@
114122
"\n",
115123
" part def Context {\n",
116124
" part rootelement :Component {\n",
117-
" part nx00001 subsets children {\n",
125+
" part nx00001: Onshape_Component, Omniverse_Component subsets children {\n",
118126
" attribute :>> tx=1.0;\n",
119127
" attribute :>> ty=1.0;\n",
120128
" attribute :>> tz=1.0;\n",
121129
" attribute :>> rx=1.0;\n",
122130
" attribute :>> ry=1.0;\n",
123131
" attribute :>> rz=1.0;\n",
124132
" attribute :>> typeID = 0;\n",
125-
" part tcs00001 subsets children {\n",
133+
" part tcs00001: Onshape_Component, Omniverse_Component subsets children {\n",
126134
" attribute :>> tx=1.0;\n",
127135
" attribute :>> ty=1.0;\n",
128136
" attribute :>> tz=1.0;\n",
@@ -152,7 +160,7 @@
152160
},
153161
{
154162
"cell_type": "code",
155-
"execution_count": null,
163+
"execution_count": 5,
156164
"id": "5bfc772f",
157165
"metadata": {},
158166
"outputs": [
@@ -166,7 +174,7 @@
166174
],
167175
"source": [
168176
"#flexo config\n",
169-
"BASE_URL = \"URL\" \n",
177+
"BASE_URL = \"http://192.168.1.214:31083/\" \n",
170178
"\n",
171179
"BEARER_TOKEN = \"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJmbGV4by1tbXMtYXVkaWVuY2UiLCJpc3MiOiJodHRwOi8vZmxleG8tbW1zLXNlcnZpY2VzIiwidXNlcm5hbWUiOiJ1c2VyMDEiLCJncm91cHMiOlsic3VwZXJfYWRtaW5zIl0sImV4cCI6MTc2OTY3MzYwMH0.UqU5KOPSCbYyqbj3BBZs4u7lWbpHyDHPEd7Tbd4wWsM\"\n",
172180
"\n",
@@ -187,8 +195,8 @@
187195
"metadata": {},
188196
"outputs": [],
189197
"source": [
190-
"project, proj_id = v2.get_project_by_name(client, name = \"myproject\")\n",
191-
"created_project, example_project_id, _ = v2.create_sysml_project(client, name=\"myproject\")\n",
198+
"project, proj_id = v2.get_project_by_name(client, name = \"Flexo_SysIDE_TestProject\")\n",
199+
"created_project, example_project_id, _ = v2.create_sysml_project(client, name=\"Flexo_SysIDE_TestProject\")\n",
192200
"change_payload_str = convert_sysml_string_textual_to_json(sysml_text, minimal=False)\n",
193201
"commit1_response, commit1_id = v2.commit_to_project(client, example_project_id, change_payload_str, commit_msg = \"default commit message\")"
194202
]
@@ -205,55 +213,27 @@
205213
},
206214
{
207215
"cell_type": "code",
208-
"execution_count": null,
216+
"execution_count": 11,
209217
"id": "6b1870b8",
210218
"metadata": {},
211219
"outputs": [
212220
{
213-
"name": "stdout",
214-
"output_type": "stream",
215-
"text": [
216-
"Walking the ownership tree printing all elements:\n",
217-
"[{'abs_rx': 1.0,\n",
218-
" 'abs_ry': 1.0,\n",
219-
" 'abs_rz': 1.0,\n",
220-
" 'abs_tx': 1.0,\n",
221-
" 'abs_ty': 1.0,\n",
222-
" 'abs_tz': 1.0,\n",
223-
" 'name': 'nx00001',\n",
224-
" 'parent_name': None,\n",
225-
" 'parent_typeID': None,\n",
226-
" 'rx': 1.0,\n",
227-
" 'ry': 1.0,\n",
228-
" 'rz': 1.0,\n",
229-
" 'tx': 1.0,\n",
230-
" 'ty': 1.0,\n",
231-
" 'typeID': 1000.0,\n",
232-
" 'tz': 1.0},\n",
233-
" {'abs_rx': 2.469355406085109,\n",
234-
" 'abs_ry': 0.28857876165748914,\n",
235-
" 'abs_rz': 2.469355406085109,\n",
236-
" 'abs_tx': 2.1735727354212466,\n",
237-
" 'abs_ty': 2.2703235189345308,\n",
238-
" 'abs_tz': 0.9051043103313733,\n",
239-
" 'name': 'tcs00001',\n",
240-
" 'parent_name': 'nx00001',\n",
241-
" 'parent_typeID': 1000.0,\n",
242-
" 'rx': 1.0,\n",
243-
" 'ry': 1.0,\n",
244-
" 'rz': 1.0,\n",
245-
" 'tx': 1.0,\n",
246-
" 'ty': 1.0,\n",
247-
" 'typeID': 2.0,\n",
248-
" 'tz': 1.0}]\n"
221+
"ename": "ImportError",
222+
"evalue": "cannot import name 'find_part_with_components' from 'geometry_api.geometry_api' (/Users/johannes/sysmlv2_dls/.venv/lib/python3.13/site-packages/geometry_api/geometry_api.py)",
223+
"output_type": "error",
224+
"traceback": [
225+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
226+
"\u001b[31mImportError\u001b[39m Traceback (most recent call last)",
227+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[11]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpprint\u001b[39;00m\n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mtransformation_api\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mtransformations\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m transformation_matrix, euler_from_matrix\n\u001b[32m----> \u001b[39m\u001b[32m5\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mgeometry_api\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mgeometry_api\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m components_from_part_world, find_part_with_components, walk_ownership_tree, find_part_by_name\n\u001b[32m 7\u001b[39m \u001b[38;5;66;03m# If needed to import your transformations file:\u001b[39;00m\n\u001b[32m 8\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01msyside\u001b[39;00m\n",
228+
"\u001b[31mImportError\u001b[39m: cannot import name 'find_part_with_components' from 'geometry_api.geometry_api' (/Users/johannes/sysmlv2_dls/.venv/lib/python3.13/site-packages/geometry_api/geometry_api.py)"
249229
]
250230
}
251231
],
252232
"source": [
253233
"# example_mypattern_components.py\n",
254234
"import json\n",
255235
"import pprint\n",
256-
"from geometry_api.transformations import transformation_matrix, euler_from_matrix\n",
236+
"from transformation_api.transformations import transformation_matrix, euler_from_matrix\n",
257237
"from geometry_api.geometry_api import components_from_part_world, find_part_with_components, walk_ownership_tree, find_part_by_name\n",
258238
"\n",
259239
"# If needed to import your transformations file:\n",
@@ -332,7 +312,7 @@
332312
],
333313
"metadata": {
334314
"kernelspec": {
335-
"display_name": ".venv (3.13.2)",
315+
"display_name": ".venv",
336316
"language": "python",
337317
"name": "python3"
338318
},
@@ -346,7 +326,7 @@
346326
"name": "python",
347327
"nbconvert_exporter": "python",
348328
"pygments_lexer": "ipython3",
349-
"version": "3.13.2"
329+
"version": "3.13.7"
350330
}
351331
},
352332
"nbformat": 4,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
from flexo_syside_lib.committer import commit_sysml_to_flexo
3+
4+
5+
DEFAULT_PROJECT_NAME = "Flexo_SysIDE_TestProject"
6+
sysml_sample = """
7+
package TestPackage {
8+
part Satellite {
9+
attribute mass = 500.0;
10+
}
11+
}
12+
"""
13+
14+
FLEXO_API_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJmbGV4by1tbXMtYXVkaWVuY2UiLCJpc3MiOiJodHRwOi8vZmxleG8tbW1zLXNlcnZpY2VzIiwidXNlcm5hbWUiOiJ1c2VyMDEiLCJncm91cHMiOlsic3VwZXJfYWRtaW5zIl0sImV4cCI6MTc2OTY3MzYwMH0.UqU5KOPSCbYyqbj3BBZs4u7lWbpHyDHPEd7Tbd4wWsM"
15+
16+
result = commit_sysml_to_flexo(
17+
sysml_output=sysml_sample,
18+
project_name=DEFAULT_PROJECT_NAME,
19+
verbose=True,
20+
)
21+
22+
print("Commit Result:", result)

tests/test_geometry_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from multiprocessing import context
12
from annotated_types import doc
23
import pytest
34
import syside
@@ -101,8 +102,11 @@ def test_load_from_sysml_and_regenerate_text():
101102
if context:
102103
break
103104

104-
assert context is not None, "Could not find PartUsage for RootComponent"
105+
assert context is not None, "Could not find PartUsage for geometryroot"
105106
print("Loading from SysMLv2 model...")
106107
root_comp = load_from_sysml(context)
107108

108109
print(root_comp.to_textual())
110+
#test_load_from_sysml_and_regenerate_text()
111+
112+

0 commit comments

Comments
 (0)