Skip to main content
1-Visitor
December 13, 2017
Solved

Urgent help needed : Toolkit : renaming an assembly adds in invalid external reference

  • December 13, 2017
  • 1 reply
  • 4099 views

Hello All,

 Please reply back if you know the solution.

I am trying to Rename and open active assembly. 

I tried using 

ProMdlnameRename,

ProMdlnameCopy,

ProMdlfileMdlnameCopy.

All three function shows the expected result but as soon as I erase the model from session and re-open it from working dir. it show missing references.

 

Original name: Org.asm Renamed to Org_Copy.asm

Somehow Org_Copy.asm gets an external reference added for Org.asm

How can I avoid/correct this external reference?

 

fyi:

1. I have followed the code mentioned in TestDbms_c.html

2. I read  this article 

https://www.ptc.com/en/support/article?n=CS190735#_ga=2.57112618.1072489329.1513065444-2007632961.1513065444

 

Best answer by Ketan_Lalcheta

Hello

 

I have a positive results.What I have done is as below:

-Open assembly manually having only one part

- Use code to get current mdl, rename it with suffix as _1 , save mdl, close window and do erase not displayed.

- Use code to retrive new (first renamed) mdl, rename it with suffix as _2 , save mdl, close window and do erase not displayed.

 

Manually checked and able to open second renamed assembly.

 

********************************************************************************************

ProError status = PRO_TK_GENERAL_ERROR;

//get current mdl
ProMdl objMdl;
status = ProMdlCurrentGet(&objMdl);

//Get name
ProName objName;
status = ProMdlNameGet(objMdl,objName);

//prepare first new name
ProName objNameFirst;
ProWstringCopy(objName,objNameFirst,PRO_VALUE_UNUSED);
ProWstringConcatenate(L"_1",objNameFirst,PRO_VALUE_UNUSED);

//first new name set
status = ProMdlnameRename(objMdl,objNameFirst);

//save model
status = ProMdlSave(objMdl);

//close current window
status = ProWindowCurrentClose();

//erase after first rename
status = ProMdlEraseAll(objMdl);

//Load first renamed model
ProMdl objMdlAfterFirst;
status = ProMdlnameRetrieve(objNameFirst,PRO_MDLFILE_ASSEMBLY,&objMdlAfterFirst);

//prepare second new name
ProName objNameSecond;
ProWstringCopy(objNameFirst,objNameSecond,PRO_VALUE_UNUSED);
ProWstringConcatenate(L"_2",objNameSecond,PRO_VALUE_UNUSED);

//second new name set
status = ProMdlnameRename(objMdlAfterFirst,objNameSecond);

//save model second rename
status = ProMdlSave(objMdlAfterFirst);

//close current window
status = ProWindowCurrentClose();

//erase after second rename
status = ProMdlEraseAll(objMdlAfterFirst);

return status;

 

 

 

********************************************************************************************

 Thanks and Regards

Ketan

1 reply

1-Visitor
December 14, 2017
Hope you are renaming only Main assembly and not child parts. If you are renaming child parts also, do start renaming parts first and then assembly. Additionally, If you do only SAVE A COPY, it will save main assembly might be into new location where child parts are not present. SAVE A BACKUP is correct method to do the same as it saves a copy of child parts as well. GIve a try to ProMdlnameBackup() API. HIH, Ketan
MadhaviG1-VisitorAuthor
1-Visitor
December 14, 2017

Thanks for the reply.

Rename works fine but "in session". No problem with references.

Changes are visible in session. As soon as session is refreshed changes are gone.

When I manually rename a model it gives two options "in session" , "in session and on disk".

Function does NOT give these options. Looks like by default it's "In session".

 

Yes I rename the parts too and sadly backing up is not the solution.

Renaming the parts first does not work 😕 

this is so weird. 

1-Visitor
December 15, 2017

As it is saved in session, could you please try with API ProMdlSave() after renaming models?