cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Removing duplicate relations created by a mapkey

B_Baker
10-Marble

Removing duplicate relations created by a mapkey

I have created a mapkey that users use for updating legacy Creo parts (Creo 6 and earlier).  We are now on Creo 9.

The mapkey checks for missing relations and parameters (including restricted) then adds them if they are missing.  The issue is that it will duplicate relations that already exist.  I put a pause in the mapkey telling them to delete old relations before continuing but we know that doesn't usually work. 

I also have Modecheck running looking for the missing relations and errors if they are missing.  It tries to add them even if they exist due to the fact that they are in the Post Regeneration relations. The relations that Modelcheck adds appear in the Initial relations. The reason for locating them in the Post Regeneration was that it was overwriting legacy relations located in the Initial relations.  It is causing a regeneration issue that Modelcheck flags.

In my mapkey I have relation written to bypass a couple relation (these came from PTC Tech support) and appear to work.

IF EXISTS("REV=PTC_WM_REVISION")==NO
REV=PTC_WM_REVISION
ENDIF
IF EXISTS("Weight=PRO_MP_MASS")==NO
Weight=PRO_MP_MASS
ENDIF

What I would like is for the mapkey to not enter relations again if they already exist.

 I have tried using the ‘IF EXISTS’ but not had much luck. 

1 ACCEPTED SOLUTION

Accepted Solutions
B_Baker
10-Marble
(To:dnordin)

Thank you both for the suggestions.

 

Martin, thank you for confirming that it is not working. I didn't think it would work but it came from PTC Tech Support.

 

At this point, I'm just going to remove Modelcheck forcing in the relations until at some point PTC decides to fix the issue of Modelcheck not using Post Regeneration.  The users will just have to follow directions!

View solution in original post

3 REPLIES 3

Hi,

I'm sorry, but I can't suggest a simple solution for you. Just adding some notes ...

 

1.] Using mapkey functionality you cannot check whether some relation exists or not.

 

2.] IF EXISTS("REV=PTC_WM_REVISION")==NO notation is incorrect

I guess you are trying to find relation "REV=PTC_WM_REVISION" ... this "functionality" is not implemented.

See https://support.ptc.com/help/creo/creo_pma/r10.0/usascii/#page/fundamentals/fundamentals/Passing_Strings_as_Arguments_in_Relations.html page for information related to  EXISTS() function.

In case that you want to test whether REV parameter exists, please use following notation (exclamation mark means logical not).

if !exists("REV")

 

3.] I'm not a Modelcheck expert.

 

4.] In the past I developed AutoIT script which in combination with trail files was able to check&correct relation. Unfortunately this solution is very complicated and it does not make any sense to provide it to you.

---

My solution executes following steps:

  • opens Relation dialog box
  • cuts the contents of Relation dialog box to clipboard (this removes all relations)
  • sends clipboard contents to external application
  • external application checks&corrects relation
  • external application puts relations to clipboard
  • the contents of clipboard is copied to Relation dialog box
  • Relation dialog box is closed
  • model is regenerated
  • model is saved

 


Martin Hanák
dnordin
15-Moonstone
(To:B_Baker)

B_Baker,

 

You can use an external script that can remove the unwanted/duplicate relations using "sed" (Streaming Editor) or something similar. There are versions of "sed" for Windows as well as functionality in Powershell and such.

 

You can have a mapkey open the relations dialog and export the relations to disk. You can then run your external script to manipulate the relations file as needed, and then you import the modified relations file back into Creo Parametric.

 

I would make the suggestion that you surround your "standard" relations (typically in your start models) with a header and footer. This allows your script that removes/updates your standard relations to be simplified. For example:

 

/* Begin standard relations
/* Do NOT edit the company standard relations

... enter all your standard relations here

/* End standard relations

 

Your relations editing script can now simply look for the header/footer combination and remove everything in between (including the header/footer) and replace it with your latest standards.

 

In your "sed" script, you'd use something along the lines of the following to remove the standard relations:

 

# Delete standard relations section
/\/* Begin standard relations/,/End standard relations/d

 

In the same "sed" script, you can add the new standards section back into the relations using the append functionality.

 

Regards,

Dan N.

B_Baker
10-Marble
(To:dnordin)

Thank you both for the suggestions.

 

Martin, thank you for confirming that it is not working. I didn't think it would work but it came from PTC Tech Support.

 

At this point, I'm just going to remove Modelcheck forcing in the relations until at some point PTC decides to fix the issue of Modelcheck not using Post Regeneration.  The users will just have to follow directions!

Top Tags