@@ -138,28 +138,31 @@ def toCAF(
138
138
# add leafs and subassemblies
139
139
subassys : Dict [str , Tuple [TDF_Label , Location ]] = {}
140
140
for k , v in assy .traverse ():
141
- # leaf part
142
- lab = tool .NewShape ()
143
- tool .SetShape (lab , Compound .makeCompound (v .shapes ).wrapped )
144
- setName (lab , f"{ k } _part" , tool )
145
-
146
141
# assy part
147
142
subassy = tool .NewShape ()
148
- tool .AddComponent (subassy , lab , TopLoc_Location ())
149
143
setName (subassy , k , tool )
150
144
151
- # handle colors - this logic is needed for proper STEP export
152
- color = v .color
153
- tmp = v
154
- if coloredSTEP :
155
- while not color and tmp .parent :
156
- tmp = tmp .parent
157
- color = tmp .color
158
- if color :
159
- setColor (lab , color , ctool )
160
- else :
161
- if color :
162
- setColor (subassy , color , ctool )
145
+ if len (v .shapes ) > 0 :
146
+ # leaf part
147
+ lab = tool .NewShape ()
148
+ tool .SetShape (lab , Compound .makeCompound (v .shapes ).wrapped )
149
+ setName (lab , f"{ k } _part" , tool )
150
+
151
+ tool .AddComponent (subassy , lab , TopLoc_Location ())
152
+ setName (subassy , k , tool )
153
+
154
+ # handle colors - this logic is needed for proper STEP export
155
+ color = v .color
156
+ tmp = v
157
+ if coloredSTEP :
158
+ while not color and tmp .parent :
159
+ tmp = tmp .parent
160
+ color = tmp .color
161
+ if color :
162
+ setColor (lab , color , ctool )
163
+ else :
164
+ if color :
165
+ setColor (subassy , color , ctool )
163
166
164
167
subassys [k ] = (subassy , v .loc )
165
168
0 commit comments