forked from youen/assembly_handbook
added code to better recognize vhelio references
This commit is contained in:
parent
819644560a
commit
4d6ee21709
@ -1,6 +1,12 @@
|
||||
import FreeCADGui as Gui
|
||||
import FreeCAD as App
|
||||
|
||||
import re
|
||||
_object_reference_re = re.compile("^(.*?_)?((CHO|ELE|ROU|TSM|QIN|ACC|DIV|TXT|FRN|T|M|L|R)[0-9]+)(_[0-9]*)?$")
|
||||
_object_reference_clean_re = re.compile("^(.*?)(_st[0-9]+)?$")
|
||||
_bad_reference_re = re.compile("^[0-9]*$")
|
||||
_has_number_re = re.compile("_[0-9]+$")
|
||||
|
||||
class AHB_ParseStep:
|
||||
def GetResources(self):
|
||||
return {"MenuText": "[dev] parse STEP",
|
||||
@ -38,6 +44,9 @@ class AHB_ParseStep:
|
||||
obj: App.DocumentObject
|
||||
for obj in objects:
|
||||
if obj.TypeId == 'Part::Feature':
|
||||
if "Base_OriginalLabel" in obj.PropertiesList:
|
||||
obj.Label = obj.Base_OriginalLabel
|
||||
|
||||
total_features = total_features + 1
|
||||
object_idx = -1
|
||||
if override_names:
|
||||
@ -119,26 +128,59 @@ class AHB_ParseStep:
|
||||
obj.addProperty("App::PropertyString", "Base_OriginalLabel", "Base")
|
||||
obj.Base_OriginalLabel = obj.Label
|
||||
|
||||
obj.Label = object_info.name
|
||||
|
||||
final_ref = self.parse_vhelio_reference(object_info.name)
|
||||
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
|
||||
if final_ref is None:
|
||||
final_ref = self.parse_vhelio_reference(step_parser.process_name(object_info.layer.reference)[1])
|
||||
|
||||
if final_ref is None:
|
||||
final_ref = step_parser.process_name(object_info.layer.reference)[1]
|
||||
if object_info.name != final_ref and not object_info.name.startswith(final_ref + "_"):
|
||||
final_ref = None
|
||||
|
||||
if final_ref is None:
|
||||
final_ref = step_parser.process_name(object_info.name)[1]
|
||||
|
||||
final_ref = _object_reference_clean_re.search(final_ref).group(1)
|
||||
|
||||
if _bad_reference_re.search(final_ref) is not None:
|
||||
final_ref = "inconnu"
|
||||
if object_info.layer is not None and _bad_reference_re.search(object_info.layer.reference) is None:
|
||||
final_ref = object_info.layer.reference
|
||||
|
||||
if object_info.name == final_ref or object_info.name.startswith(final_ref + "_"):
|
||||
new_label = object_info.layer.reference + "_" + final_ref
|
||||
else:
|
||||
if _bad_reference_re.search(object_info.name) is None or final_ref == "inconnu":
|
||||
new_label = object_info.name
|
||||
else:
|
||||
final_ref = object_info.layer.reference
|
||||
new_label = final_ref
|
||||
|
||||
if "Base_Reference" not in obj.PropertiesList:
|
||||
obj.addProperty("App::PropertyString", "Base_Reference", "Base")
|
||||
obj.Base_Reference = final_ref
|
||||
if _has_number_re.search(new_label) is None:
|
||||
new_label = new_label + "_01"
|
||||
|
||||
if "Base_Layer" not in obj.PropertiesList:
|
||||
obj.addProperty("App::PropertyString", "Base_Layer", "Base")
|
||||
obj.Label = new_label
|
||||
|
||||
if "Base_Reference" not in obj.PropertiesList:
|
||||
obj.addProperty("App::PropertyString", "Base_Reference", "Base")
|
||||
obj.Base_Reference = final_ref
|
||||
|
||||
if "Base_Layer" not in obj.PropertiesList:
|
||||
obj.addProperty("App::PropertyString", "Base_Layer", "Base")
|
||||
if object_info.layer is None:
|
||||
obj.Base_Layer = ""
|
||||
else:
|
||||
obj.Base_Layer = object_info.layer.name
|
||||
|
||||
feature_idx = feature_idx + 1
|
||||
|
||||
print("STEP names import finished")
|
||||
|
||||
def parse_vhelio_reference(self, str):
|
||||
object_reference_match = _object_reference_re.search(str)
|
||||
if object_reference_match is not None:
|
||||
return object_reference_match.group(2)
|
||||
return None
|
||||
|
||||
from ahb_command import AHB_CommandWrapper
|
||||
AHB_CommandWrapper.addGuiCommand('AHB_parse_step', AHB_ParseStep())
|
||||
|
@ -175,7 +175,7 @@ class AHB_Render:
|
||||
dir = os.path.dirname(filename)
|
||||
|
||||
if render_main:
|
||||
resolution = (2000,2000)
|
||||
resolution = (3000,3000)
|
||||
workbench.context.setAllStagesVisible(True)
|
||||
self.render(resolution, filename)
|
||||
img_full = Image.new('RGB', resolution, (255, 255, 255))
|
||||
@ -192,7 +192,7 @@ class AHB_Render:
|
||||
stage_name = str(stage_id)
|
||||
while len(stage_name) < 6:
|
||||
stage_name = "0" + stage_name
|
||||
resolution = (2000, 2000)
|
||||
resolution = (3000, 3000)
|
||||
if prev_stage_id is not None:
|
||||
workbench.context.setActiveStage(prev_stage_id)
|
||||
workbench.context.setAllStagesVisible(False)
|
||||
|
Loading…
Reference in New Issue
Block a user