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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

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

MadhaviG
12-Amethyst

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

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

 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

9 REPLIES 9

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

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. 

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

🙂 tried already.

I tried ProMdlSave() I also Regenerated the model when it was in the session and saved it using Creo menu.

Well here are few more details which I have found.

Copy works okay but I really want to rename the Asm (so that it will be reflected in any other in session model which is using it). 

Example: I have Asm1.asm. I Use ProMdlnameRename() to rename it to AsmRenamed.asm.

Now on when I use any of Rename,Copy,Backup fucntion() on AsmRenamed.asm; the resultant  asm keep on having external dependency to AsmRenamed.asm.

I do feel there has be some configuration to avoid this external dependency.

So far I have found and tried these options

default_ext_ref_scope skeleton_model
def_comp_ref_ctrl_exception no
def_obj_ref_ctrl_exception yes
new_ref_part_name_disabled yes
popup_refpairintch_window yes
remember_replaced_components yes
let_proe_rename_pdm_objects yes
rename_drawings_with_object none
ae_propagate_detail_dependency independent
allow_fully_dependent_copy no

 

😐 do not know what to try next; would see if I can remove this ext. dependency once i rename the asm

Are you renaming twice in same session? I mean a.asm to b.asm to C.asm in same session without closing and performing other operation? If so, why not to go with directly to C.asm frm a.asm? If not, may be erase not displayed should be a try.
Now I m personally interested to try this at my end whenever I get some time. Could you please tell me what exactly you are trying to implement....

yah user can rename the asm any number of times.

I just trying to implement a simple (sounds simple but giving me hard time Woman Frustrated ) Rename functionality using Toolkit.

I am clearing the session/not displayed models before every rename operation. 

I had also created a sample app just to find out the root cause.

here is what I have found:

1. it has nothing to do with renaming the parts of asm.

2. just create a simple asm  say First.asm and rename it to say Second.asm

    till now everything is okay. Even if you clear session and re-open Second.asm then also things will be fine.

3. Problem occures as soon as you perform rename (or copy/backup) operation on Second.asm

Say you rename Second.asm to Third.asm.

It will be fine in session. You can check Model References and you will not find any external dependency on Second.asm.

Now close the Third.asm; make sure Second.asm is not in session either.

( Weird thing: Just latest version gets renamed and I can see old versions with old name say First.asm/Second.asm)

Clear the session and re-open third.asm from disk(working dir).

you will see a missing External dependency for Second.asm.

 

Please let me know if you give it a try.

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

Above result is captured on Creo 3.0 M120.

@Ketan_Lalcheta thanks for sharing code that helped me find out the root cause.

 Woman Indifferent  filename had ext in it. That is what the problem was. Woman Embarassed

That is why it was renaming just the latest version and not the whole model.

 

Announcements


Top Tags