MATLAB: TLC – Get the reference to the PWork vector in r2018a

cgtypeMATLABr2018asimulink codertlc

In R2017b the following would get me a reference to the PWork vector in a .tlc file:
%assign PWorkVarGroupIdx = ::CompiledModel.DWorks.DWork[block.DWork[2]._idx].VarGroupIdx
%assign PWorkName = ::CompiledModel.CGTypes.CGType[::CompiledModel.VarGroups.VarGroup[PWorkVarGroupIdx[0]].CGTypeIdx].Members.Member[PWorkVarGroupIdx[1]].Name
This no longer works in r2018a. The error I get is:
Unable to find Members within the CGType scope.
Does anybody know how to get the PWork vector in a .tlc file in r2018a?

Best Answer

Dear Glen,
It seems Mathworks has changed the API access for CGType massively since R2017b. The new API to query the CGType.Member.Name is LibCGTypeMemberName(cgTypeIdx, memberIdx) found in the following file.
MATLABROOT/rtw/c/tlc/lib/dtypelib.tlc:849:%% Function: LibCGTypeMemberName ===========================================
MATLABROOT/rtw/c/tlc/lib/dtypelib.tlc-850-%% Abstract:
MATLABROOT/rtw/c/tlc/lib/dtypelib.tlc-851-%% Returns the name of a member of a struct CGType
MATLABROOT/rtw/c/tlc/lib/dtypelib.tlc-852-%%
MATLABROOT/rtw/c/tlc/lib/dtypelib.tlc:853:%function LibCGTypeMemberName(cgTypeIdx, memberIdx) void
I am not sure if you are still looking for a solution to this question. But, I believe it is one of the only questions relevant to the recent change in the CGType APIs that I found on the Google searches and yet unanswered.
I would suggest finding the rest of the changed APIs by grep-ing through the installed TLC files in R2018a.
Hope this helps!
Siraj