09-30-2015 11:03 AM - edited 09-30-2015 11:04 AM
Hi,
I am trying to cut my waveform channels. I am using this script. Does anyone know why it doesn't work and how should I improve it?
Dim i, j, oMyUnit, iOffset, oMyChannels, chName iOffset = -0.1 for i=1 to GroupCount Call Data.Root.ChannelGroups(i).Activate '-------------------------- Vymaze nepotrebne kanaly ----------------------------------------------- ' Call ChnDelete("/DMS1+2") ' Call ChnDelete("/DMS2+3") ' Call ChnDelete("/DMS5+6") ' '-------- upravi offset na -0.1 a priradi jednotku sekundy ------ for j=1 to GroupChnCount(i) set oMyChannels = Data.Root.ChannelGroups(i).Channels(j) oMyChannels.Properties("wf_start_offset").Value = iOffset oMyChannels.Properties("wf_xunit_string").Value = "s" '-------------------------- Orizne kanaly -----------------------------------------------
chName = oMyChannels.Name Call ChnTimeAreaCopy ("", chName,"", chName, -0.01, 0.1) 'oriznuti dat next next
Thanks
10-01-2015 01:17 AM
Hi!
I am pretty sure I can help you along with that, but could you explain a little bit more what you mean with "cut my waveform channels"? By what criterion are you cutting the channel?
Perhaps I can give you some helpful function, even I do not understand completely what you want:
WfChnToChn & ChnToWfChn: converts Waveform channels back and forth to normal numeric channels with extra time channel
PNo: finds the (first) index of a value or the next best fit to that
DataBlDel: deletes a portion of a channel. you need the index and number of samples to delete.
Depending on what you are exactly trying to do you could just use DataBlDel and delete the parts of the waveform channel you dont need anymore. If you dont know the index and length of the desired channel part use PNo with a generated time channel (with WfChnToChn).
With the waveform channel you will probably need to adjust the start time of the channel since it is not automatically updated if you remove samples from the front of the channel.
Best regards,
Christoph
10-01-2015 01:31 AM
Hi,
thanks for your help. I have channels from -0.1 to 1 s. I am interested in a time -0.01 to 0.1 s. So I thought that I could use ChnTimeAreaCopy to copy out this time span from the channel and save it under the same name. For some reason this doesn't want to work in my script (although it works in the analysis mode when I do it manually).
I guess that I can get the time channel and use the procedure from your post. That was very helpful. Thanks
10-01-2015 02:24 AM
Hi,
I ran your code and just removed the two lines where you modify the properties and it works fine for me. What are you struggeling with?
Dim i, j, oMyUnit, iOffset, oMyChannels, chName for i=1 to GroupCount Call Data.Root.ChannelGroups(i).Activate for j=1 to GroupChnCount(i) set oMyChannels = Data.Root.ChannelGroups(i).Channels(j) chName = oMyChannels.Name Call ChnTimeAreaCopy ("", chName,"", chName, 1, 1.8) next next
Best regards,
Christoph
10-01-2015 02:34 AM
After running your code I get this error which is the same as mine 😞
2 9:33:06 Error: Error in <NoName(4).VBS> (Line: 14, Column: 5): Error while executing "ChnTimeAreaCopy" command Error type: ACCESS VIOLATION Error address: BC665456 Module name:DIAdem.exe
Thanks a lot for your help!
Petr
10-01-2015 06:41 AM
That's very unfortunate!
I cant image it is a scripting/programming error, so I would check when that behaviour occurs.
Which DIAdem version are you using? 32/64 bit? Can you reproduce that behaviour with different TDM(S) data files? Have you checked a different computer?
If you provide me with the (sample) data file and your exact script and give me your version info I can try to reproduce?!