The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
Hi
If this works from the UI then I assume that your application is asynchronous or is it ?
If yes, make sure that the application user runs the same access control profile as the manual session.
You have set the config option let_proe_rename_pdm* (I’m not in front of a workstation, so this is not the full option name 😉). Take care what you doing here, you may loose Windchill references.
Re Q1: Not tried in JLink, but in OTK (C++) pfcModel::Rename() does work, so JLink Model.Rename() should work, too. In my tests (OTK), it worked even independent of let_proe_rename_pdm_objects no or yes.
Re Q2: No, checkout is not mandatory for rename in this context (an unlocked object in Creo is), but checkout unlocks the read-only state in Creo. There are other functions for unlocking (TK: ProMdlHasNoConflict(), ProMdlIsModifiable(), JLink: CheckIsModifiable()).
Re Q3: API should behave identically, but small differences can be expected (as in other parts of TK/OTK/JLink sometimes happens). One difference is "independent of let_proe_rename_pdm_objects", as I just learned from my tests.
Re Q4: Renaming Windchill-managed CAD objects: sometimes a Windchill workflow for renaming is preferred, sometimes from within Creo (ootb or custom). Both are supported, since API exists for renaming.
In your case, it looks like the read-only policy for checked-in Windchill objects causes the modifying API call to fail (despite CheckIsModifiable(false) => true; more on this below).
Checked-in objects are read-only by default. They can be unlocked manually and via API.
Note:
The first misconception is around ProMdlIsModifiable() or Java: CheckIsModifiable() (and I fell for this, too, since the wording/context is very confusing here):
The boolean result is not the actual modifiable state in Creo in terms of that "Edit" button (in the parameter dialog).
Java API doc CheckIsModifiable():
"[...] when [ShowUI] set to false no UI is enabled and the model is considered as modifiable if there are no conflicts that could not be overridden or resolved by default resolution actions."
This API is looking for conflicts in the workspace and subordinate models - not at this object's read-only state in Creo: it evaluates something else.
My tests with Creo 12.4.0.0 with a part object from Windchill regarding read-only policy since Creo Parametric 10 (CS419079/CS419066):
Using a synchronous OTK (C++) application, using pfcModel::Rename() (but any other modifying API call should also get the same errors, e.g. modifying parameters does).
Results of pfcModel::Rename() for a part that is...
Conclusion: Error due to read-only state and unrelated to value of let_proe_rename_pdm_objects (while the Creo GUI correctly reflects the setting let_proe_rename_pdm_objects @ File -> Manage File -> Rename).
PTC provided functions for the read-only state with Creo 12 (ProMdlIsModifiable() existed before):
https://support.ptc.com/help/creo/creo_pma/r12/usascii//index.html#page/whats_new_pma/creo_toolkit_read_only_locked_models.html
ProMdlHasNoConflict()
ProMdlsAreModifiable()
ProMdlsHaveNoConflict()
While this functions can unlock the read-only state, they can not reveal the actual read-only state in terms of that "Edit" button (in the parameter dialog) - and the docs never promised this.
I never got any indication for the read-only state from ProMdlHasNoConflict() or ProMdlIsModifiable(), see the test cases below.
Testing ProMdlHasNoConflict() and ProMdlIsModifiable(): using config.pro options:
and test part checked-in/read-only active:
Both functions do not affect check-in or read-only status if 2nd parameter PRO_B_FALSE:
ProMdlHasNoConflict(pMdl, PRO_B_FALSE, &bNoConflict) => PRO_TK_NO_ERROR, bNoConflict => PRO_B_TRUE
ProMdlIsModifiable(pMdl, PRO_B_FALSE, &bIsModifiable) => PRO_TK_NO_ERROR, bIsModifiable => PRO_B_TRUE <- This is the source of misunderstanding, because the object is checked-in & read-only active.
Both functions can affect check-in/read-only status with 2nd parameter PRO_B_TRUE:
ProMdlHasNoConflict(pMdl, PRO_B_TRUE, &bNoConflict) => PRO_TK_NO_ERROR, bNoConflict => PRO_B_TRUE, changed: read-only inactive, optional also check-in state
- triggers automatic Conflict Resolution (always without GUI, dm_checkout_on_the_fly applies)
ProMdlIsModifiable(pMdl, PRO_B_TRUE, &bIsModifiable)
- triggers Conflict Resolution: with or without GUI, depending on dm_auto_conflict_resolution.
-> Answer: Cancel => PRO_TK_NO_ERROR, bIsModifiable => PRO_B_FALSE, nothing changed (still checked-in/read-only active)
-> Answer: make read only, OK => PRO_TK_NO_ERROR, bIsModifiable => PRO_B_FALSE, changed: now also locked (pad lock symbol), (still checked-in/read-only active)
-> Answer: check out, OK => PRO_TK_NO_ERROR, bIsModifiable => PRO_B_TRUE, changed: checked-out/read-only inactive
-> Answer: continue, OK => PRO_TK_NO_ERROR, bIsModifiable => PRO_B_TRUE, changed: read-only inactive, (still checked-in)
My findings:
- ProMdlHasNoConflict(pMdl, PRO_B_TRUE, &bNoConflict) does what is configured by dm_checkout_on_the_fly (default: checkout). (Sidenote: under a special condition, after removing checked-out object etc., it fails with XToolkitGeneralError, and on next try succeeds.)
- Neither ProMdlHasNoConflict() nor ProMdlIsModifiable() can be used to check for the Checked-in/read-only state. I would have expected to be able to do it with ProMdlIsModifiable(pMdl, PRO_B_FALSE, &bIsModifiable), but it always returns PRO_B_TRUE (when modifyable and when read-only in terms of that "Edit" button (in the parameter dialog)).
Creo knows this read-only state and offers options to the user ("Edit" button), while TK/OTK applications can not detect this state. PTC should provide a way for this.
Additional background/workaround for C TOOLKIT: ProMdlReadonlyIgnore()
https://community.ptc.com/t5/Customization/ProMdlReadonlyIgnore-implementation/m-p/976820#M13529
Note: If I strech the scope from JLink API to C TK and C++ OTK, it's because TK/OTK is the full set of API and helps to understand Creo behavior.
Good answer Hannes! @nsalaorno Don’t expect a rename in Windchill as well😵
The role of PTC_COMMON_NAME must be more prominent in Creo. The filename as an ID, is not acceptable for a User. There is a much better behavior of customer ID’s in Creo required. The current requirements would not acceptable for me and a no go. But this may a different discussion 😎😉
