08-10-2017 01:05 PM
I have a number of View Layouts, with many many sheets, resulting in a really lot of plots. But they almost all reference group numbers. As I've evolved my data analysis, my resulting TDM files don't always have the data groups in the same order. I started making plots reference by group name, but somewhere along the way, its almost all reverted back to numbers. I didn't find this come up before (surprisingly). Anyone already have a script for doing this conversion on every view in the current/every sheet of the open View layout? Still using version 2015, sorry.
Would like to know if a conversion button has been implemented in a later release, but I still need a solution for 2015. 🙂
--Scott
Solved! Go to Solution.
08-10-2017 02:01 PM
So I did discover that if I have the general settings to "group name" and move group 3 into the group 2 position in the Data Portal, it magically changes the references for the groups affected to the names of the groups. That was a bit unexpected. We'll see if it holds.
08-11-2017 02:39 AM
To standardize on group name instead of index you have to change DIAdem's general settings (Settings>>DIAdem Settings...) to use "Group name/Channel" name as address syntax
08-11-2017 06:31 AM
@StefanR wrote:
To standardize on group name instead of index you have to change DIAdem's general settings (Settings>>DIAdem Settings...) to use "Group name/Channel" name as address syntax
Yes, changing the settings is great for future views (and apparently affecting some existing view when you change group order) but it doesn't solve the problem of fixing existing group numbers to names in existing views.
08-14-2017 02:12 AM
Hi Scott,
you find below a script which works as requested. The only restriction is that you need a dataset which matches with the VIEW layout (no check whether a channel exists).
dim iLoop, jLoop, kLoop, oCurrArea, oCurrCurves for iLoop = 1 to View.Sheets.Count for jLoop = 1 to View.Sheets(iLoop).Areas.Count set oCurrArea = View.Sheets(iLoop).Areas(jLoop) if oCurrArea.DisplayObjType = "CurveChart2D" then set oCurrCurves = oCurrArea.DisplayObj.Curves2D for kLoop = 1 to oCurrCurves.Count if oCurrCurves(kLoop).XChannelName <> "" then oCurrCurves(kLoop).XChannelName = GetGroupNameAndChnName(oCurrCurves(kLoop).XChannelName) end if oCurrCurves(kLoop).YChannelName = GetGroupNameAndChnName(oCurrCurves(kLoop).YChannelName) next end if next next '------------------------------------------------------------------------------- function GetGroupNameAndChnName(sName) GetGroupNameAndChnName = Data.GetChannel(sName).GetReference(eRefTypeNameName) end function
Greetings
Walter
08-14-2017 09:25 AM
Quick update to the function to check for whether the channel exists.
Thank you Walter for the main code.
function GetGroupNameAndChnName(sName) if CNo(sName) Then GetGroupNameAndChnName = Data.GetChannel(sName).GetReference(eRefTypeNameName) else GetGroupNameAndChnName = sName end If end function
08-14-2017 09:33 AM
Hi Scott,
In DIAdem 2017 is CNO marked as obsolete. CNO is part of the old script syntax which is replaced by the data-api. With this background, I would recommend the following:
function GetGroupNameAndChnName(sName) if Data.GetChannels(sName).Count > 0 Then GetGroupNameAndChnName = Data.GetChannel(sName).GetReference(eRefTypeNameName) else GetGroupNameAndChnName = sName end If end function
Greetings
Walter
08-14-2017 09:41 AM
@Walter_Rick wrote:
Hi Scott,
In DIAdem 2017 is CNO marked as obsolete. CNO is part of the old script syntax which is replaced by the data-api. With this background, I would recommend the following:
function GetGroupNameAndChnName(sName) if Data.GetChannels(sName).Count > 0 Then GetGroupNameAndChnName = Data.GetChannel(sName).GetReference(eRefTypeNameName) else GetGroupNameAndChnName = sName end If end functionGreetings
Walter
Thank you Walter for the clarification.
Here's also a version (for anyone else how might want it) that only does the change on the active sheet. I have some layouts I don't want a global change.
dim jLoop, kLoop, oCurrArea, oCurrCurves for jLoop = 1 to View.ActiveSheet.Areas.Count set oCurrArea = View.ActiveSheet.Areas(jLoop) if oCurrArea.DisplayObjType = "CurveChart2D" then set oCurrCurves = oCurrArea.DisplayObj.Curves2D for kLoop = 1 to oCurrCurves.Count if oCurrCurves(kLoop).XChannelName <> "" then oCurrCurves(kLoop).XChannelName = GetGroupNameAndChnName(oCurrCurves(kLoop).XChannelName) end if oCurrCurves(kLoop).YChannelName = GetGroupNameAndChnName(oCurrCurves(kLoop).YChannelName) next end if next '------------------------------------------------------------------------------- function GetGroupNameAndChnName(sName) if Data.GetChannels(sName).Count > 0 Then GetGroupNameAndChnName = Data.GetChannel(sName).GetReference(eRefTypeNameName) else GetGroupNameAndChnName = sName end If end function