Ticket #108 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

step management - Suggested part references are all the same

Reported by: pjoulaud Owned by:
Priority: major Milestone: openPLM-1.1 Official Release
Component: models & controllers Version:
Keywords: Cc:

Description (last modified by pjoulaud) (diff)

See picture attached.
I want to build a part structure based on a step file.
All suggested references for parts are the same (PART_00107) and process doesn't end successfully.
There is a hole in reference sequence (PART_00092 to PART_00096 are missing).
It seems the bug comes from this. To be confirmed.
Thank you.

Attachments

Capture.png Download (74.8 KB) - added by pjoulaud 7 years ago.
fix_Hole_interface_decomposition??.txt Download (1.1 KB) - added by Galech 7 years ago.
possible solution

Change History

Changed 7 years ago by pjoulaud

Changed 7 years ago by Galech

possible solution

comment:1 Changed 7 years ago by Galech

Verify if the changes proposed in the attached file are a correct solution to the problem

comment:2 Changed 7 years ago by pjoulaud

  • Description modified (diff)

comment:3 Changed 7 years ago by pcosquer

There are gaps since a revised part is count by the current algorithm.

I'm not sure it is a good idea to fill a gap between two references as it should be better
if parts created after a decomposition have continuous references.

An alternative way is to find the "maximum" reference and use it as a start:

from django.db.models import Max
import re
...
try:
    max_ref = Part.objects.filter(reference__regex="^PART_\d+$").order_by("-reference").values_list("reference",   flat=True)[0]
    new_ref = "PART_%05d" % (start + int(max_ref[5:]))
except IndexError as e:
    new_ref = "PART_00001"

This code may fail if the database does not accept the regular expression, I think it is ok with postgresql and
sqlite.

But there are still some issues if a part "PART_10" exists as it is "greater" than "PART_050".

A better solution:

  • add an hidden reference_number field to PLMObject automatically set according to the reference (0 if the reference could not be parsed )
  • Part.objects.order_by("-reference_number").values_list("reference_number", flat=True)[0] should always returns the right value

comment:4 Changed 7 years ago by pcosquer

  • Status changed from new to closed
  • Resolution set to fixed

I've added the field reference_number and some tests (revision [1195])

It should be fixed.

I'm closing this ticket. If you find a similar bug, you can reopen this ticket. In that case, please attach the STEP file (if possible).

Note: See TracTickets for help on using tickets.