@@ -86,7 +86,13 @@ def export_jcad_to_fcstd(jcad_dict: dict) -> "fc.Document":
8686
8787 prop_handlers = build_prop_handlers ()
8888 coordinate_names = {
89- "Origin" , "X_Axis" , "Y_Axis" , "Z_Axis" , "XY_Plane" , "XZ_Plane" , "YZ_Plane"
89+ "Origin" ,
90+ "X_Axis" ,
91+ "Y_Axis" ,
92+ "Z_Axis" ,
93+ "XY_Plane" ,
94+ "XZ_Plane" ,
95+ "YZ_Plane" ,
9096 }
9197
9298 # 1) Sanitize JCAD names in place and build a mapping
@@ -104,20 +110,19 @@ def export_jcad_to_fcstd(jcad_dict: dict) -> "fc.Document":
104110
105111 # 2) Separate PartDesign::Body entries from others
106112 body_objs = [
107- o for o in jcad_dict .get ("objects" , [])
108- if o ["shape" ] == "PartDesign::Body"
113+ o for o in jcad_dict .get ("objects" , []) if o ["shape" ] == "PartDesign::Body"
109114 ]
110115 other_objs = [
111- o for o in jcad_dict .get ("objects" , [])
116+ o
117+ for o in jcad_dict .get ("objects" , [])
112118 if o not in body_objs and o ["name" ] not in coordinate_names
113119 ]
114120
115121 # Helper: determine RGB tuple and visibility flag
116122 def _color_and_visibility (jcad_obj ):
117123 opts = jcad_dict .get ("options" , {}).get (jcad_obj ["name" ], {})
118- hexcol = (
119- jcad_obj .get ("parameters" , {}).get ("Color" )
120- or opts .get ("color" , "#808080" )
124+ hexcol = jcad_obj .get ("parameters" , {}).get ("Color" ) or opts .get (
125+ "color" , "#808080"
121126 )
122127 rgb = _hex_to_rgb (hexcol )
123128 visible = opts .get ("visible" )
@@ -152,16 +157,17 @@ def _color_and_visibility(jcad_obj):
152157
153158 rgb , visible = _color_and_visibility (obj )
154159 default_camera = (
155- "OrthographicCamera {\n "
156- " viewportMapping ADJUST_CAMERA\n "
157- " position 5.0 0.0 10.0\n "
158- " orientation 0.7 0.2 0.4 1.0\n "
159- " nearDistance 0.2\n "
160- " farDistance 20.0\n "
161- " aspectRatio 1.0\n "
162- " focalDistance 8.0\n "
163- " height 16.0\n "
164- "}" )
160+ "OrthographicCamera {\n "
161+ " viewportMapping ADJUST_CAMERA\n "
162+ " position 5.0 0.0 10.0\n "
163+ " orientation 0.7 0.2 0.4 1.0\n "
164+ " nearDistance 0.2\n "
165+ " farDistance 20.0\n "
166+ " aspectRatio 1.0\n "
167+ " focalDistance 8.0\n "
168+ " height 16.0\n "
169+ "}"
170+ )
165171 guidata [obj ["name" ]] = {
166172 "ShapeColor" : {"type" : "App::PropertyColor" , "value" : rgb },
167173 "Visibility" : {"type" : "App::PropertyBool" , "value" : visible },
@@ -176,4 +182,4 @@ def _color_and_visibility(jcad_obj):
176182 path = tmp .name
177183 OfflineRenderingUtils .save (doc , filename = path , guidata = guidata )
178184
179- return fc .app .openDocument (path )
185+ return fc .app .openDocument (path )
0 commit comments