|
|
@ -51,7 +51,7 @@ class AHB_ParseStep: |
|
|
|
|
|
|
|
|
|
|
|
if 0 <= object_idx < len(step_info.objects): |
|
|
|
if 0 <= object_idx < len(step_info.objects): |
|
|
|
object_info = step_info.objects[object_idx] |
|
|
|
object_info = step_info.objects[object_idx] |
|
|
|
print(obj.Label + " => " + object_info.name) |
|
|
|
print("phase 1 " + obj.Label + " => " + object_info.name) |
|
|
|
|
|
|
|
|
|
|
|
obj.Label = object_info.name |
|
|
|
obj.Label = object_info.name |
|
|
|
|
|
|
|
|
|
|
@ -68,27 +68,74 @@ class AHB_ParseStep: |
|
|
|
step_info2 = step_parser.parse(filename, 'SOLIDS') |
|
|
|
step_info2 = step_parser.parse(filename, 'SOLIDS') |
|
|
|
print("STEP names phase 2 (" + str(len(step_info2.objects)) + ")") |
|
|
|
print("STEP names phase 2 (" + str(len(step_info2.objects)) + ")") |
|
|
|
feature_idx = 0 |
|
|
|
feature_idx = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# don't know why, but these objects are not ordered like the others |
|
|
|
|
|
|
|
special_objects = { |
|
|
|
|
|
|
|
'10_01_003 F_st7758_1': 'COMPOUND004', # manivelle droite |
|
|
|
|
|
|
|
'CHO04': 'COMPOUND1257', # guidon |
|
|
|
|
|
|
|
'CHO40': 'COMPOUND1258', # garde-boue droit |
|
|
|
|
|
|
|
'CHO41': 'COMPOUND1259', # garde-boue gauche |
|
|
|
|
|
|
|
'Pochette laterale': 'COMPOUND1260', # pochette gauche |
|
|
|
|
|
|
|
'Pochette laterale_1': 'COMPOUND1261', # pochette droite |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
object_idx = -1 |
|
|
|
|
|
|
|
|
|
|
|
for obj in objects: |
|
|
|
for obj in objects: |
|
|
|
if obj.TypeId == 'Part::Feature': |
|
|
|
if obj.TypeId == 'Part::Feature': |
|
|
|
#print(obj.Label) |
|
|
|
if object_idx >= 0: |
|
|
|
if obj.Label.startswith("COMPOUND"): |
|
|
|
object_idx = object_idx + 1 |
|
|
|
feature_from_end = total_features - feature_idx |
|
|
|
|
|
|
|
object_idx = len(step_info2.objects) - feature_from_end |
|
|
|
explicit_object_idx = -1 |
|
|
|
#print(obj.Label + " object_idx=" + str(object_idx)) |
|
|
|
for s in special_objects.items(): |
|
|
|
if 0 <= object_idx < len(step_info2.objects): |
|
|
|
if obj.Label == s[1]: |
|
|
|
|
|
|
|
for idx, info in enumerate(step_info2.objects): |
|
|
|
|
|
|
|
if info.name == s[0]: |
|
|
|
|
|
|
|
explicit_object_idx = idx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if explicit_object_idx >= 0: |
|
|
|
|
|
|
|
object_idx = explicit_object_idx |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
|
|
if object_idx < 0 or object_idx >= len(step_info2.objects): |
|
|
|
|
|
|
|
break |
|
|
|
object_info = step_info2.objects[object_idx] |
|
|
|
object_info = step_info2.objects[object_idx] |
|
|
|
print(obj.Label + " => " + object_info.name) |
|
|
|
skip = False |
|
|
|
|
|
|
|
for s in special_objects.items(): |
|
|
|
|
|
|
|
if s[0] == object_info.name: |
|
|
|
|
|
|
|
skip = True |
|
|
|
|
|
|
|
if skip: |
|
|
|
|
|
|
|
object_idx = object_idx + 1 |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 0 <= object_idx < len(step_info2.objects): |
|
|
|
|
|
|
|
object_info = step_info2.objects[object_idx] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if obj.Label.startswith("COMPOUND"): |
|
|
|
|
|
|
|
print("phase 2 " + obj.Label + " => " + object_info.name + " (ref="+object_info.layer.reference+", layer="+object_info.layer.name+")") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "Base_OriginalLabel" not in obj.PropertiesList: |
|
|
|
|
|
|
|
obj.addProperty("App::PropertyString", "Base_OriginalLabel", "Base") |
|
|
|
|
|
|
|
obj.Base_OriginalLabel = obj.Label |
|
|
|
|
|
|
|
|
|
|
|
obj.Label = object_info.name |
|
|
|
obj.Label = object_info.name |
|
|
|
|
|
|
|
|
|
|
|
if object_info.layer is not None: |
|
|
|
if object_info.layer is not None: |
|
|
|
|
|
|
|
final_ref = step_parser.process_name(object_info.layer.reference)[1] |
|
|
|
|
|
|
|
if object_info.name == final_ref or object_info.name.startswith(final_ref + "_"): |
|
|
|
|
|
|
|
obj.Label = object_info.layer.reference |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
final_ref = object_info.layer.reference |
|
|
|
|
|
|
|
|
|
|
|
if "Base_Reference" not in obj.PropertiesList: |
|
|
|
if "Base_Reference" not in obj.PropertiesList: |
|
|
|
obj.addProperty("App::PropertyString", "Base_Reference", "Base") |
|
|
|
obj.addProperty("App::PropertyString", "Base_Reference", "Base") |
|
|
|
obj.Base_Reference = object_info.layer.reference |
|
|
|
obj.Base_Reference = final_ref |
|
|
|
|
|
|
|
|
|
|
|
if "Base_Layer" not in obj.PropertiesList: |
|
|
|
if "Base_Layer" not in obj.PropertiesList: |
|
|
|
obj.addProperty("App::PropertyString", "Base_Layer", "Base") |
|
|
|
obj.addProperty("App::PropertyString", "Base_Layer", "Base") |
|
|
|
obj.Base_Layer = object_info.layer.name |
|
|
|
obj.Base_Layer = object_info.layer.name |
|
|
|
|
|
|
|
|
|
|
|
feature_idx = feature_idx + 1 |
|
|
|
feature_idx = feature_idx + 1 |
|
|
|
|
|
|
|
|
|
|
|
print("STEP names import finished") |
|
|
|
print("STEP names import finished") |
|
|
|